AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problems with a selection detection (https://forums.alliedmods.net/showthread.php?t=2752)

FlyingMongoose 06-15-2004 20:15

Problems with a selection detection
 
Code:
#include <amxmodx> public client_putinserver(id) {     new team[32]     get_user_team(id,team,31)     if(get_user_flags(id)&ADMIN_IMMUNITY)     {         return PLUGIN_CONTINUE     }     if(team[0]!='U')     {         client_cmd(id,"menuselect 10")         return PLUGIN_CONTINUE     }else{         client_cmd(id,"menuselect 5")         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE  } public check_time(id) {     new plist[32],pnum     get_players(plist, pnum ,"a")     for(new i=0; i<pnum; i++)     {         if(get_user_flags(plist[i]&ADMIN_IMMUNITY))         {             return PLUGIN_CONTINUE         }         if(is_user_alive(plist[i])!=1)         {             server_cmd("kick #%d ^"You failed to select a skin in time^"",plist[i])         }         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE } public plugin_init(){     register_plugin("Automatic Team Assign","0.2.2","[SMS]FlyingMongoose")     register_event("ShowMenu","client_putinserver","b","4&Team_Select")     register_event("VGUIMenu","client_putinserver","b","1=2","1=26","1=27")     register_logevent("check_time",2,"0=World triggered","1=Round_Start")     return PLUGIN_CONTINUE }
the problem is that it enters check_time, it just doesn't do anything

BAILOPAN 06-15-2004 23:05

1] How do you know it enters check_time?

2] for(new i=0; i<pnum; i++)
please do:
new i
for(i=0; i<pnum; i++)

3] Why are you binding these calls to client_putinserver, which is called separately also? my reveal trickiness...

FlyingMongoose 06-16-2004 00:30

I know it enters check_time because

Code:
for(new i=0; i<pnum; i++)     {         if(get_user_flags(plist[i]&ADMIN_IMMUNITY))         {             return PLUGIN_CONTINUE         }         if(is_user_alive(plist[i])!=1)         {             server_cmd("kick #%d ^"You failed to select a skin in time^"",plist[i])         }         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE

use to have

Code:
for(new i=0; i<pnum; i++)     {         console_print(i,"Num: %s",pnum)         if(get_user_flags(plist[i]&ADMIN_IMMUNITY))         {             return PLUGIN_CONTINUE         }         if(is_user_alive(plist[i])!=1)         {             server_cmd("kick #%d ^"You failed to select a skin in time^"",plist[i])         }         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE

and it did output something, htough it wasn't a number :-/

BAILOPAN 06-16-2004 02:21

it wasn't a number because you did "%s" instead of "%d"

FlyingMongoose 06-16-2004 03:01

okay that explains that...but...why won't this work? I'm so confused

to me this code should work

FlyingMongoose 06-16-2004 05:37

alright, now that I realized my error, I think I may be able to fix this
I was trying to detect alive players, when I wanted to detect dead players >.< thank you bail for helping me to realize that

Code:
#include <amxmod> public client_putinserver(id) {     new team[32]     get_user_team(id,team,31)     if(get_user_flags(id)&ADMIN_IMMUNITY)     {         return PLUGIN_CONTINUE     }     if(team[0]!='U')     {         client_cmd(id,"menuselect 10")         return PLUGIN_CONTINUE     }else{         client_cmd(id,"menuselect 5")         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE  } public check_time(id) {     new plist[32],pnum     get_players(plist,pnum,"b")     for(new i=0; i<pnum; i++)     {         if(is_user_alive(get_user_userid(plist[i]))!=1)         {             if(get_user_flags(plist[i])&ADMIN_IMMUNITY)             {                 return PLUGIN_CONTINUE             }else{                 server_cmd("kick #%d ^"You failed to select a skin in time^"",plist[i])             }         }                 return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE } public plugin_init(){     register_plugin("Automatic Team Assign","0.2.2","[SMS]FlyingMongoose")     register_event("ShowMenu","client_putinserver","b","4&Team_Select")     register_event("VGUIMenu","client_putinserver","b","1=2","1=26","1=27")     register_logevent("check_time",2,"0=World triggered","1=Round_Start")     return PLUGIN_CONTINUE }

this all works the way I intended it to. BAIL...you remind my of my programming teacher...you give a LITTLE hint on how to fix a problem then make me go and do it myself...and I did, thank you ;)

FlyingMongoose 06-16-2004 16:17

alright, after multiple people telling me doing everything I did in client_putinserver was a bad idea I decided I'd break hte plugin up a bit

Code:
#include <amxmodx> public client_putinserver(id) {     set_task(1.0,"assign_teams")     return PLUGIN_CONTINUE  } public assign_teams(id){     new plist[32],pnum,team[32]     new i     get_players(plist,pnum)         for(i=0; i<pnum; i++)     {         get_user_team(plist[i],team,31)         if(team[0]=='U')         {             if(get_user_flags(plist[i])&ADMIN_IMMUNITY)             {                 return PLUGIN_CONTINUE             }             server_print("Team: %s",team)             client_cmd(get_user_userid(plist[i]),"menuselect 5")             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE } public block_teams(id){     new team[32]     get_user_team(id,team,31)     if(get_user_flags(id)&ADMIN_IMMUNITY)     {         return PLUGIN_CONTINUE     }     if(team[0]!='U')     {         client_cmd(id,"menuselect 10")         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE } public check_time(id) {     new plist[32],pnum     get_players(plist,pnum,"b")     for(new i=0; i<pnum; i++)     {         if(is_user_alive(get_user_userid(plist[i]))!=1)         {             if(get_user_flags(plist[i])&ADMIN_IMMUNITY)             {                 return PLUGIN_CONTINUE             }else{                 server_cmd("kick #%d ^"You failed to select a skin in time^"",plist[i])             }         }                 return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE } public plugin_init(){     register_plugin("Automatic Team Assign","0.2.2","[SMS]FlyingMongoose")     register_event("ShowMenu","block_teams","b","4&Team_Select")     register_event("VGUIMenu","block_teams","b","1=2","1=26","1=27")     register_logevent("check_time",2,"0=World triggered","1=Round_Start")     return PLUGIN_CONTINUE }

Please tell me if that looks better someone

[FBX] 06-17-2004 01:14

the code looks fine but the concept looks flawed, from what I can tell, you kick a guy if the round starts and he hasn't picked a skin... but what if he joins right when it says "terrorists win!" or something... then he has less than half a second to pick or gets kicked. On one hand, you could kick him if he still hasn't picked for a whole consecutive round, and that wouldnt be hard to implement using your current code.

FlyingMongoose 06-17-2004 05:20

it actually gives him until the round starts, the world triggered Round_Start doesn't occur until freeze time is up.

FlyingMongoose 10-04-2005 13:02

Dusting off some old code and seeing if I can get this working again :)

But I need a server willing to test :(

Code:
 #include <amxmodx> public client_putinserver(id) {     set_task(1.0,"assign_teams")     return PLUGIN_CONTINUE } public assign_teams(id){     new plist[32],pnum,team[32]     new i     get_players(plist,pnum)         for(i=0; i<pnum; i++)     {         get_user_team(plist[i],team,31)         if(team[0]=='U')         {             if(get_user_flags(plist[i])&ADMIN_IMMUNITY)             {                 return PLUGIN_CONTINUE             }             server_print("Team: %s",team)             client_cmd(get_user_userid(plist[i]),"menuselect 5")             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE } public block_teams(id){     new team[32]     get_user_team(id,team,31)     if(get_user_flags(id)&ADMIN_IMMUNITY)     {         return PLUGIN_CONTINUE     }     if(team[0]!='U')     {         client_cmd(id,"menuselect 10")         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE } public check_time(id) {     new plist[32],pnum     get_players(plist,pnum,"b")     new i     for(i=0; i<pnum; i++)     {         if(is_user_alive(get_user_userid(plist[i]))!=1)         {             if(get_user_flags(plist[i])&ADMIN_IMMUNITY)             {                 return PLUGIN_CONTINUE             }else{                 server_cmd("kick #%d ^"You failed to select a skin in time^"",plist[i])             }         }         return PLUGIN_CONTINUE     }     return PLUGIN_CONTINUE } public plugin_init(){     register_plugin("Automatic Team Assign","0.2.2","FlyingMongoose")     register_event("ShowMenu","block_teams","b","4&Team_Select")     register_event("VGUIMenu","block_teams","b","1=2","1=26","1=27")     register_logevent("check_time",2,"0=World triggered","1=Round_Start")     return PLUGIN_CONTINUE }

I've made a TINY change (I fixed format of one of my loops) lol. Anyone have any more suggestions?

I'm also thinking of basing this around the round time instead of round start, how can I recieve that variable to give that player that much time to select a skin?

Yay for necro-posting :lol:


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

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