AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   message_begin seem do not work (https://forums.alliedmods.net/showthread.php?t=10359)

larnk 02-16-2005 22:40

message_begin seem do not work
 
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....

XxAvalanchexX 02-16-2005 23:28

Just use client_cmd instead of engclient_cmd.

larnk 02-18-2005 05:27

thank you,XxAvalanchexX, I have tried the function client_cmd(), it will send the CurWeapon message. but there is a little problem, if I press 1 and press fire(mouse left button) fast enough, one bullit will be fired...
and this is the reason why I use engclient_cmd..

XxAvalanchexX 02-18-2005 15:25

That would mean that there is enough time to play the gun cocking animation, which takes at least half a second. Are you 100% sure? Try removing the first parameter check in register_event.

larnk 02-19-2005 08:32

It's not only an animation, but a bullit is fired really...

karlos 02-19-2005 11:56

maybe this is due to that register_event is called when the action happened
try hooking the message itself
register_message(get_user_msgid("CurWeapon"), "your_func_name")
and replace read_date with get_msg_art_* (int / str or float , depends on what type it is, here it is int)


All times are GMT -4. The time now is 19:19.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.