AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   question about ids and stuff ... (https://forums.alliedmods.net/showthread.php?t=46055)

shino 10-17-2006 15:54

question about ids and stuff ...
 
this is code ...
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("say .ready","check_ready")     register_srvcmd("check_whoisready","check_whoisready") } public check_ready(id) {     UserReady[id] = 1 } public check_whoisready() {     new Name[128]     for(new i=0;i<=get_playersnum();i++) {         if(UserReady[i] == 1) {             get_user_name(i,Name,127)             client_print(0,print_chat,"%s is ready!",Name)         }     } }

as you see, player could say .ready and he would be assigned into UserReady with his id. when someone types into server console check_whoisready, that loop will throw out anyone who has that id and is assigned into UserReady.

i would like to know, if my code would work or the use of UserReady[id] is wrong, ec i mustn't use this loop to get players' ids.

plz reply if you know the solution, ty :*

XxAvalanchexX 10-17-2006 16:02

Re: question about ids and stuff ...
 
You should declare the UserReady array somewhere. I would change your gets_playersnum to get_maxplayers. The reason for this is that a player can have a higher id than the current amount of players in the server (ie: he is one of only two players in the server but his id is 11), whereas it can't go higher than the max players. You should also set i to 1 instead of 0 then, because there is no player 0.

shino 10-18-2006 08:05

Re: question about ids and stuff ...
 
thank you :) but please explain:
"You should declare the UserReady array somewhere."

where should i declare it?

XxAvalanchexX 10-18-2006 16:58

Re: question about ids and stuff ...
 
Outside any function, so that it is global (all functions have access to it). Most people declare all of their global variables at the top of the script. ie:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" new userReady[33]; public plugin_init() {


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

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