SA-MP Forums Archive
Targetid doesn't detect the player - 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: Targetid doesn't detect the player (/showthread.php?tid=659266)



Targetid doesn't detect the player - KayJ - 29.09.2018

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
name[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME], targetidmoney GetPlayerMoney(playerid);
    
GetPlayerName(playeridnamesizeof(name));
    
GetPlayerName(targetidtnamesizeof(tname));
    switch(
reason)
    {
        case 
0// Timeout / Crashed
        
{
            if(
rp[playerid] == || rp1[targetid] ==1)
            {
                if(
pInfo[targetid][pWallet] == 0)
                {
                    new 
string [200];
                    
format(string,sizeof(string), "You've recovered your wallet(0$). Reason: %s(%d) has crashed."nameplayerid);
                    
SendClientMessage(playerid, -1string);
                    
pInfo[targetid][pWallet] = 1;
                    
pInfo[playerid][pWallet] = 0;
                    
pInfo[playerid][pCash] = 0;
                } else return 
1;
            }
            return 
1;
        }
        case 
1// Left
        
{
            if(
rp[playerid] == || rp1[targetid] ==1)
            {
                if(
pInfo[targetid][pWallet] == 0)
                {
                    new 
string [200];
                    
format(string,sizeof(string), "You've recovered your wallet(0$). Reason: %s(%d) has left."nameplayerid);
                    
SendClientMessage(playerid, -1string);
                    
pInfo[targetid][pWallet] = 1;
                    
pInfo[playerid][pWallet] = 0;
                    
pInfo[playerid][pCash] = 0;
                } else return 
1;
            }
        }
        case 
2// Kicked / Banned
        
{
            if(
rp[playerid] == || rp1[targetid] ==1)
            {
                if(
pInfo[targetid][pWallet] == 0)
                {
                    new 
string [200];
                    
GivePlayerMoney(targetidmoney);
                    
GivePlayerMoney(playerid, -money);
                    
format(string,sizeof(string), "You've recovered your wallet(%d$). Reason: %s(%d) has been kicked/banned."nameplayeridmoney);
                    
SendClientMessage(playerid, -1string);
                    
pInfo[targetid][pWallet] = 1;
                    
pInfo[playerid][pWallet] = 0;
                    
pInfo[playerid][pCash] = 0;
                } else return 
1;
            }
        }
    }
       
SaveStats(playerid);
    return 
1;

If I rob someone and /q then the person doesn't get his wallet back nor the message of recovering.


Re: Targetid doesn't detect the player - Electrifying - 29.09.2018

Код:
 format(string,sizeof(string), "You've recovered your wallet(0$). Reason: %s(%d) has left.", name, playerid);
 SendClientMessage(playerid, -1, string);
You are sending a message to the guy disconnecting from the server.


Re: Targetid doesn't detect the player - KayJ - 29.09.2018

After correction, still not works.


Re: Targetid doesn't detect the player - Calisthenics - 29.09.2018

The same mistake as your previous thread, targetid is again 0.

I look at the source code of your filterscript for the /rob command and you have the same mistake there again. You get the position before the sscanf line.

You set some variables to 1 when being robbed or robbing a player but instead of this way, here is what you have to do:
reset to -1 and set the ID of the player who robs or being robbed. That way, you can retrieve it in OnPlayerDisconnect and send them a message about the recovery of their wallet.


Re: Targetid doesn't detect the player - ReD_HunTeR - 29.09.2018

recheck your code, you are doing everything wrong,
1, you should consider saving targetid somewhere.
2, you are actually sending message to playerid not targetid


Re: Targetid doesn't detect the player - v1k1nG - 29.09.2018

Quitting player won't read the message anyways!
Just recover the wallet elsewhere in your code, and tell players via any helping command that the wallet is recovered in case of... etc.
Good luck!


Re: Targetid doesn't detect the player - TheToretto - 29.09.2018

Replace your "playerid" by "targetid", same thing for "targetid" by "playerid" because you're sending messages and everything to the playerid, who did just disconnect, he'll get nothing.