AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register_clcmd with parameter UID (https://forums.alliedmods.net/showthread.php?t=298974)

gameplayonline 06-28-2017 08:59

register_clcmd with parameter UID
 
Hello,
Is any solution how to do this?
I have declared variable uid and i need register_clcmd with value of this variable. If somebody say /referral 123 and variable will be set to this number do anything...

PurposeLessx 06-28-2017 09:05

Re: register_clcmd with parameter UID
 
You can use it in this way.

PHP Code:

#include <amxmodx>
#include <amxmisc>

public plugin_init() {
    
register_plugin("Say""1.0""PurposeLess")

    
register_clcmd("say""clcmd_say")
    
register_clcmd("say_team""clcmd_say")
}

public 
clcmd_say(id)
{
    new 
arg[32]
    
read_args(argsizeof(arg) - 1)
    
remove_quotes(arg)

    if(
equali(arg"/referral 123"))
    {
    }



gameplayonline 06-28-2017 09:18

Re: register_clcmd with parameter UID
 
When i change
Code:

if(equali(arg, "/referral 123"))
    {
    }

to

Code:

if(equali(arg, "/referral %d", uid))
    {
    }

it will work?

fysiks 06-28-2017 09:37

Re: register_clcmd with parameter UID
 
Did you try it? If you are wanting to get the 123 into a variable, you need to check that it contains "/referral" first and then parse the string to get the argument after it and convert it to a number.

Natsheh 06-28-2017 09:55

Re: register_clcmd with parameter UID
 
You can use strtok native to divide the string..

Get the left string which it will be the command
And the right is the numbers..

gameplayonline 06-28-2017 10:58

Re: register_clcmd with parameter UID
 
Can you show me example please? Im new and i only start learning pawno and dont have perfect english

EFFx 06-28-2017 11:35

Re: register_clcmd with parameter UID
 
Or strbreak too. Anyway, search. In this section you do things by yourself.

gameplayonline 06-28-2017 12:11

Re: register_clcmd with parameter UID
 
Ihave this but have error.
Code:

       
        new arg[32]
        read_args(arg, sizeof(arg) - 1)
        remove_quotes(arg)

        if(contain(arg, "/referral"))
        {
                parse(arg)
                str_to_num(arg)
                if (equali(arg, uid)
                        client_print(id, print_chat, "test")   
        }
}

Error: Error: Argument type mismatch (argument 2) on line 83

gameplayonline 06-28-2017 12:22

Re: register_clcmd with parameter UID
 
I tried
Code:

uid = 123
        new arg[32]
        read_args(arg, sizeof(arg) - 1)
        remove_quotes(arg)

        if(strtok(arg, "/referral", str_to_num(arg), uid ))
        {
                        client_print(id, print_chat, "test")   
        }

Still have error: Error: Argument type mismatch (argument 4) on line 79

gameplayonline 06-28-2017 13:13

Re: register_clcmd with parameter UID
 
Im trying many changes but i really dont know how to do can somebody help me please?


All times are GMT -4. The time now is 22:44.

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