Quote:
|
Originally Posted by v3x
Umm, why won't this work?
Code:
// ..
new arg[32]
new players[32]
new player,num,i
read_argv(1,arg,31)
if(equali(arg[0],"@")) {
get_players(players,num,"bce",arg[1])
if(!num) {
console_print(id,"[AMXX] No players on such team!")
return PLUGIN_HANDLED
}
for(i=0;i<num;i++) {
player = players[i]
// Do something with player =)
}
}
// ..
|
The way that works is by manually supplying the Full Team Name, which is: @CT & @TERRORIST to the command in console..
but in the console, I find that a bit tedious to say the least, and it is much nicer when you can just type @CT & @T
And let your code add the Full Name for Terrorist itself..
My suggestion:
Code:
new iPlayers[32], iNum, player
new szArg[32]
read_argv( 1, szArg, 31 )
if( szArg[0] == '@' ) // Group of Players..
{
if( equali(szArg[1], "T") || equali(szArg[1], "TERRORIST") )
get_players( iPlayers, iNum, "e", "TERRORIST" )
else if( equali(szArg[1], "C") || equali(szArg[1], "CT") )
get_players( iPlayers, iNum, "e", "CT" )
else if( equali(szArg[1], "A") || equali(szArg[1], "ALL") )
get_players( iPlayers, iNum)
if(!iNum) {
console_print(id,"[AMXX] No players on such team!")
return PLUGIN_HANDLED
}
for( i=0; i<iNum; i++ )
{
player = iPlayers[i]
// Do something with player =)
}
}else if( szArg[0] == '*' ) // ALL Again, but with wildcard *
{
get_players( iPlayers, iNum)
if(!iNum) {
console_print(id,"[AMXX] No players found!")
return PLUGIN_HANDLED
}
for( i=0; i<iNum; i++ )
{
player = iPlayers[i]
// Do something with player =)
}
}else // Individual player
{
player = cmd_target( id, szArg[0], 1 + 2 + 4 + 8 ) // Remove bits you dont need..
if( !player ) return PLUGIN_HANDLED
// Do something with player =)
}
Feel free to use such a method in your plugins!! Makes it easier in console, you could type (for example):
amx_command @A
amx_command *
amx_command @T
amx_command @CT
amx_command xeroblood
amx_command #1
Stuff like that.. I hope that helps!