Targetid doesn't detect the player -
KayJ - 29.09.2018
PHP код:
public OnPlayerDisconnect(playerid, reason)
{
new name[MAX_PLAYER_NAME], tname[MAX_PLAYER_NAME], targetid, money = GetPlayerMoney(playerid);
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(targetid, tname, sizeof(tname));
switch(reason)
{
case 0: // Timeout / Crashed
{
if(rp[playerid] == 1 || 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.", name, playerid);
SendClientMessage(playerid, -1, string);
pInfo[targetid][pWallet] = 1;
pInfo[playerid][pWallet] = 0;
pInfo[playerid][pCash] = 0;
} else return 1;
}
return 1;
}
case 1: // Left
{
if(rp[playerid] == 1 || 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.", name, playerid);
SendClientMessage(playerid, -1, string);
pInfo[targetid][pWallet] = 1;
pInfo[playerid][pWallet] = 0;
pInfo[playerid][pCash] = 0;
} else return 1;
}
}
case 2: // Kicked / Banned
{
if(rp[playerid] == 1 || rp1[targetid] ==1)
{
if(pInfo[targetid][pWallet] == 0)
{
new string [200];
GivePlayerMoney(targetid, money);
GivePlayerMoney(playerid, -money);
format(string,sizeof(string), "You've recovered your wallet(%d$). Reason: %s(%d) has been kicked/banned.", name, playerid, money);
SendClientMessage(playerid, -1, string);
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.