SA-MP Forums Archive
Don't understand ? - 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: Don't understand ? (/showthread.php?tid=453935)



Don't understand ? - kaloqn54 - 27.07.2013

I wrote a simple code here it is:
Код:
CMD:welcome(playerid, params[])
{
new string[128], msg[128], pname[MAX_PLAYER_NAME];
if(sscanf(params,"sz",msg)) return SendClientMessage(playerid, 0xCD3333, "/welcome <text>");
format(string, sizeof(string), "*%s %s", pname, msg);
SendClientMessageToAll(0xCD3333, string);
return 1;
}
And when i write the command on my server unknow command ?


Respuesta: Don't understand ? - RafaelZam - 27.07.2013

pawn Код:
CMD:welcome(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /welcome < text >");
    new str[500];
    format(str, sizeof(str), " * %s %s", GetName(playerid), params);
    SendClientMessageToAll(0xCD3333, str);
    return 1;
}
this with this


Re: Respuesta: Don't understand ? - Deron_Green - 27.07.2013

Quote:
Originally Posted by Rafael_Zambrano
Посмотреть сообщение
pawn Код:
CMD:welcome(playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /welcome < text >");
    new str[500];
    format(str, sizeof(str), " * %s %s", GetName(playerid), params);
    SendClientMessageToAll(0xCD3333, str);
    return 1;
}
this with this
I can tell you pulled this out of your GM/FS this code wont work for most people. He doesn't have GetName(playerid) so where did that come from?
And new str[500]; ?
No. just No.
Try this:
pawn Код:
CMD:welcome(playerid, params[])
{
    new string[128], msg[128], pname[MAX_PLAYER_NAME];
    if(sscanf(params,"s[128]",msg)) return SendClientMessage(playerid, 0xCD3333, "/welcome <text>");
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "*%s %s", pname, msg);
    SendClientMessageToAll(0xCD3333, string);
    return 1;
}



Re: Don't understand ? - ToiletDuck - 27.07.2013

Use isnull instead of sscanf

pawn Код:
CMD:welcome(playerid, params[])
{
    new string[128], pname[MAX_PLAYER_NAME];
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /welcome < text >");
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "*%s %s", pname, params);
    SendClientMessageToAll(0xCD3333, string);
    return 1;
}