SA-MP Forums Archive
Simple command isn't working - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Simple command isn't working (/showthread.php?tid=279496)



Simple command isn't working - Kingunit - 27.08.2011

Hello,

I'm create some simple commands, but this one doens't work. It's just strange since I don't see the fault.
I've used those command before and those just worked. This one not:
pawn Code:
//-----[Me]-----
CMD:me(playerid, params[])
{
    if(sscanf(params, "s", playerid)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY"[CMD] / "#COL_SGREY"[Action]");
    new string[128], text[64], pName[24];
    GetPlayerName(playerid,pName,128);
    format(string,sizeof string,"* %s %s",pName,text);
    SendClientMessageToAll(COLOR_RED,string);
    return 1;
}
When I am ingame the output is just:
*


Re: Simple command isn't working - [MG]Dimi - 27.08.2011

PHP Code:
new string[128], text[64], pName[24];
    
GetPlayerName(playerid,pName,128); 
Up there you have pName[24] and down you have GetPlayerName(playerid,pName,12

Maybe that?


AW: Simple command isn't working - Nero_3D - 27.08.2011

the text variable looks pretty empty and sscanf surly wants an string not an integer as output


Re: Simple command isn't working - Jafet_Macario - 27.08.2011

PHP Code:
CMD:me(playeridparams[])
{
    new 
pName[MAX_PLAYER_NAME], string[128];
    
GetPlayerName(playeridpNamesizeof(pName));
    if(
isnull(params)) return SendClientMessage(playeridCOLOR_WHITE""#COL_DGREY"[CMD] / "#COL_SGREY"[Action]");
    
format(stringsizeof(string), "* %s %s"pNameparams);
    
SendClientMessageToAll(COLOR_RED,string);
    return 
1;




Re: Simple command isn't working - Kingunit - 27.08.2011

Quote:
Originally Posted by Jafet_Macario
View Post
PHP Code:
CMD:me(playeridparams[])
{
    new 
pName[MAX_PLAYER_NAME], string[128];
    
GetPlayerName(playeridpNamesizeof(pName));
    if(
isnull(params)) return SendClientMessage(playeridCOLOR_WHITE""#COL_DGREY"[CMD] / "#COL_SGREY"[Action]");
    
format(stringsizeof(string), "* %s %s"pNameparams);
    
SendClientMessageToAll(COLOR_RED,string);
    return 
1;

Yes, those are working. But now if I use it I didn't learned anything. Can someone show me a example with using sscanf? So I can see what I've did wrong.


Re: Simple command isn't working - Jafet_Macario - 27.08.2011

You don't need to:
pawn Code:
if(sscanf(params,"s"...
because sscanf will use params so you only gotta check if the params are null


Re: Simple command isn't working - Kingunit - 27.08.2011

Aah okay. Anyway thank you for helping me all