PDA

View Full Version : Don't understand ?


kaloqn54
27/07/2013, 02:25 AM
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 ????

RafaelZam
27/07/2013, 02:49 AM
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

Deron_Green
27/07/2013, 03:14 AM
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:

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

ToiletDuck
27/07/2013, 05:51 AM
Use isnull instead of sscanf

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