Raised This Month: $ Target: $400
 0% 

How to get command arguments?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lukass
Junior Member
Join Date: Dec 2008
Old 05-04-2010 , 07:01   How to get command arguments?
Reply With Quote #1

Hello good people,

I have "say /add" command, after it i need to put space and any number, like "say /add 80". I need to get that number in my function. How can i do that?
Lukass is offline
AoD90
Senior Member
Join Date: Jul 2008
Location: Ugljevik/RS/BIH
Old 05-04-2010 , 07:29   Re: How to get command arguments?
Reply With Quote #2

PHP Code:
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say""cmdSay")
}

public 
cmdSay(id)
{
    new 
text[200]
    
read_args(text,199)
    
remove_quotes(text)

    if(
containi(text,"/add")==0)
         
strtok(texttext199YourNumberWillBeHere255' ')
    return 
PLUGIN_CONTINUE

AoD90 is offline
Send a message via MSN to AoD90
Lukass
Junior Member
Join Date: Dec 2008
Old 05-04-2010 , 08:52   Re: How to get command arguments?
Reply With Quote #3

Thank You.

I don't want to start new topic, so i have one more question here. You know, when we need to save some temporary data about players, most of us probably use something like this:


Code:
new Players[33];


public client_connect(id) {

if(...) Players[id] = 1;

}

But i can't get, what i should do, if i want to assign longer values to array like one above. I mean, i want to save numbers like 4 digits or longer. But this one saves only first digit.
Lukass is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-04-2010 , 18:22   Re: How to get command arguments?
Reply With Quote #4

It doesn't save only one digit. You can use many digits. The Players array is an array of integer values. So, each of the 33 slots can hold an integer which can be many digits.

PHP Code:
Players[id] = 5784523 
__________________
fysiks 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 03:38.


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