Raised This Month: $ Target: $400
 0% 

@TEAM


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-04-2005 , 19:41   @TEAM
Reply With Quote #1

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 =)     } } // ..
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-04-2005 , 22:41  
Reply With Quote #2

Bah, I got it..

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

But I really wanted to use equali.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
n0obie4life
Veteran Member
Join Date: Dec 2004
Old 05-05-2005 , 03:10  
Reply With Quote #3

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?
__________________
Plugins:
none

n0obie4life is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 05-05-2005 , 12:14   Re: @TEAM
Reply With Quote #4

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!
xeroblood is offline
Send a message via MSN to xeroblood
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-05-2005 , 15:33  
Reply With Quote #5

@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.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-05-2005 , 21:01  
Reply With Quote #6

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

Can you explain how array sizes work?

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

__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 05-05-2005 , 21:06  
Reply With Quote #7

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!
xeroblood is offline
Send a message via MSN to xeroblood
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 05-05-2005 , 21:13  
Reply With Quote #8

So for when we get the player's name.. [32], that is applying it to each single charactor like in single quotes?
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
n0obie4life
Veteran Member
Join Date: Dec 2004
Old 05-06-2005 , 04:07  
Reply With Quote #9

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.
__________________
Plugins:
none

n0obie4life is offline
Reply


Thread Tools
Display Modes

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 16:36.


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