Raised This Month: $ Target: $400
 0% 

[resolved] read_data, write_string(), etc.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
stupok
Veteran Member
Join Date: Feb 2006
Old 10-15-2006 , 15:05   [resolved] read_data, write_string(), etc.
Reply With Quote #1

I want to check if the player is on the team zombiemodel, and if so, switch the player to team humanmodel. TeamInfo is the event, in The Specialists, that gets called when a client switches teams.

I am trying to send the message TeamInfo to the client so that the client's team is switched back to the team humanmodel. The client_print message is sent, so I'm assuming I set everything up correctly, besides the sending of the message.

I know there are a bunch of threads on this, and I've looked at many of them, but I just couldn't find an answer for this. The documentation didn't help either.

Here's two versions attempting to achieve the same result:

This version does nothing as far as I can tell:
Code:
register_event("TeamInfo", "zombie_teams", "b") public zombies_teams(id) {     new arg1 = read_data(1)     new teamname[32]     read_data(2, teamname, 31)         //get_user_info(id, "model", teamname, 31)         if(!is_user_bot(id) && equali(teamname, zombiemodel))     {         message_begin(MSG_ONE, get_user_msgid("TeamInfo"), {0,0,0}, id)         write_byte(arg1)         write_string(humanmodel)         message_end()         client_print(id, print_chat, "You are a human!")     }     return PLUGIN_CONTINUE }

This version at least sends the print_chat message "You are a human!":
Code:
public client_infochanged(id) {     new teamname[32]         get_user_info(id, "model", teamname, 31)         if(!is_user_bot(id) && equali(teamname, zombiemodel))     {         message_begin(MSG_ONE, get_user_msgid("TeamInfo"), {0,0,0}, id)         write_byte(arg1)         write_string(humanmodel)         message_end()         client_print(id, print_chat, "You are a human!")     }     return PLUGIN_CONTINUE }

Last edited by stupok; 10-15-2006 at 17:26.
stupok is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-15-2006 , 15:14   Re: read_data, write_string(), etc.
Reply With Quote #2

TeamInfo is probably a global message, so register it with the a flag instead of b.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 10-15-2006 , 15:40   Re: read_data, write_string(), etc.
Reply With Quote #3

You're right, according to the message logger by Damaged Soul its destination is ALL.

Forgot about that. I'm checking the first code with flag a instead of b right now...

EDIT: Changing to flag a instead of b did nothing.

Last edited by stupok; 10-15-2006 at 15:43.
stupok is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 10-15-2006 , 15:55   Re: read_data, write_string(), etc.
Reply With Quote #4

try to set the user team with set_user_info
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
stupok
Veteran Member
Join Date: Feb 2006
Old 10-15-2006 , 16:05   Re: read_data, write_string(), etc.
Reply With Quote #5

Thank you Greenberet.

Working code:
Code:
public client_infochanged(id) {     new teamname[32]     get_user_info(id, "model", teamname, 31)         if(!is_user_bot(id) && equali(teamname, zombiemodel))     {         set_user_info(id, "model", humanmodel)         client_print(id, print_chat, "You are a human!")     }     return PLUGIN_CONTINUE }
stupok is offline
Reply



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 04:53.


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