Hello guys! I have 2 questions (I know about 1 question per topic)
1) If i holding a knife, then typing "changeknife 1" in console, viewmodel isn't changing immediately. I need to change to any other weapon and then change back to knife. Is there any way to fix this?
2) Which weapon models can be changed via "
entity_set_string(id, EV_SZ_viewmodel, modelname)"?
Here is the script i using:
PHP Code:
#include < amxmodx >
#include < engine >
new const models[][] = {
"models/v_knife.mdl",
"models/p_knife.mdl",
"models/v_knife_r.mdl"
}
enum _:udata {
knife
}
new UserData[33][udata]
public plugin_precache()
{
for(new i; i < sizeof(models); i++)
precache_model(models[i])
}
public plugin_init() {
register_plugin ("knife changer", "test", "kww (yes)")
register_event ("CurWeapon", "event_curweapon", "be", "1=1")
register_clcmd ("changeknife", "xknife_handler")
}
public client_putinserver ( id ) {
UserData[id][knife] = 0
}
public xknife_handler(id) {
new x_arg[16]
read_argv(1, x_arg, charsmax(x_arg))
switch(x_arg[0]) {
case EOS: client_print(id, print_console, "* Usage: changeknife <1|0> (now %i)", UserData[id][knife])
case '0': UserData[id][knife] = 0
case '1': UserData[id][knife] = 1
}
client_print(id, print_console, "%i", )
return PLUGIN_HANDLED
}
public event_curweapon(id) {
new wpn = read_data(2)
if (wpn == CSW_KNIFE) {
switch (UserData[id][knife]) {
case 0:
{
entity_set_string(id, EV_SZ_viewmodel, models[0])
entity_set_string(id, EV_SZ_weaponmodel, models[1])
}
case 1:
{
entity_set_string(id, EV_SZ_viewmodel, models[2])
}
}
}
return PLUGIN_CONTINUE
}