Raised This Month: $51 Target: $400
 12% 

Help with String


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Facksy
Senior Member
Join Date: Apr 2017
Location: +2+2
Old 11-15-2017 , 18:33   Help with String
Reply With Quote #1

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");
    }
}

Last edited by Facksy; 11-15-2017 at 18:34.
Facksy is offline
fakuivan
Senior Member
Join Date: Nov 2015
Old 11-15-2017 , 19:10   Re: Help with String
Reply With Quote #2

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 is offline
fakuivan
Senior Member
Join Date: Nov 2015
Old 11-15-2017 , 19:13   Re: Help with String
Reply With Quote #3

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

Last edited by fakuivan; 11-15-2017 at 19:21.
fakuivan is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 11-16-2017 , 03:13   Re: Help with String
Reply With Quote #4

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");
    }

__________________
Elitcky is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 11-16-2017 , 03:56   Re: Help with String
Reply With Quote #5

You can just use this instead of manually hooking say https://sm.alliedmods.net/new-api/co...ientSayCommand
xerox8521 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 07:06.


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