SA-MP Forums Archive
Saving Weapons. (Only works on crash?) - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving Weapons. (Only works on crash?) (/showthread.php?tid=75449)



Saving Weapons. (Only works on crash?) - -eXo - 02.05.2009

This only saves players weapons when they crash, anyone help?.

Код:
public OnPlayerDisconnect(playerid, reason)
{
	gActivePlayers[playerid]--;
	numplayers--;
	if(reason == 0)
	{
	  PlayerInfo[playerid][pCrashed] = 1;
	  for(new slot = 0; slot != 12; slot++)
	  {
	    new wep, ammo;
	    GetPlayerWeaponData(playerid, slot, wep, ammo);
	    
	    if(wep != 0 && ammo != 0)
	    {
	      if(PlayerInfo[playerid][pGun1] == 0) { PlayerInfo[playerid][pGun1] = wep; PlayerInfo[playerid][pAmmo1] = ammo; }
	      else if(PlayerInfo[playerid][pGun2] == 0) { PlayerInfo[playerid][pGun2] = wep; PlayerInfo[playerid][pAmmo2] = ammo; }
	      else if(PlayerInfo[playerid][pGun3] == 0) { PlayerInfo[playerid][pGun3] = wep; PlayerInfo[playerid][pAmmo3] = ammo; }
	      else if(PlayerInfo[playerid][pGun4] == 0) { PlayerInfo[playerid][pGun4] = wep; PlayerInfo[playerid][pAmmo4] = ammo; }
	    }
	  }
	}



Re: Saving Weapons. (Only works on crash?) - Danny_Costelo - 02.05.2009

Quote:

if(reason == 0)

There's your problem.


Re: Saving Weapons. (Only works on crash?) - -eXo - 02.05.2009

What do I change that to so it works on crash and logout?.


Re: Saving Weapons. (Only works on crash?) - Danny_Costelo - 02.05.2009

Quote:
Originally Posted by -eXo
What do I change that to so it works on crash and logout?.
Remove reason == 0 and the bracket opening and closing it, than it'll work for all cases (Kicks, Disconnect, Crash).