hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.05.24. 14:42



Jelenlévő felhasználók

Jelenleg 475 felhasználó van jelen :: 1 regisztrált, 0 rejtett és 474 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: Google [Bot] az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 3 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: .SMA fordítási hibák orvoslása
HozzászólásElküldve: 2018.04.01. 22:16 
Offline
Újonc

Csatlakozott: 2018.04.01. 22:03
Hozzászólások: 6
Megköszönték neki: 1 alkalommal
Sziasztok!

Módosításokat végeztem a zp50_item_grenade_infect.sma-ban, hogy legyen _p, _w model és ne ölje meg az utolsó embert. Ezutóbbi simán ment is, már működik is a szerveremen. Ám mikor egy külföldi tutorial (https://zombie-mod.ru/counter-strike/st ... -zp50.html) alapján módosítottam/adtam hozzá a sorokat, hogy legyen _p és_w model, a fordító 3 hibaüzenettel elintézett, amik a következők:

zp50_item_infection_bomb.sma(107) : error 017: undefined symbol "g_pmodel_grenade_infect"
zp50_item_infection_bomb.sma(107 -- 108) : error 088: number of arguments does not match definition
zp50_item_infection_bomb.sma(247) : warning 217: loose indentation

Ebben kérném a segítségét olyan szakinak, aki ért hozzá és meg tudná nekem oldani! :)

A .sma forrskód, amiben már benne vannak a módosításaim:

  1. /*================================================================================
  2.    
  3.     ---------------------------------
  4.     -*- [ZP] Item: Infection Bomb -*-
  5.     ---------------------------------
  6.    
  7.     This plugin is part of Zombie Plague Mod and is distributed under the
  8.     terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
  9.    
  10. ================================================================================*/
  11.  
  12. #define ITEM_NAME "Infection Bomb"
  13. #define ITEM_COST 20
  14.  
  15. #include <amxmodx>
  16. #include <fun>
  17. #include <fakemeta>
  18. #include <hamsandwich>
  19. #include <amx_settings_api>
  20. #include <cs_weap_models_api>
  21. #include <zp50_items>
  22. #include <zp50_gamemodes>
  23.  
  24. // Settings file
  25. new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
  26.  
  27. // Default sounds
  28. new const sound_grenade_infect_explode[][] = { "zombie_plague/grenade_infect.wav" }
  29. new const sound_grenade_infect_player[][] = { "scientist/scream20.wav" , "scientist/scream22.wav" , "scientist/scream05.wav" }
  30.  
  31. #define MODEL_MAX_LENGTH 64
  32. #define SOUND_MAX_LENGTH 64
  33. #define SPRITE_MAX_LENGTH 64
  34.  
  35. // Models
  36. new g_model_grenade_infect[MODEL_MAX_LENGTH] = "models/zombie_plague/v_fertozobomba.mdl"
  37. new g_model_pgrenade_infect[MODEL_MAX_LENGTH] = "models/zombie_plague/p_fertozobomba.mdl"
  38. new g_model_wgrenade_infect[MODEL_MAX_LENGTH] = "models/zombie_plague/w_fertozobomba.mdl"
  39.  
  40. // Sprites
  41. new g_sprite_grenade_trail[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"
  42. new g_sprite_grenade_ring[SPRITE_MAX_LENGTH] = "sprites/shockwave.spr"
  43.  
  44. new Array:g_sound_grenade_infect_explode
  45. new Array:g_sound_grenade_infect_player
  46.  
  47. // Explosion radius for custom grenades
  48. const Float:NADE_EXPLOSION_RADIUS = 240.0
  49.  
  50. // HACK: pev_ field used to store custom nade types and their values
  51. const PEV_NADE_TYPE = pev_flTimeStepSound
  52. const NADE_TYPE_INFECTION = 1111
  53.  
  54. new g_trailSpr, g_exploSpr
  55.  
  56. new g_ItemID
  57. new g_GameModeInfectionID
  58. new g_GameModeMultiID
  59. new g_InfectionBombCounter, cvar_infection_bomb_round_limit
  60.  
  61. public plugin_init()
  62. {
  63.     register_plugin("[ZP] Item: Infection Bomb", ZP_VERSION_STRING, "ZP Dev Team")
  64.    
  65.     register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  66.    
  67.     register_forward(FM_SetModel, "fw_SetModel")
  68.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  69.    
  70.     g_ItemID = zp_items_register(ITEM_NAME, ITEM_COST)
  71.     cvar_infection_bomb_round_limit = register_cvar("zp_infection_bomb_round_limit", "3")
  72. }
  73.  
  74. public plugin_precache()
  75. {
  76.     // Initialize arrays
  77.     g_sound_grenade_infect_explode = ArrayCreate(SOUND_MAX_LENGTH, 1)
  78.     g_sound_grenade_infect_player = ArrayCreate(SOUND_MAX_LENGTH, 1)
  79.    
  80.     // Load from external file
  81.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT EXPLODE", g_sound_grenade_infect_explode)
  82.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT PLAYER", g_sound_grenade_infect_player)
  83.    
  84.     // If we couldn't load custom sounds from file, use and save default ones
  85.     new index
  86.     if (ArraySize(g_sound_grenade_infect_explode) == 0)
  87.     {
  88.         for (index = 0; index < sizeof sound_grenade_infect_explode; index++)
  89.             ArrayPushString(g_sound_grenade_infect_explode, sound_grenade_infect_explode[index])
  90.        
  91.         // Save to external file
  92.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT EXPLODE", g_sound_grenade_infect_explode)
  93.     }
  94.     if (ArraySize(g_sound_grenade_infect_player) == 0)
  95.     {
  96.         for (index = 0; index < sizeof sound_grenade_infect_player; index++)
  97.             ArrayPushString(g_sound_grenade_infect_player, sound_grenade_infect_player[index])
  98.        
  99.         // Save to external file
  100.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT PLAYER", g_sound_grenade_infect_player)
  101.     }
  102.    
  103.     // Load from external file, save if not found
  104.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_grenade_infect, charsmax(g_model_grenade_infect)))
  105.         amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_grenade_infect)
  106.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_pgrenade_infect, charsmax(g_model_pgrenade_infect)))
  107.         amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_pmodel_grenade_infect)
  108.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_wgrenade_infect, charsmax(g_model_wgrenade_infect)))
  109.         amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_wgrenade_infect)
  110.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail, charsmax(g_sprite_grenade_trail)))
  111.         amx_save_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail)
  112.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "RING", g_sprite_grenade_ring, charsmax(g_sprite_grenade_ring)))
  113.         amx_save_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "RING", g_sprite_grenade_ring)
  114.    
  115.     // Precache sounds
  116.     new sound[SOUND_MAX_LENGTH]
  117.     for (index = 0; index < ArraySize(g_sound_grenade_infect_explode); index++)
  118.     {
  119.         ArrayGetString(g_sound_grenade_infect_explode, index, sound, charsmax(sound))
  120.         precache_sound(sound)
  121.     }
  122.     for (index = 0; index < ArraySize(g_sound_grenade_infect_player); index++)
  123.     {
  124.         ArrayGetString(g_sound_grenade_infect_player, index, sound, charsmax(sound))
  125.         precache_sound(sound)
  126.     }
  127.    
  128.     // Precache models
  129.     precache_model(g_model_grenade_infect)
  130.     precache_model(g_model_pgrenade_infect)
  131.     precache_model(g_model_wgrenade_infect)
  132.     g_trailSpr = precache_model(g_sprite_grenade_trail)
  133.     g_exploSpr = precache_model(g_sprite_grenade_ring)
  134. }
  135.  
  136. public plugin_cfg()
  137. {
  138.     g_GameModeInfectionID = zp_gamemodes_get_id("Infection Mode")
  139.     g_GameModeMultiID = zp_gamemodes_get_id("Multiple Infection Mode")
  140. }
  141.  
  142. public event_round_start()
  143. {
  144.     g_InfectionBombCounter = 0
  145. }
  146.  
  147. public zp_fw_items_select_pre(id, itemid, ignorecost)
  148. {
  149.     // This is not our item
  150.     if (itemid != g_ItemID)
  151.         return ZP_ITEM_AVAILABLE;
  152.    
  153.     // Infection bomb only available during infection modes
  154.     new current_mode = zp_gamemodes_get_current()
  155.     if (current_mode != g_GameModeInfectionID && current_mode != g_GameModeMultiID)
  156.         return ZP_ITEM_DONT_SHOW;
  157.    
  158.     // Infection bomb only available to zombies
  159.     if (!zp_core_is_zombie(id))
  160.         return ZP_ITEM_DONT_SHOW;
  161.    
  162.     // Display remaining item count for this round
  163.     static text[32]
  164.     formatex(text, charsmax(text), "[%d/%d]", g_InfectionBombCounter, get_pcvar_num(cvar_infection_bomb_round_limit))
  165.     zp_items_menu_text_add(text)
  166.    
  167.     // Reached infection bomb limit for this round
  168.     if (g_InfectionBombCounter >= get_pcvar_num(cvar_infection_bomb_round_limit))
  169.         return ZP_ITEM_NOT_AVAILABLE;
  170.    
  171.     // Player already owns infection bomb
  172.     if (user_has_weapon(id, CSW_HEGRENADE))
  173.         return ZP_ITEM_NOT_AVAILABLE;
  174.    
  175.     return ZP_ITEM_AVAILABLE;
  176. }
  177.  
  178. public zp_fw_items_select_post(id, itemid, ignorecost)
  179. {
  180.     // This is not our item
  181.     if (itemid != g_ItemID)
  182.         return;
  183.    
  184.     // Give infection bomb
  185.     give_item(id, "weapon_hegrenade")
  186.     g_InfectionBombCounter++
  187. }
  188.  
  189. public zp_fw_core_cure(id, attacker)
  190. {
  191.     // Remove custom grenade model
  192.     cs_reset_player_view_model(id, CSW_HEGRENADE)
  193. }
  194.  
  195. public zp_fw_core_infect_post(id, attacker)
  196. {
  197.     // Set custom grenade model
  198.     cs_set_player_view_model(id, CSW_HEGRENADE, g_model_grenade_infect)
  199.     cs_set_player_view_model(id, CSW_HEGRENADE, g_model_pgrenade_infect)
  200. }
  201.  
  202. // Forward Set Model
  203. public fw_SetModel(entity, const model[])
  204. {
  205.     // We don't care
  206.     if (strlen(model) < 8)
  207.         return FMRES_IGNORED
  208.    
  209.     // Narrow down our matches a bit
  210.     if (model[7] != 'w' || model[8] != '_')
  211.         return FMRES_IGNORED
  212.    
  213.     // Get damage time of grenade
  214.     static Float:dmgtime
  215.     pev(entity, pev_dmgtime, dmgtime)
  216.    
  217.     // Grenade not yet thrown
  218.     if (dmgtime == 0.0)
  219.         return FMRES_IGNORED
  220.    
  221.     // Grenade's owner isn't zombie?
  222.     if (!zp_core_is_zombie(pev(entity, pev_owner)))
  223.         return FMRES_IGNORED
  224.    
  225.     // HE Grenade
  226.     if (model[9] == 'h' && model[10] == 'e')
  227.     {
  228.         // Give it a glow
  229.         fm_set_rendering(entity, kRenderFxGlowShell, 0, 200, 0, kRenderNormal, 16);
  230.        
  231.         // And a colored trail
  232.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  233.         write_byte(TE_BEAMFOLLOW) // TE id
  234.         write_short(entity) // entity
  235.         write_short(g_trailSpr) // sprite
  236.         write_byte(10) // life
  237.         write_byte(10) // width
  238.         write_byte(0) // r
  239.         write_byte(200) // g
  240.         write_byte(0) // b
  241.         write_byte(200) // brightness
  242.         message_end()
  243.        
  244.         // Set grenade type on the thrown grenade entity
  245.         set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_INFECTION)
  246.         engfunc( EngFunc_SetModel, entity, g_model_wgrenade_infect)
  247.         return FMRES_SUPERCEDE
  248.     }
  249.         // W-he
  250.         return FMRES_IGNORED
  251. }
  252.  
  253. // Ham Grenade Think Forward
  254. public fw_ThinkGrenade(entity)
  255. {
  256.     // Invalid entity
  257.     if (!pev_valid(entity)) return HAM_IGNORED;
  258.    
  259.     // Get damage time of grenade
  260.     static Float:dmgtime
  261.     pev(entity, pev_dmgtime, dmgtime)
  262.    
  263.     // Check if it's time to go off
  264.     if (dmgtime > get_gametime())
  265.         return HAM_IGNORED;
  266.    
  267.     // Check if it's one of our custom nades
  268.     switch (pev(entity, PEV_NADE_TYPE))
  269.     {
  270.         case NADE_TYPE_INFECTION: // Infection Bomb
  271.         {
  272.             infection_explode(entity)
  273.             return HAM_SUPERCEDE;
  274.         }
  275.     }
  276.    
  277.     return HAM_IGNORED;
  278. }
  279.  
  280. // Infection Bomb Explosion
  281. infection_explode(ent)
  282. {
  283.     // Round ended
  284.     if (zp_gamemodes_get_current() == ZP_NO_GAME_MODE)
  285.     {
  286.         // Get rid of the grenade
  287.         engfunc(EngFunc_RemoveEntity, ent)
  288.         return;
  289.     }
  290.    
  291.     // Get origin
  292.     static Float:origin[3]
  293.     pev(ent, pev_origin, origin)
  294.    
  295.     // Make the explosion
  296.     create_blast(origin)
  297.    
  298.     // Infection nade explode sound
  299.     static sound[SOUND_MAX_LENGTH]
  300.     ArrayGetString(g_sound_grenade_infect_explode, random_num(0, ArraySize(g_sound_grenade_infect_explode) - 1), sound, charsmax(sound))
  301.     emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  302.    
  303.     // Get attacker
  304.     new attacker = pev(ent, pev_owner)
  305.    
  306.     // Infection bomb owner disconnected or not zombie anymore?
  307.     if (!is_user_connected(attacker) || !zp_core_is_zombie(attacker))
  308.     {
  309.         // Get rid of the grenade
  310.         engfunc(EngFunc_RemoveEntity, ent)
  311.         return;
  312.     }
  313.    
  314.     // Collisions
  315.     new victim = -1
  316.    
  317.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, NADE_EXPLOSION_RADIUS)) != 0)
  318.     {
  319.         // Only effect alive humans
  320.         if (!is_user_alive(victim) || zp_core_is_zombie(victim))
  321.             continue;
  322.        
  323.         // Last human is killed
  324.         if (zp_core_get_human_count() == 1)
  325.         {
  326.             //ExecuteHamB(Ham_Killed, victim, attacker, 0)
  327.             continue;
  328.         }
  329.        
  330.         // Turn into zombie
  331.         zp_core_infect(victim, attacker)
  332.        
  333.         // Victim's sound
  334.         ArrayGetString(g_sound_grenade_infect_player, random_num(0, ArraySize(g_sound_grenade_infect_player) - 1), sound, charsmax(sound))
  335.         emit_sound(victim, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  336.     }
  337.    
  338.     // Get rid of the grenade
  339.     engfunc(EngFunc_RemoveEntity, ent)
  340. }
  341.  
  342. // Infection Bomb: Green Blast
  343. create_blast(const Float:origin[3])
  344. {
  345.     // Smallest ring
  346.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  347.     write_byte(TE_BEAMCYLINDER) // TE id
  348.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  349.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  350.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  351.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  352.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  353.     engfunc(EngFunc_WriteCoord, origin[2]+385.0) // z axis
  354.     write_short(g_exploSpr) // sprite
  355.     write_byte(0) // startframe
  356.     write_byte(0) // framerate
  357.     write_byte(4) // life
  358.     write_byte(60) // width
  359.     write_byte(0) // noise
  360.     write_byte(0) // red
  361.     write_byte(200) // green
  362.     write_byte(0) // blue
  363.     write_byte(200) // brightness
  364.     write_byte(0) // speed
  365.     message_end()
  366.    
  367.     // Medium ring
  368.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  369.     write_byte(TE_BEAMCYLINDER) // TE id
  370.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  371.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  372.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  373.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  374.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  375.     engfunc(EngFunc_WriteCoord, origin[2]+470.0) // z axis
  376.     write_short(g_exploSpr) // sprite
  377.     write_byte(0) // startframe
  378.     write_byte(0) // framerate
  379.     write_byte(4) // life
  380.     write_byte(60) // width
  381.     write_byte(0) // noise
  382.     write_byte(0) // red
  383.     write_byte(200) // green
  384.     write_byte(0) // blue
  385.     write_byte(200) // brightness
  386.     write_byte(0) // speed
  387.     message_end()
  388.    
  389.     // Largest ring
  390.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  391.     write_byte(TE_BEAMCYLINDER) // TE id
  392.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  393.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  394.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  395.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  396.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  397.     engfunc(EngFunc_WriteCoord, origin[2]+555.0) // z axis
  398.     write_short(g_exploSpr) // sprite
  399.     write_byte(0) // startframe
  400.     write_byte(0) // framerate
  401.     write_byte(4) // life
  402.     write_byte(60) // width
  403.     write_byte(0) // noise
  404.     write_byte(0) // red
  405.     write_byte(200) // green
  406.     write_byte(0) // blue
  407.     write_byte(200) // brightness
  408.     write_byte(0) // speed
  409.     message_end()
  410. }
  411.  
  412. // Set entity's rendering type (from fakemeta_util)
  413. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  414. {
  415.     static Float:color[3]
  416.     color[0] = float(r)
  417.     color[1] = float(g)
  418.     color[2] = float(b)
  419.    
  420.     set_pev(entity, pev_renderfx, fx)
  421.     set_pev(entity, pev_rendercolor, color)
  422.     set_pev(entity, pev_rendermode, render)
  423.     set_pev(entity, pev_renderamt, float(amount))
  424. }


Előre is köszönöm szépen a segítséget! :)

Steamen is kereshettek, de ha itt válaszoltok, az is tökéletes! :)

http://steamcommunity.com/id/nemesa95/


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: .SMA fordítási hibák orvoslása
HozzászólásElküldve: 2018.04.02. 05:46 
Offline
Senior Tag
Avatar

Csatlakozott: 2018.02.01. 16:27
Hozzászólások: 225
Megköszönt másnak: 14 alkalommal
Megköszönték neki: 18 alkalommal
Candyman írta:
Sziasztok!

Módosításokat végeztem a zp50_item_grenade_infect.sma-ban, hogy legyen _p, _w model és ne ölje meg az utolsó embert. Ezutóbbi simán ment is, már működik is a szerveremen. Ám mikor egy külföldi tutorial (https://zombie-mod.ru/counter-strike/st ... -zp50.html) alapján módosítottam/adtam hozzá a sorokat, hogy legyen _p és_w model, a fordító 3 hibaüzenettel elintézett, amik a következők:

zp50_item_infection_bomb.sma(107) : error 017: undefined symbol "g_pmodel_grenade_infect"
zp50_item_infection_bomb.sma(107 -- 108) : error 088: number of arguments does not match definition
zp50_item_infection_bomb.sma(247) : warning 217: loose indentation

Ebben kérném a segítségét olyan szakinak, aki ért hozzá és meg tudná nekem oldani! :)

A .sma forrskód, amiben már benne vannak a módosításaim:

  1. /*================================================================================
  2.    
  3.     ---------------------------------
  4.     -*- [ZP] Item: Infection Bomb -*-
  5.     ---------------------------------
  6.    
  7.     This plugin is part of Zombie Plague Mod and is distributed under the
  8.     terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
  9.    
  10. ================================================================================*/
  11.  
  12. #define ITEM_NAME "Infection Bomb"
  13. #define ITEM_COST 20
  14.  
  15. #include <amxmodx>
  16. #include <fun>
  17. #include <fakemeta>
  18. #include <hamsandwich>
  19. #include <amx_settings_api>
  20. #include <cs_weap_models_api>
  21. #include <zp50_items>
  22. #include <zp50_gamemodes>
  23.  
  24. // Settings file
  25. new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
  26.  
  27. // Default sounds
  28. new const sound_grenade_infect_explode[][] = { "zombie_plague/grenade_infect.wav" }
  29. new const sound_grenade_infect_player[][] = { "scientist/scream20.wav" , "scientist/scream22.wav" , "scientist/scream05.wav" }
  30.  
  31. #define MODEL_MAX_LENGTH 64
  32. #define SOUND_MAX_LENGTH 64
  33. #define SPRITE_MAX_LENGTH 64
  34.  
  35. // Models
  36. new g_model_grenade_infect[MODEL_MAX_LENGTH] = "models/zombie_plague/v_fertozobomba.mdl"
  37. new g_model_pgrenade_infect[MODEL_MAX_LENGTH] = "models/zombie_plague/p_fertozobomba.mdl"
  38. new g_model_wgrenade_infect[MODEL_MAX_LENGTH] = "models/zombie_plague/w_fertozobomba.mdl"
  39.  
  40. // Sprites
  41. new g_sprite_grenade_trail[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"
  42. new g_sprite_grenade_ring[SPRITE_MAX_LENGTH] = "sprites/shockwave.spr"
  43.  
  44. new Array:g_sound_grenade_infect_explode
  45. new Array:g_sound_grenade_infect_player
  46.  
  47. // Explosion radius for custom grenades
  48. const Float:NADE_EXPLOSION_RADIUS = 240.0
  49.  
  50. // HACK: pev_ field used to store custom nade types and their values
  51. const PEV_NADE_TYPE = pev_flTimeStepSound
  52. const NADE_TYPE_INFECTION = 1111
  53.  
  54. new g_trailSpr, g_exploSpr
  55.  
  56. new g_ItemID
  57. new g_GameModeInfectionID
  58. new g_GameModeMultiID
  59. new g_InfectionBombCounter, cvar_infection_bomb_round_limit
  60.  
  61. public plugin_init()
  62. {
  63.     register_plugin("[ZP] Item: Infection Bomb", ZP_VERSION_STRING, "ZP Dev Team")
  64.    
  65.     register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  66.    
  67.     register_forward(FM_SetModel, "fw_SetModel")
  68.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  69.    
  70.     g_ItemID = zp_items_register(ITEM_NAME, ITEM_COST)
  71.     cvar_infection_bomb_round_limit = register_cvar("zp_infection_bomb_round_limit", "3")
  72. }
  73.  
  74. public plugin_precache()
  75. {
  76.     // Initialize arrays
  77.     g_sound_grenade_infect_explode = ArrayCreate(SOUND_MAX_LENGTH, 1)
  78.     g_sound_grenade_infect_player = ArrayCreate(SOUND_MAX_LENGTH, 1)
  79.    
  80.     // Load from external file
  81.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT EXPLODE", g_sound_grenade_infect_explode)
  82.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT PLAYER", g_sound_grenade_infect_player)
  83.    
  84.     // If we couldn't load custom sounds from file, use and save default ones
  85.     new index
  86.     if (ArraySize(g_sound_grenade_infect_explode) == 0)
  87.     {
  88.         for (index = 0; index < sizeof sound_grenade_infect_explode; index++)
  89.             ArrayPushString(g_sound_grenade_infect_explode, sound_grenade_infect_explode[index])
  90.        
  91.         // Save to external file
  92.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT EXPLODE", g_sound_grenade_infect_explode)
  93.     }
  94.     if (ArraySize(g_sound_grenade_infect_player) == 0)
  95.     {
  96.         for (index = 0; index < sizeof sound_grenade_infect_player; index++)
  97.             ArrayPushString(g_sound_grenade_infect_player, sound_grenade_infect_player[index])
  98.        
  99.         // Save to external file
  100.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT PLAYER", g_sound_grenade_infect_player)
  101.     }
  102.    
  103.     // Load from external file, save if not found
  104.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_grenade_infect, charsmax(g_model_grenade_infect)))
  105.         amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_grenade_infect)
  106.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_pgrenade_infect, charsmax(g_model_pgrenade_infect)))
  107.         amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_pmodel_grenade_infect)
  108.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_wgrenade_infect, charsmax(g_model_wgrenade_infect)))
  109.         amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_wgrenade_infect)
  110.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail, charsmax(g_sprite_grenade_trail)))
  111.         amx_save_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail)
  112.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "RING", g_sprite_grenade_ring, charsmax(g_sprite_grenade_ring)))
  113.         amx_save_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "RING", g_sprite_grenade_ring)
  114.    
  115.     // Precache sounds
  116.     new sound[SOUND_MAX_LENGTH]
  117.     for (index = 0; index < ArraySize(g_sound_grenade_infect_explode); index++)
  118.     {
  119.         ArrayGetString(g_sound_grenade_infect_explode, index, sound, charsmax(sound))
  120.         precache_sound(sound)
  121.     }
  122.     for (index = 0; index < ArraySize(g_sound_grenade_infect_player); index++)
  123.     {
  124.         ArrayGetString(g_sound_grenade_infect_player, index, sound, charsmax(sound))
  125.         precache_sound(sound)
  126.     }
  127.    
  128.     // Precache models
  129.     precache_model(g_model_grenade_infect)
  130.     precache_model(g_model_pgrenade_infect)
  131.     precache_model(g_model_wgrenade_infect)
  132.     g_trailSpr = precache_model(g_sprite_grenade_trail)
  133.     g_exploSpr = precache_model(g_sprite_grenade_ring)
  134. }
  135.  
  136. public plugin_cfg()
  137. {
  138.     g_GameModeInfectionID = zp_gamemodes_get_id("Infection Mode")
  139.     g_GameModeMultiID = zp_gamemodes_get_id("Multiple Infection Mode")
  140. }
  141.  
  142. public event_round_start()
  143. {
  144.     g_InfectionBombCounter = 0
  145. }
  146.  
  147. public zp_fw_items_select_pre(id, itemid, ignorecost)
  148. {
  149.     // This is not our item
  150.     if (itemid != g_ItemID)
  151.         return ZP_ITEM_AVAILABLE;
  152.    
  153.     // Infection bomb only available during infection modes
  154.     new current_mode = zp_gamemodes_get_current()
  155.     if (current_mode != g_GameModeInfectionID && current_mode != g_GameModeMultiID)
  156.         return ZP_ITEM_DONT_SHOW;
  157.    
  158.     // Infection bomb only available to zombies
  159.     if (!zp_core_is_zombie(id))
  160.         return ZP_ITEM_DONT_SHOW;
  161.    
  162.     // Display remaining item count for this round
  163.     static text[32]
  164.     formatex(text, charsmax(text), "[%d/%d]", g_InfectionBombCounter, get_pcvar_num(cvar_infection_bomb_round_limit))
  165.     zp_items_menu_text_add(text)
  166.    
  167.     // Reached infection bomb limit for this round
  168.     if (g_InfectionBombCounter >= get_pcvar_num(cvar_infection_bomb_round_limit))
  169.         return ZP_ITEM_NOT_AVAILABLE;
  170.    
  171.     // Player already owns infection bomb
  172.     if (user_has_weapon(id, CSW_HEGRENADE))
  173.         return ZP_ITEM_NOT_AVAILABLE;
  174.    
  175.     return ZP_ITEM_AVAILABLE;
  176. }
  177.  
  178. public zp_fw_items_select_post(id, itemid, ignorecost)
  179. {
  180.     // This is not our item
  181.     if (itemid != g_ItemID)
  182.         return;
  183.    
  184.     // Give infection bomb
  185.     give_item(id, "weapon_hegrenade")
  186.     g_InfectionBombCounter++
  187. }
  188.  
  189. public zp_fw_core_cure(id, attacker)
  190. {
  191.     // Remove custom grenade model
  192.     cs_reset_player_view_model(id, CSW_HEGRENADE)
  193. }
  194.  
  195. public zp_fw_core_infect_post(id, attacker)
  196. {
  197.     // Set custom grenade model
  198.     cs_set_player_view_model(id, CSW_HEGRENADE, g_model_grenade_infect)
  199.     cs_set_player_view_model(id, CSW_HEGRENADE, g_model_pgrenade_infect)
  200. }
  201.  
  202. // Forward Set Model
  203. public fw_SetModel(entity, const model[])
  204. {
  205.     // We don't care
  206.     if (strlen(model) < 8)
  207.         return FMRES_IGNORED
  208.    
  209.     // Narrow down our matches a bit
  210.     if (model[7] != 'w' || model[8] != '_')
  211.         return FMRES_IGNORED
  212.    
  213.     // Get damage time of grenade
  214.     static Float:dmgtime
  215.     pev(entity, pev_dmgtime, dmgtime)
  216.    
  217.     // Grenade not yet thrown
  218.     if (dmgtime == 0.0)
  219.         return FMRES_IGNORED
  220.    
  221.     // Grenade's owner isn't zombie?
  222.     if (!zp_core_is_zombie(pev(entity, pev_owner)))
  223.         return FMRES_IGNORED
  224.    
  225.     // HE Grenade
  226.     if (model[9] == 'h' && model[10] == 'e')
  227.     {
  228.         // Give it a glow
  229.         fm_set_rendering(entity, kRenderFxGlowShell, 0, 200, 0, kRenderNormal, 16);
  230.        
  231.         // And a colored trail
  232.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  233.         write_byte(TE_BEAMFOLLOW) // TE id
  234.         write_short(entity) // entity
  235.         write_short(g_trailSpr) // sprite
  236.         write_byte(10) // life
  237.         write_byte(10) // width
  238.         write_byte(0) // r
  239.         write_byte(200) // g
  240.         write_byte(0) // b
  241.         write_byte(200) // brightness
  242.         message_end()
  243.        
  244.         // Set grenade type on the thrown grenade entity
  245.         set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_INFECTION)
  246.         engfunc( EngFunc_SetModel, entity, g_model_wgrenade_infect)
  247.         return FMRES_SUPERCEDE
  248.     }
  249.         // W-he
  250.         return FMRES_IGNORED
  251. }
  252.  
  253. // Ham Grenade Think Forward
  254. public fw_ThinkGrenade(entity)
  255. {
  256.     // Invalid entity
  257.     if (!pev_valid(entity)) return HAM_IGNORED;
  258.    
  259.     // Get damage time of grenade
  260.     static Float:dmgtime
  261.     pev(entity, pev_dmgtime, dmgtime)
  262.    
  263.     // Check if it's time to go off
  264.     if (dmgtime > get_gametime())
  265.         return HAM_IGNORED;
  266.    
  267.     // Check if it's one of our custom nades
  268.     switch (pev(entity, PEV_NADE_TYPE))
  269.     {
  270.         case NADE_TYPE_INFECTION: // Infection Bomb
  271.         {
  272.             infection_explode(entity)
  273.             return HAM_SUPERCEDE;
  274.         }
  275.     }
  276.    
  277.     return HAM_IGNORED;
  278. }
  279.  
  280. // Infection Bomb Explosion
  281. infection_explode(ent)
  282. {
  283.     // Round ended
  284.     if (zp_gamemodes_get_current() == ZP_NO_GAME_MODE)
  285.     {
  286.         // Get rid of the grenade
  287.         engfunc(EngFunc_RemoveEntity, ent)
  288.         return;
  289.     }
  290.    
  291.     // Get origin
  292.     static Float:origin[3]
  293.     pev(ent, pev_origin, origin)
  294.    
  295.     // Make the explosion
  296.     create_blast(origin)
  297.    
  298.     // Infection nade explode sound
  299.     static sound[SOUND_MAX_LENGTH]
  300.     ArrayGetString(g_sound_grenade_infect_explode, random_num(0, ArraySize(g_sound_grenade_infect_explode) - 1), sound, charsmax(sound))
  301.     emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  302.    
  303.     // Get attacker
  304.     new attacker = pev(ent, pev_owner)
  305.    
  306.     // Infection bomb owner disconnected or not zombie anymore?
  307.     if (!is_user_connected(attacker) || !zp_core_is_zombie(attacker))
  308.     {
  309.         // Get rid of the grenade
  310.         engfunc(EngFunc_RemoveEntity, ent)
  311.         return;
  312.     }
  313.    
  314.     // Collisions
  315.     new victim = -1
  316.    
  317.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, NADE_EXPLOSION_RADIUS)) != 0)
  318.     {
  319.         // Only effect alive humans
  320.         if (!is_user_alive(victim) || zp_core_is_zombie(victim))
  321.             continue;
  322.        
  323.         // Last human is killed
  324.         if (zp_core_get_human_count() == 1)
  325.         {
  326.             //ExecuteHamB(Ham_Killed, victim, attacker, 0)
  327.             continue;
  328.         }
  329.        
  330.         // Turn into zombie
  331.         zp_core_infect(victim, attacker)
  332.        
  333.         // Victim's sound
  334.         ArrayGetString(g_sound_grenade_infect_player, random_num(0, ArraySize(g_sound_grenade_infect_player) - 1), sound, charsmax(sound))
  335.         emit_sound(victim, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  336.     }
  337.    
  338.     // Get rid of the grenade
  339.     engfunc(EngFunc_RemoveEntity, ent)
  340. }
  341.  
  342. // Infection Bomb: Green Blast
  343. create_blast(const Float:origin[3])
  344. {
  345.     // Smallest ring
  346.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  347.     write_byte(TE_BEAMCYLINDER) // TE id
  348.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  349.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  350.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  351.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  352.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  353.     engfunc(EngFunc_WriteCoord, origin[2]+385.0) // z axis
  354.     write_short(g_exploSpr) // sprite
  355.     write_byte(0) // startframe
  356.     write_byte(0) // framerate
  357.     write_byte(4) // life
  358.     write_byte(60) // width
  359.     write_byte(0) // noise
  360.     write_byte(0) // red
  361.     write_byte(200) // green
  362.     write_byte(0) // blue
  363.     write_byte(200) // brightness
  364.     write_byte(0) // speed
  365.     message_end()
  366.    
  367.     // Medium ring
  368.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  369.     write_byte(TE_BEAMCYLINDER) // TE id
  370.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  371.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  372.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  373.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  374.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  375.     engfunc(EngFunc_WriteCoord, origin[2]+470.0) // z axis
  376.     write_short(g_exploSpr) // sprite
  377.     write_byte(0) // startframe
  378.     write_byte(0) // framerate
  379.     write_byte(4) // life
  380.     write_byte(60) // width
  381.     write_byte(0) // noise
  382.     write_byte(0) // red
  383.     write_byte(200) // green
  384.     write_byte(0) // blue
  385.     write_byte(200) // brightness
  386.     write_byte(0) // speed
  387.     message_end()
  388.    
  389.     // Largest ring
  390.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  391.     write_byte(TE_BEAMCYLINDER) // TE id
  392.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  393.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  394.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  395.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  396.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  397.     engfunc(EngFunc_WriteCoord, origin[2]+555.0) // z axis
  398.     write_short(g_exploSpr) // sprite
  399.     write_byte(0) // startframe
  400.     write_byte(0) // framerate
  401.     write_byte(4) // life
  402.     write_byte(60) // width
  403.     write_byte(0) // noise
  404.     write_byte(0) // red
  405.     write_byte(200) // green
  406.     write_byte(0) // blue
  407.     write_byte(200) // brightness
  408.     write_byte(0) // speed
  409.     message_end()
  410. }
  411.  
  412. // Set entity's rendering type (from fakemeta_util)
  413. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  414. {
  415.     static Float:color[3]
  416.     color[0] = float(r)
  417.     color[1] = float(g)
  418.     color[2] = float(b)
  419.    
  420.     set_pev(entity, pev_renderfx, fx)
  421.     set_pev(entity, pev_rendercolor, color)
  422.     set_pev(entity, pev_rendermode, render)
  423.     set_pev(entity, pev_renderamt, float(amount))
  424. }


Előre is köszönöm szépen a segítséget! :)

Steamen is kereshettek, de ha itt válaszoltok, az is tökéletes! :)

http://steamcommunity.com/id/nemesa95/



Helló!

Ez volt elírva: ' g_pmodel_grenade_infect '

Parancsolj:

  1. /*================================================================================
  2.    
  3.     ---------------------------------
  4.     -*- [ZP] Item: Infection Bomb -*-
  5.     ---------------------------------
  6.    
  7.     This plugin is part of Zombie Plague Mod and is distributed under the
  8.     terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
  9.    
  10. ================================================================================*/
  11.  
  12. #define ITEM_NAME "Infection Bomb"
  13. #define ITEM_COST 20
  14.  
  15. #include <amxmodx>
  16. #include <fun>
  17. #include <fakemeta>
  18. #include <hamsandwich>
  19. #include <amx_settings_api>
  20. #include <cs_weap_models_api>
  21. #include <zp50_items>
  22. #include <zp50_gamemodes>
  23.  
  24. // Settings file
  25. new const ZP_SETTINGS_FILE[] = "zombieplague.ini"
  26.  
  27. // Default sounds
  28. new const sound_grenade_infect_explode[][] = { "zombie_plague/grenade_infect.wav" }
  29. new const sound_grenade_infect_player[][] = { "scientist/scream20.wav" , "scientist/scream22.wav" , "scientist/scream05.wav" }
  30.  
  31. #define MODEL_MAX_LENGTH 64
  32. #define SOUND_MAX_LENGTH 64
  33. #define SPRITE_MAX_LENGTH 64
  34.  
  35. // Models
  36. new g_model_grenade_infect[MODEL_MAX_LENGTH] = "models/zombie_plague/v_fertozobomba.mdl"
  37. new g_model_pgrenade_infect[MODEL_MAX_LENGTH] = "models/zombie_plague/p_fertozobomba.mdl"
  38. new g_model_wgrenade_infect[MODEL_MAX_LENGTH] = "models/zombie_plague/w_fertozobomba.mdl"
  39.  
  40. // Sprites
  41. new g_sprite_grenade_trail[SPRITE_MAX_LENGTH] = "sprites/laserbeam.spr"
  42. new g_sprite_grenade_ring[SPRITE_MAX_LENGTH] = "sprites/shockwave.spr"
  43.  
  44. new Array:g_sound_grenade_infect_explode
  45. new Array:g_sound_grenade_infect_player
  46.  
  47. // Explosion radius for custom grenades
  48. const Float:NADE_EXPLOSION_RADIUS = 240.0
  49.  
  50. // HACK: pev_ field used to store custom nade types and their values
  51. const PEV_NADE_TYPE = pev_flTimeStepSound
  52. const NADE_TYPE_INFECTION = 1111
  53.  
  54. new g_trailSpr, g_exploSpr
  55.  
  56. new g_ItemID
  57. new g_GameModeInfectionID
  58. new g_GameModeMultiID
  59. new g_InfectionBombCounter, cvar_infection_bomb_round_limit
  60.  
  61. public plugin_init()
  62. {
  63.     register_plugin("[ZP] Item: Infection Bomb", ZP_VERSION_STRING, "ZP Dev Team")
  64.    
  65.     register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  66.    
  67.     register_forward(FM_SetModel, "fw_SetModel")
  68.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  69.    
  70.     g_ItemID = zp_items_register(ITEM_NAME, ITEM_COST)
  71.     cvar_infection_bomb_round_limit = register_cvar("zp_infection_bomb_round_limit", "3")
  72. }
  73.  
  74. public plugin_precache()
  75. {
  76.     // Initialize arrays
  77.     g_sound_grenade_infect_explode = ArrayCreate(SOUND_MAX_LENGTH, 1)
  78.     g_sound_grenade_infect_player = ArrayCreate(SOUND_MAX_LENGTH, 1)
  79.    
  80.     // Load from external file
  81.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT EXPLODE", g_sound_grenade_infect_explode)
  82.     amx_load_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT PLAYER", g_sound_grenade_infect_player)
  83.    
  84.     // If we couldn't load custom sounds from file, use and save default ones
  85.     new index
  86.     if (ArraySize(g_sound_grenade_infect_explode) == 0)
  87.     {
  88.         for (index = 0; index < sizeof sound_grenade_infect_explode; index++)
  89.             ArrayPushString(g_sound_grenade_infect_explode, sound_grenade_infect_explode[index])
  90.        
  91.         // Save to external file
  92.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT EXPLODE", g_sound_grenade_infect_explode)
  93.     }
  94.     if (ArraySize(g_sound_grenade_infect_player) == 0)
  95.     {
  96.         for (index = 0; index < sizeof sound_grenade_infect_player; index++)
  97.             ArrayPushString(g_sound_grenade_infect_player, sound_grenade_infect_player[index])
  98.        
  99.         // Save to external file
  100.         amx_save_setting_string_arr(ZP_SETTINGS_FILE, "Sounds", "GRENADE INFECT PLAYER", g_sound_grenade_infect_player)
  101.     }
  102.    
  103.     // Load from external file, save if not found
  104.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_grenade_infect, charsmax(g_model_grenade_infect)))
  105.         amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_grenade_infect)
  106.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_pgrenade_infect, charsmax(g_model_pgrenade_infect)))
  107.         amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_grenade_infect)
  108.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_wgrenade_infect, charsmax(g_model_wgrenade_infect)))
  109.         amx_save_setting_string(ZP_SETTINGS_FILE, "Weapon Models", "GRENADE INFECT", g_model_wgrenade_infect)
  110.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail, charsmax(g_sprite_grenade_trail)))
  111.         amx_save_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "TRAIL", g_sprite_grenade_trail)
  112.     if (!amx_load_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "RING", g_sprite_grenade_ring, charsmax(g_sprite_grenade_ring)))
  113.         amx_save_setting_string(ZP_SETTINGS_FILE, "Grenade Sprites", "RING", g_sprite_grenade_ring)
  114.    
  115.     // Precache sounds
  116.     new sound[SOUND_MAX_LENGTH]
  117.     for (index = 0; index < ArraySize(g_sound_grenade_infect_explode); index++)
  118.     {
  119.         ArrayGetString(g_sound_grenade_infect_explode, index, sound, charsmax(sound))
  120.         precache_sound(sound)
  121.     }
  122.     for (index = 0; index < ArraySize(g_sound_grenade_infect_player); index++)
  123.     {
  124.         ArrayGetString(g_sound_grenade_infect_player, index, sound, charsmax(sound))
  125.         precache_sound(sound)
  126.     }
  127.    
  128.     // Precache models
  129.     precache_model(g_model_grenade_infect)
  130.     precache_model(g_model_pgrenade_infect)
  131.     precache_model(g_model_wgrenade_infect)
  132.     g_trailSpr = precache_model(g_sprite_grenade_trail)
  133.     g_exploSpr = precache_model(g_sprite_grenade_ring)
  134. }
  135.  
  136. public plugin_cfg()
  137. {
  138.     g_GameModeInfectionID = zp_gamemodes_get_id("Infection Mode")
  139.     g_GameModeMultiID = zp_gamemodes_get_id("Multiple Infection Mode")
  140. }
  141.  
  142. public event_round_start()
  143. {
  144.     g_InfectionBombCounter = 0
  145. }
  146.  
  147. public zp_fw_items_select_pre(id, itemid, ignorecost)
  148. {
  149.     // This is not our item
  150.     if (itemid != g_ItemID)
  151.         return ZP_ITEM_AVAILABLE;
  152.    
  153.     // Infection bomb only available during infection modes
  154.     new current_mode = zp_gamemodes_get_current()
  155.     if (current_mode != g_GameModeInfectionID && current_mode != g_GameModeMultiID)
  156.         return ZP_ITEM_DONT_SHOW;
  157.    
  158.     // Infection bomb only available to zombies
  159.     if (!zp_core_is_zombie(id))
  160.         return ZP_ITEM_DONT_SHOW;
  161.    
  162.     // Display remaining item count for this round
  163.     static text[32]
  164.     formatex(text, charsmax(text), "[%d/%d]", g_InfectionBombCounter, get_pcvar_num(cvar_infection_bomb_round_limit))
  165.     zp_items_menu_text_add(text)
  166.    
  167.     // Reached infection bomb limit for this round
  168.     if (g_InfectionBombCounter >= get_pcvar_num(cvar_infection_bomb_round_limit))
  169.         return ZP_ITEM_NOT_AVAILABLE;
  170.    
  171.     // Player already owns infection bomb
  172.     if (user_has_weapon(id, CSW_HEGRENADE))
  173.         return ZP_ITEM_NOT_AVAILABLE;
  174.    
  175.     return ZP_ITEM_AVAILABLE;
  176. }
  177.  
  178. public zp_fw_items_select_post(id, itemid, ignorecost)
  179. {
  180.     // This is not our item
  181.     if (itemid != g_ItemID)
  182.         return;
  183.    
  184.     // Give infection bomb
  185.     give_item(id, "weapon_hegrenade")
  186.     g_InfectionBombCounter++
  187. }
  188.  
  189. public zp_fw_core_cure(id, attacker)
  190. {
  191.     // Remove custom grenade model
  192.     cs_reset_player_view_model(id, CSW_HEGRENADE)
  193. }
  194.  
  195. public zp_fw_core_infect_post(id, attacker)
  196. {
  197.     // Set custom grenade model
  198.     cs_set_player_view_model(id, CSW_HEGRENADE, g_model_grenade_infect)
  199.     cs_set_player_view_model(id, CSW_HEGRENADE, g_model_pgrenade_infect)
  200. }
  201.  
  202. // Forward Set Model
  203. public fw_SetModel(entity, const model[])
  204. {
  205.     // We don't care
  206.     if (strlen(model) < 8)
  207.         return FMRES_IGNORED
  208.    
  209.     // Narrow down our matches a bit
  210.     if (model[7] != 'w' || model[8] != '_')
  211.         return FMRES_IGNORED
  212.    
  213.     // Get damage time of grenade
  214.     static Float:dmgtime
  215.     pev(entity, pev_dmgtime, dmgtime)
  216.    
  217.     // Grenade not yet thrown
  218.     if (dmgtime == 0.0)
  219.         return FMRES_IGNORED
  220.    
  221.     // Grenade's owner isn't zombie?
  222.     if (!zp_core_is_zombie(pev(entity, pev_owner)))
  223.         return FMRES_IGNORED
  224.    
  225.     // HE Grenade
  226.     if (model[9] == 'h' && model[10] == 'e')
  227.     {
  228.         // Give it a glow
  229.         fm_set_rendering(entity, kRenderFxGlowShell, 0, 200, 0, kRenderNormal, 16);
  230.        
  231.         // And a colored trail
  232.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  233.         write_byte(TE_BEAMFOLLOW) // TE id
  234.         write_short(entity) // entity
  235.         write_short(g_trailSpr) // sprite
  236.         write_byte(10) // life
  237.         write_byte(10) // width
  238.         write_byte(0) // r
  239.         write_byte(200) // g
  240.         write_byte(0) // b
  241.         write_byte(200) // brightness
  242.         message_end()
  243.        
  244.         // Set grenade type on the thrown grenade entity
  245.         set_pev(entity, PEV_NADE_TYPE, NADE_TYPE_INFECTION)
  246.         engfunc( EngFunc_SetModel, entity, g_model_wgrenade_infect)
  247.             return FMRES_SUPERCEDE
  248.     }
  249.         // W-he
  250.         return FMRES_IGNORED
  251. }
  252.  
  253. // Ham Grenade Think Forward
  254. public fw_ThinkGrenade(entity)
  255. {
  256.     // Invalid entity
  257.     if (!pev_valid(entity)) return HAM_IGNORED;
  258.    
  259.     // Get damage time of grenade
  260.     static Float:dmgtime
  261.     pev(entity, pev_dmgtime, dmgtime)
  262.    
  263.     // Check if it's time to go off
  264.     if (dmgtime > get_gametime())
  265.         return HAM_IGNORED;
  266.    
  267.     // Check if it's one of our custom nades
  268.     switch (pev(entity, PEV_NADE_TYPE))
  269.     {
  270.         case NADE_TYPE_INFECTION: // Infection Bomb
  271.         {
  272.             infection_explode(entity)
  273.             return HAM_SUPERCEDE;
  274.         }
  275.     }
  276.    
  277.     return HAM_IGNORED;
  278. }
  279.  
  280. // Infection Bomb Explosion
  281. infection_explode(ent)
  282. {
  283.     // Round ended
  284.     if (zp_gamemodes_get_current() == ZP_NO_GAME_MODE)
  285.     {
  286.         // Get rid of the grenade
  287.         engfunc(EngFunc_RemoveEntity, ent)
  288.         return;
  289.     }
  290.    
  291.     // Get origin
  292.     static Float:origin[3]
  293.     pev(ent, pev_origin, origin)
  294.    
  295.     // Make the explosion
  296.     create_blast(origin)
  297.    
  298.     // Infection nade explode sound
  299.     static sound[SOUND_MAX_LENGTH]
  300.     ArrayGetString(g_sound_grenade_infect_explode, random_num(0, ArraySize(g_sound_grenade_infect_explode) - 1), sound, charsmax(sound))
  301.     emit_sound(ent, CHAN_WEAPON, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  302.    
  303.     // Get attacker
  304.     new attacker = pev(ent, pev_owner)
  305.    
  306.     // Infection bomb owner disconnected or not zombie anymore?
  307.     if (!is_user_connected(attacker) || !zp_core_is_zombie(attacker))
  308.     {
  309.         // Get rid of the grenade
  310.         engfunc(EngFunc_RemoveEntity, ent)
  311.         return;
  312.     }
  313.    
  314.     // Collisions
  315.     new victim = -1
  316.    
  317.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, origin, NADE_EXPLOSION_RADIUS)) != 0)
  318.     {
  319.         // Only effect alive humans
  320.         if (!is_user_alive(victim) || zp_core_is_zombie(victim))
  321.             continue;
  322.        
  323.         // Last human is killed
  324.         if (zp_core_get_human_count() == 1)
  325.         {
  326.             //ExecuteHamB(Ham_Killed, victim, attacker, 0)
  327.             continue;
  328.         }
  329.        
  330.         // Turn into zombie
  331.         zp_core_infect(victim, attacker)
  332.        
  333.         // Victim's sound
  334.         ArrayGetString(g_sound_grenade_infect_player, random_num(0, ArraySize(g_sound_grenade_infect_player) - 1), sound, charsmax(sound))
  335.         emit_sound(victim, CHAN_VOICE, sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  336.     }
  337.    
  338.     // Get rid of the grenade
  339.     engfunc(EngFunc_RemoveEntity, ent)
  340. }
  341.  
  342. // Infection Bomb: Green Blast
  343. create_blast(const Float:origin[3])
  344. {
  345.     // Smallest ring
  346.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  347.     write_byte(TE_BEAMCYLINDER) // TE id
  348.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  349.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  350.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  351.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  352.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  353.     engfunc(EngFunc_WriteCoord, origin[2]+385.0) // z axis
  354.     write_short(g_exploSpr) // sprite
  355.     write_byte(0) // startframe
  356.     write_byte(0) // framerate
  357.     write_byte(4) // life
  358.     write_byte(60) // width
  359.     write_byte(0) // noise
  360.     write_byte(0) // red
  361.     write_byte(200) // green
  362.     write_byte(0) // blue
  363.     write_byte(200) // brightness
  364.     write_byte(0) // speed
  365.     message_end()
  366.    
  367.     // Medium ring
  368.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  369.     write_byte(TE_BEAMCYLINDER) // TE id
  370.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  371.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  372.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  373.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  374.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  375.     engfunc(EngFunc_WriteCoord, origin[2]+470.0) // z axis
  376.     write_short(g_exploSpr) // sprite
  377.     write_byte(0) // startframe
  378.     write_byte(0) // framerate
  379.     write_byte(4) // life
  380.     write_byte(60) // width
  381.     write_byte(0) // noise
  382.     write_byte(0) // red
  383.     write_byte(200) // green
  384.     write_byte(0) // blue
  385.     write_byte(200) // brightness
  386.     write_byte(0) // speed
  387.     message_end()
  388.    
  389.     // Largest ring
  390.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, origin, 0)
  391.     write_byte(TE_BEAMCYLINDER) // TE id
  392.     engfunc(EngFunc_WriteCoord, origin[0]) // x
  393.     engfunc(EngFunc_WriteCoord, origin[1]) // y
  394.     engfunc(EngFunc_WriteCoord, origin[2]) // z
  395.     engfunc(EngFunc_WriteCoord, origin[0]) // x axis
  396.     engfunc(EngFunc_WriteCoord, origin[1]) // y axis
  397.     engfunc(EngFunc_WriteCoord, origin[2]+555.0) // z axis
  398.     write_short(g_exploSpr) // sprite
  399.     write_byte(0) // startframe
  400.     write_byte(0) // framerate
  401.     write_byte(4) // life
  402.     write_byte(60) // width
  403.     write_byte(0) // noise
  404.     write_byte(0) // red
  405.     write_byte(200) // green
  406.     write_byte(0) // blue
  407.     write_byte(200) // brightness
  408.     write_byte(0) // speed
  409.     message_end()
  410. }
  411.  
  412. // Set entity's rendering type (from fakemeta_util)
  413. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  414. {
  415.     static Float:color[3]
  416.     color[0] = float(r)
  417.     color[1] = float(g)
  418.     color[2] = float(b)
  419.    
  420.     set_pev(entity, pev_renderfx, fx)
  421.     set_pev(entity, pev_rendercolor, color)
  422.     set_pev(entity, pev_rendermode, render)
  423.     set_pev(entity, pev_renderamt, float(amount))
  424. }


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: .SMA fordítási hibák orvoslása
HozzászólásElküldve: 2018.04.04. 19:58 
Offline
Újonc

Csatlakozott: 2018.04.01. 22:03
Hozzászólások: 6
Megköszönték neki: 1 alkalommal
Köszönöm szépen a segítséget! :)


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 3 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 114 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole