Simple command isn't working
#1

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:
*
Reply
#2

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?
Reply
#3

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

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;

Reply
#5

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.
Reply
#6

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
Reply
#7

Aah okay. Anyway thank you for helping me all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)