AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   @TEAM (https://forums.alliedmods.net/showthread.php?t=13111)

v3x 05-04-2005 19:41

@TEAM
 
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 =)     } } // ..

v3x 05-04-2005 22:41

Bah, I got it..

Code:
if(arg[0]=='@') {

But I really wanted to use equali. :(

n0obie4life 05-05-2005 03:10

Quote:

Originally Posted by v3x
Bah, I got it..

Code:
if(arg[0]=='@') {

But I really wanted to use equali. :(

cool, you got it in 3 hours?

xeroblood 05-05-2005 12:14

Re: @TEAM
 
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!

v3x 05-05-2005 15:33

@noobie:
Do you really think I was working on that for 3 hours? I was doing other stuff, then I eventually came back to it.

@xero:
Thanks, I'll learn from that. :D

v3x 05-05-2005 21:01

Hmm.. This is probably the most noobish of questions I've ever asked.. :oops:

Can you explain how array sizes work?

Like, how can szArg[1] hold "TERRORIST"?

:P

xeroblood 05-05-2005 21:06

Yeah, it is kinda weird in Small C..

If the string is: @TERRORIST

Then:

[0] == '@'
[0] == "@TERRORIST"
[1] == 'T'
[1] == "TERRORIST"
[2] == 'E'
[2] == "ERRORIST"

etc..

Notice the different use of quotes? With single-quotes, a single character is implied, with double-quotes a string is implied..

However, the string functions expect strings, so always use double-quotes when passing arguments to them..

When used as a string, the index simple denotes the starting point of the string...

I hope that makes sense for ya!

v3x 05-05-2005 21:13

So for when we get the player's name.. [32], that is applying it to each single charactor like in single quotes?

n0obie4life 05-06-2005 04:07

Quote:

Originally Posted by v3x
@noobie:
Do you really think I was working on that for 3 hours? I was doing other stuff, then I eventually came back to it.

yep.


All times are GMT -4. The time now is 16:36.

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