Targetid doesn't detect the player
#1

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

Код:
 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.
Reply
#3

After correction, still not works.
Reply
#4

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)