AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [resolved] read_data, write_string(), etc. (https://forums.alliedmods.net/showthread.php?t=45970)

stupok 10-15-2006 15:05

[resolved] read_data, write_string(), etc.
 
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 }

XxAvalanchexX 10-15-2006 15:14

Re: read_data, write_string(), etc.
 
TeamInfo is probably a global message, so register it with the a flag instead of b.

stupok 10-15-2006 15:40

Re: read_data, write_string(), etc.
 
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.

Greenberet 10-15-2006 15:55

Re: read_data, write_string(), etc.
 
try to set the user team with set_user_info

stupok 10-15-2006 16:05

Re: read_data, write_string(), etc.
 
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 }


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

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