[+REP] OnEnterExitModShop Problem
#4

Your code doesn't work because what ever you data you store in local variables will be lost once the function is executed.That means that when a player enters a mod shop, you save the information and when he exits whatever you saved wouldn't be there since the callback is called separately for entering and exiting.


The solution would be to use global variables which do not lose data when the scope of a function ends.
Код:
new Float:pVehicleH[MAX_PLAYERS];
new pVehiclePanels[MAX_PLAYERS];
new pVehicleDoors[MAX_PLAYERS];
new pVehicleLights[MAX_PLAYERS];
new pVehicleTires[MAX_PLAYERS];
public OnEnterExitModShop(playerid, enterexit, interiorid)
{
    new veh = GetPlayerVehicleID(playerid);
   if(enterexit == 1) 
   {       GetVehicleDamageStatus(veh,pVehiclePanels[playerid],pVehicleDoors[playerid],pVehicleLights[playerid],pVehicleTires[playerid]);
       GetVehicleHealth(veh,pVehicleH[playerid]);
   }
   else
   {
       UpdateVehicleDamageStatus(veh,pVehiclePanels[playerid],pVehicleDoors[playerid],pVehicleLights[playerid],pVehicleTires[playerid]);
       SetVehicleHealth(veh,pVehicleH[playerid]);
   }
}
Reply


Messages In This Thread
[+REP] OnEnterExitModShop Problem - by norton2 - 24.05.2015, 09:51
Re: [+REP] OnEnterExitModShop Problem - by Bingo - 24.05.2015, 10:13
Re: [+REP] OnEnterExitModShop Problem - by norton2 - 24.05.2015, 10:18
Re: [+REP] OnEnterExitModShop Problem - by Yashas - 24.05.2015, 10:30
Re: [+REP] OnEnterExitModShop Problem - by norton2 - 24.05.2015, 10:44
Re: [+REP] OnEnterExitModShop Problem - by Yashas - 24.05.2015, 10:51

Forum Jump:


Users browsing this thread: 1 Guest(s)