Anyone notices errors? -
Audi_Quattrix - 06.12.2013
pawn Код:
CMD:pm(playerid, params[])
{
new string2[256],string1[256],giveid,text;
if(sscanf(params,"us",giveid,text))
{
SendClientMessage(playerid,COLOR_GREY,"Usage: /Pm [ID] [Text]");
}
else
{
format(string2,sizeof(string2),"[PM] to %s(ID:%d): %s",GetPlayerNameEx(giveid),giveid,text);
SendClientMessage(playerid,COLOR_GREEN,string2);
format(string1,sizeof(string1),"[PM] from %s(ID:%d): %s",GetPlayerNameEx(playerid),playerid,text);
SendClientMessage(giveid,COLOR_GREEN,string1);
}
return 1;
}
Re: Anyone notices errors? - Patrick - 06.12.2013
Quote:
Originally Posted by Audi_Quattrix
pawn Код:
CMD:pm(playerid, params[]) { new string2[256],string1[256],giveid,text; if(sscanf(params,"us",giveid,text)) { SendClientMessage(playerid,COLOR_GREY,"Usage: /Pm [ID] [Text]"); } else { format(string2,sizeof(string2),"[PM] to %s(ID:%d): %s",GetPlayerNameEx(giveid),giveid,text); SendClientMessage(playerid,COLOR_GREEN,string2); format(string1,sizeof(string1),"[PM] from %s(ID:%d): %s",GetPlayerNameEx(playerid),playerid,text); SendClientMessage(giveid,COLOR_GREEN,string1); } return 1; }
|
Nope, I don't find any errors, but I changed some of your code. I changed the string size and Indentationalso added the string size in sscanf parameter
pawn Код:
CMD:pm(playerid, params[])
{
new
string[128], giveid, text;
if(sscanf(params,"us[128]",giveid,text))
return SendClientMessage(playerid,COLOR_GREY,"Usage: /Pm [ID] [Text]");
format(string,sizeof(string),"[PM] to %s(ID:%d): %s",GetPlayerNameEx(giveid),giveid,text);
SendClientMessage(playerid,COLOR_GREEN,string);
format(string,sizeof(string),"[PM] from %s(ID:%d): %s",GetPlayerNameEx(playerid),playerid,text);
SendClientMessage(giveid,COLOR_GREEN,string);
return 1;
}
Re: Anyone notices errors? -
Audi_Quattrix - 06.12.2013
Well im not sure is it because im testing alone sending pm to myself but
when i type:
It shows :
Код:
[PM] to (ID:101): test
It doesnt show name and i dont receive the pm.
It should be:
Код:
[PM] to Audi_Quattrix(ID:0): test
Re: Anyone notices errors? - Patrick - 06.12.2013
Make sure you have the GetPlayerNameEx function right and about the ID, you maybe have a bot(s).
pawn Код:
stock GetPlayerNameEx(playerid)
{
new
_GetPlayerName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, _GetPlayerName, sizeof( _GetPlayerName ) )
return _GetPlayerName;
}
Re: Anyone notices errors? -
Audi_Quattrix - 06.12.2013
I have the stock and its working correctly on other commands but this.
No bots at all and Bare script so it cant be related to gamemode
Re: Anyone notices errors? -
tyler12 - 06.12.2013
Quote:
Originally Posted by pds2k12
Nope, I don't find any errors, but I changed some of your code. I changed the string size and Indentationalso added the string size in sscanf parameter
pawn Код:
CMD:pm(playerid, params[]) { new string[128], giveid, text;
if(sscanf(params,"us[128]",giveid,text)) return SendClientMessage(playerid,COLOR_GREY,"Usage: /Pm [ID] [Text]"); format(string,sizeof(string),"[PM] to %s(ID:%d): %s",GetPlayerNameEx(giveid),giveid,text); SendClientMessage(playerid,COLOR_GREEN,string);
format(string,sizeof(string),"[PM] from %s(ID:%d): %s",GetPlayerNameEx(playerid),playerid,text); SendClientMessage(giveid,COLOR_GREEN,string); return 1; }
|
Make sure you declare the 'text' variable as a string too.
Re: Anyone notices errors? - Patrick - 06.12.2013

Quote:
Originally Posted by tyler12
Make sure you declare the 'text' variable as a string too.
|
Nice catch didn't actually see that, make change the , text to , text[128]
Re: Anyone notices errors? -
Audi_Quattrix - 06.12.2013
Thanks guys

I didnt notice it myself was staring at the script for pretty long actually