Raised This Month: $12 Target: $400
 3% 

question about ids and stuff ...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shino
Senior Member
Join Date: May 2006
Old 10-17-2006 , 15:54   question about ids and stuff ...
Reply With Quote #1

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 :*
__________________


+karma if i am helpful
shino is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-17-2006 , 16:02   Re: question about ids and stuff ...
Reply With Quote #2

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.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
shino
Senior Member
Join Date: May 2006
Old 10-18-2006 , 08:05   Re: question about ids and stuff ...
Reply With Quote #3

thank you but please explain:
"You should declare the UserReady array somewhere."

where should i declare it?
__________________


+karma if i am helpful
shino is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-18-2006 , 16:58   Re: question about ids and stuff ...
Reply With Quote #4

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() {
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX 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 02:59.


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