SA-MP Forums Archive
ID's are messed up - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: ID's are messed up (/showthread.php?tid=360904)



ID's are messed up - CoDeZ - 19.07.2012

Hello guys , i've got a problem , with my id's
i have a pm command , when i type /pm 1 , it send it to id 2 or id 0
Why does this happen?
I have latest version of sscanf + zcmd
and here is my code .
pawn Код:
CMD:pm(playerid,params[])
{
    new PID,p_Send[24],p_Rec[24],str[128],str2[128],Message[100];
    GetPlayerName(PID,p_Rec,24);
    GetPlayerName(playerid,p_Send,24);
    if(PM_Enabled[PID]==0) return SendClientMessage(playerid,COLOR_RED,"This player has disabled his pm");
    else if (PM_Enabled[PID]==1)
    {
        if(sscanf(params,"us[100]",PID,Message)) return SendClientMessage(playerid,COLOR_GREEN,"USAGE:/pm playerid message");
        if(isnull(params)) return SendClientMessage(playerid,COLOR_RED,"USAGE:/pm playerid message");
        if(PID==playerid) return SendClientMessage(playerid,COLOR_RED,"You can't pm your self.");
        if(!IsPlayerConnected(PID)) return SendClientMessage(playerid,COLOR_RED,"This player is not connected.");
        format(str2,sizeof(str),"Pm To "#COL_GREEN"%s[%d]:%s",p_Rec,PID,Message);
        format(str,sizeof(str2),"Pm From "#COL_GREEN"%s[%d]:%s",p_Send,playerid,Message);
        SendClientMessage(playerid,COLOR_RED,str2);
        SendClientMessage(PID,COLOR_YELLOW,str);
    }
    return 1;
}



Re: ID's are messed up - Andi_Evandy - 19.07.2012

pawn Код:
CMD:pm(playerid,params[])
{
    new PID,p_Send[24],p_Rec[24],str[128],str2[128],Message[100];
    if(sscanf(params,"us[100]",PID,Message)) return SendClientMessage(playerid,COLOR_GREEN,"USAGE:/pm playerid message");
    if(PID == playerid) return SendClientMessage(playerid,COLOR_RED,"You can't pm your self.");
    if(!IsPlayerConnected(PID)) return SendClientMessage(playerid,COLOR_RED,"This player is not connected.");
    if(PM_Enabled[PID] == 0) return SendClientMessage(playerid,COLOR_RED,"This player has disabled his pm");
    else if (PM_Enabled[PID] == 1)
    {
        GetPlayerName(PID,p_Rec,24);
        GetPlayerName(playerid,p_Send,24);
        format(str2,sizeof(str),"Pm To "#COL_GREEN"%s[%d]:%s",p_Rec,PID,Message);
        format(str,sizeof(str2),"Pm From "#COL_GREEN"%s[%d]:%s",p_Send,playerid,Message);
        SendClientMessage(playerid,COLOR_RED,str2);
        SendClientMessage(PID,COLOR_YELLOW,str);
    }
    return 1;
}



Re: ID's are messed up - hansen111 - 19.07.2012

If you want to know what the problem was which was corrected in the post by Andi_Evandi then this line:

if(sscanf(params,"us[100]",PID,Message))

is the code that actually assign the variables PID and Message the values you put in the command. So placing this line AFTER you use PID and Message is pointless, by moving the line in top the values are assigned correctly and you can use those varibles in code AFTER like:

else if (PM_Enabled[PID] == 1)

Hope it maskes sence to you


Re: ID's are messed up - CoDeZ - 19.07.2012

Quote:
Originally Posted by hansen111
Посмотреть сообщение
If you want to know what the problem was which was corrected in the post by Andi_Evandi then this line:

if(sscanf(params,"us[100]",PID,Message))

is the code that actually assign the variables PID and Message the values you put in the command. So placing this line AFTER you use PID and Message is pointless, by moving the line in top the values are assigned correctly and you can use those varibles in code AFTER like:

else if (PM_Enabled[PID] == 1)

Hope it maskes sence to you
Yes i understood it , thanks