Anyone notices errors?
#1

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

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

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

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

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

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

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]
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)