Raised This Month: $ Target: $400
 0% 

message_begin seem do not work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
larnk
Member
Join Date: Dec 2004
Old 02-16-2005 , 22:40   message_begin seem do not work
Reply With Quote #1

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....
larnk is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-16-2005 , 23:28  
Reply With Quote #2

Just use client_cmd instead of engclient_cmd.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
larnk
Member
Join Date: Dec 2004
Old 02-18-2005 , 05:27  
Reply With Quote #3

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..
larnk is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-18-2005 , 15:25  
Reply With Quote #4

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.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
larnk
Member
Join Date: Dec 2004
Old 02-19-2005 , 08:32  
Reply With Quote #5

It's not only an animation, but a bullit is fired really...
larnk is offline
karlos
Veteran Member
Join Date: Apr 2004
Location: Germany/Poland
Old 02-19-2005 , 11:56  
Reply With Quote #6

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)
__________________
alias White Panther
karlos is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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