SA-MP Forums Archive
Problem with timer - 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: Problem with timer (/showthread.php?tid=465809)



Problem with timer - cuemur - 24.09.2013

PHP код:
LockNearbyVehicles(playerid, Float:radi)
{
    new 
Float:x, Float:y, Float:z;
    
GetPlayerPos(playerid, x, y, z);
    for(new 
i=1; i<MAX_VEHICLES; i++)
    {
        if(
GetVehicleModel(i))
        {
            
TimeRunning[i] = 40;
            new 
Float:posx, Float:posy, Float:posz;
            new 
Float:tempposx, Float:tempposy, Float:tempposz;
            
GetVehiclePos(i, posx, posy, posz);
            
tempposx = (posx - x);
            
tempposy = (posy - y);
            
tempposz = (posz - z);
            if (((
tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
            {
                if(
i != GetPlayerVehicleID(playerid))   {
                
GetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, boot, objective);
                
SetVehicleParamsEx(i, VEHICLE_PARAMS_OFF, VEHICLE_PARAMS_ON, alarm, doors, bonnet, boot, objective);    }
            }
        }
    }
} 
PHP код:
forward SecUpdate2();
public 
SecUpdate2()
{
    
MafiaCheck();
    for(new 
i =0; i <= MAX_VEHICLES; i++)
    {
        if(
TimeRunning[i] > 0)  {
            
TimeRunning[i]--;   }
            
    }
} 
This lock's all nearby vehicles for 40 seconds but 40 seconds never end's
HELP :/


Re: Problem with timer - Konstantinos - 24.09.2013

You need to kill the timer if the time passed.