AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to get command arguments? (https://forums.alliedmods.net/showthread.php?t=125972)

Lukass 05-04-2010 07:01

How to get command arguments?
 
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?

AoD90 05-04-2010 07:29

Re: How to get command arguments?
 
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



Lukass 05-04-2010 08:52

Re: How to get command arguments?
 
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.

fysiks 05-04-2010 18:22

Re: How to get command arguments?
 
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 



All times are GMT -4. The time now is 03:38.

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