What do you think about this?
For Zombies:
It's very simple.
---------------------------------------------------------------------------------------------------
1-) You need to have your sprites, put it like this:
Code: Select all
new const WeaponList_Sprite[][] = { "sprites/knife_zombie.txt", "sprites/knife_zombie.spr" }
---------------------------------------------------------------------------------------------------USE YOURS!!!!
2-) Precache them:
Code: Select all
public plugin_precache()
{
for(new i = 0; i < sizeof WeaponList_Sprite; i++)
precache_generic(WeaponList_Sprite[i])
register_clcmd("knife_zombie", "hook") // You need to add this in precache, what's this? It calls the sprite(hud) when you need it (by your mouse)
}
3-)Add hook Function else you'll get errors:
Code: Select all
public hook(id)
{
if(!is_user_alive(id))
return PLUGIN_CONTINUE
engclient_cmd(id, "weapon_knife")
return PLUGIN_HANDLED
}
4-) You need to activate the sprite once ZM is infected:
Code: Select all
public ze_user_infected(iVictim, iInfector)
{
WeaponList(iVictim, 1)
}
Don't forget to disable it for humans:
Code: Select all
public ze_user_humanized(id)
{
WeaponList(id, 0)
}
5-) Activate your sprite by this stock:
Code: Select all
WeaponList(index, mode = 0)
{
if (!is_user_alive(index))
return
message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, index)
write_string(mode ? "knife_zombie" : "weapon_knife")
write_byte(-1)
write_byte(-1)
write_byte(-1)
write_byte(-1)
write_byte(2)
write_byte(1)
write_byte(29)
write_byte(0)
message_end()
}
Finally! Compile, add onto your server, change map/restart/start & HAVE FUN!
You can use this stock for anther guns (CSW_*) but you'll need to change this to the correct gun's information:
Code: Select all
write_string(mode ? "knife_zombie" : "weapon_knife")
write_byte(-1)
write_byte(-1)
write_byte(-1)
write_byte(-1)
write_byte(2)
write_byte(1)
write_byte(29)
write_byte(0)
---------------------------------------------------------------------------------------------------
Final code:
- #include <zombie_escape>
- new const WeaponList_Sprite[][] = { "sprites/knife_zombie.txt", "sprites/knife_zombie.spr" }
- public plugin_precache()
- {
- for(new i = 0; i < sizeof WeaponList_Sprite; i++)
- precache_generic(WeaponList_Sprite[i])
- register_clcmd("knife_zombie", "hook")
- }
- public hook(id)
- {
- if(!is_user_alive(id))
- return PLUGIN_CONTINUE
- engclient_cmd(id, "weapon_knife")
- return PLUGIN_HANDLED
- }
- public plugin_init()
- {
- register_plugin("[ZE] Addons: Knife Hud", "1.0", "JaCk")
- }
- public ze_user_infected(iVictim, iInfector)
- {
- WeaponList(iVictim, 1)
- }
- public ze_user_humanized(id)
- {
- WeaponList(id, 0)
- }
- WeaponList(index, mode = 0)
- {
- if (!is_user_alive(index))
- return
- message_begin(MSG_ONE, get_user_msgid("WeaponList"), {0, 0, 0}, index)
- write_string(mode ? "knife_zombie" : "weapon_knife")
- write_byte(-1)
- write_byte(-1)
- write_byte(-1)
- write_byte(-1)
- write_byte(2)
- write_byte(1)
- write_byte(29)
- write_byte(0)
- message_end()
- }
In the text file, you should have something like this:
Code: Select all
2 // This is sprites number
weapon 640 knife_zombie 0 180 170 45
weapon_s 640 knife_zombie 0 180 170 45
Code: Select all
numberOfSprites
<type> <resolution> <spriteFile> <shiftX> <shiftY> <width> <height>
---------------------------------------------------------------------------------------------------
Have a nice day!