AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Help with String (https://forums.alliedmods.net/showthread.php?t=302916)

Facksy 11-15-2017 18:33

Help with String
 
Hello guys, i've got a little problems with my plugin, when someone say "Yakada", it should reply "yes" but actually, its always replying "nop", even when i say perfectly "Yakada":
Code:

public OnPluginStart()
{
        AddCommandListener(Listener_Say, "say");
        AddCommandListener(Listener_Say, "say2");
        AddCommandListener(Listener_Say, "say_team");
}

public Action:Listener_Say(client, const String:command[], argc)
{
    decl String:arg[264];
    GetCmdArgString(arg, 264);
    if(StrEqual(arg, "Yakada"))
    {
        PrintToChatAll("yes");
    }
    else
    {
        PrintToChatAll("nop");
    }
}


fakuivan 11-15-2017 19:10

Re: Help with String
 
https://sm.alliedmods.net/new-api/co...etCmdArgString

You are getting the whole command "say Yakada", instead of just "Yakada", that's what ``GetCmdArgString`` does. You need to use ``GetCmdArg`` and pass the correct argument position to get "Yakada". Next time you could try to print the contents of your string before writing a thread and save yourself some time.

fakuivan 11-15-2017 19:13

Re: Help with String
 
Btw you might want to start by learning the new syntax, instead of the old one, since it could get deprecated in the future.

Elitcky 11-16-2017 03:13

Re: Help with String
 
Didn't tested anything...
Btw, now is in new syntax...
PHP Code:

public Action Listener_Say(int client, const char[] commandint argc)
{
    
char arg[264];
    
GetCmdArgString(argsizeof(arg));
    
StripQuotes(arg);

    if(
StrEqual(arg"Yakada"false))
    {
        
PrintToChatAll("yes");
    }
    else
    {
        
PrintToChatAll("nop");
    }



xerox8521 11-16-2017 03:56

Re: Help with String
 
You can just use this instead of manually hooking say https://sm.alliedmods.net/new-api/co...ientSayCommand


All times are GMT -4. The time now is 23:06.

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