Don't understand ?
#1

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

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

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;
}
Reply
#4

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)