I want to force a player using knife and wrote such code
Code:
public plugin_init(){
register_plugin("Only Knife","0.1","Zhao")
register_event("CurWeapon","weapon_trigger","b","1=1")
}
public weapon_trigger(id){
new wpnindex=read_data(2)
client_print(id,print_chat,"Receive Weapon %d",wpnindex)//Only For Debug
if(wpnindex!=CSW_KNIFE){
engclient_cmd(id,"weapon_knife") //This function do not send a CurWeapon message of knife
new ids[1]
ids[0]=id
set_task(1.0,"fake_weapon_msg",0,ids,1) //I want to send a knife weapon msg
}
public fake_weapon_msg(ids[]){
new id=ids[0]
client_print(id,print_chat,"Weapon Knife Msg is sent to %d",id)//For Debug
message_begin(MSG_ONE,get_user_msgid("CurWeapon"),{0,0,0},id)
write_byte(1)
write_byte(CSW_KNIFE)
write_byte(-1)
message_end()
return PLUGIN_HANDLED
}
I got "Weapon Knife msg is sent to 1" in chat message,but Can not recive the knife message ...
How to resolve this problem? Thanks....