PDA

View Full Version : Anyone notices errors?


Audi_Quattrix
06/12/2013, 06:38 PM
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;
}

Patrick
06/12/2013, 07:00 PM
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


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

Audi_Quattrix
06/12/2013, 07:17 PM
Well im not sure is it because im testing alone sending pm to myself but

when i type:
/Pm 0 test

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

Patrick
06/12/2013, 07:26 PM
Make sure you have the GetPlayerNameEx function right and about the ID, you maybe have a bot(s).


stock GetPlayerNameEx(playerid)
{
new
_GetPlayerName[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, _GetPlayerName, sizeof( _GetPlayerName ) )
return _GetPlayerName;
}

Audi_Quattrix
06/12/2013, 07:34 PM
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

tyler12
06/12/2013, 07:35 PM
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


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.

Patrick
06/12/2013, 07:37 PM
8)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]

Audi_Quattrix
06/12/2013, 07:40 PM
Thanks guys ;D
I didnt notice it myself was staring at the script for pretty long actually