Turn signal problem
#1

Well , alot of problems i have lol

I tried to make kinda of turn signals system but it's not working so well

OnPlayerKeyStateChange:
PHP код:
if(PRESSED(KEY_LOOK_RIGHT))
    {
        new 
vehicleid GetPlayerVehicleID(playerid);
        if(
IsPlayerInVehicle(playeridvehicleid))
        {
            if(!
IsVehicleAirVehicleEx(vehicleid))
            {
                
FlashTimerR[vehicleid] = SetTimerEx("FlashLightR"120true,"i",vehicleid);
                
DestroyFlashTimerR[vehicleid] = SetTimerEx("DestroyFlashLightR"700false,"i",vehicleid);
            }
        }
    }
    if(
PRESSED(KEY_LOOK_LEFT))
    {
        new 
vehicleid GetPlayerVehicleID(playerid);
        if(
IsPlayerInVehicle(playeridvehicleid))
        {
            if(!
IsVehicleAirVehicleEx(vehicleid))
            {
                
FlashTimerL[vehicleid] = SetTimerEx("FlashLightL"120true,"i",vehicleid);
                
DestroyFlashTimerL[vehicleid] = SetTimerEx("DestroyFlashLightL"700false,"i",vehicleid);
            }
        }
    } 
Timers:
PHP код:
forward FlashLightR(vehicleid);
public 
FlashLightR(vehicleid)
{
    new 
panels,doors,lights,tires;
    
GetVehicleDamageStatus(vehicleidpanelsdoorslightstires);
    if(
lights == 1)
    {
        
UpdateVehicleDamageStatus(vehicleidpanelsdoors5tires);
        
lights 5;
    }
    else if(
lights == 5)
    {
        
UpdateVehicleDamageStatus(vehicleidpanelsdoors1tires);
        
lights 1;
    }
    return 
1;
}
forward DestroyFlashLightR(vehicleid);
public 
DestroyFlashLightR(vehicleid)
{
    new 
panels,doors,lights,tires;
    
GetVehicleDamageStatus(vehicleidpanelsdoorslightstires);
    
UpdateVehicleDamageStatus(vehicleidpanelsdoors5tires);
    
KillTimer(FlashTimerR[vehicleid]);
    return 
1;
}
forward FlashLightL(vehicleid);
public 
FlashLightL(vehicleid)
{
    new 
panels,doors,lights,tires;
    
GetVehicleDamageStatus(vehicleidpanelsdoorslightstires);
    if(
lights == 4)
    {
        
UpdateVehicleDamageStatus(vehicleidpanelsdoors5tires);
        
lights 5;
    }
    else if(
lights == 5)
    {
        
UpdateVehicleDamageStatus(vehicleidpanelsdoors4tires);
        
lights 4;
    }
    return 
1;
}
forward DestroyFlashLightL(vehicleid);
public 
DestroyFlashLightL(vehicleid)
{
    new 
panels,doors,lights,tires;
    
GetVehicleDamageStatus(vehicleidpanelsdoorslightstires);
    
UpdateVehicleDamageStatus(vehicleidpanelsdoors5tires);
    
KillTimer(DestroyFlashTimerL[vehicleid]);
    return 
1;

It's not stoping and when i press to activate the right one its activating the left one...And the right one it's never stops
Reply
#2

You should probably check if the timer is already active before setting it (again). If I'd press the key in rapid succession then multiple timers would be set and they would overwrite the already existing timer handles. This means that these timers can't be killed anymore.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
You should probably check if the timer is already active before setting it (again). If I'd press the key in rapid succession then multiple timers would be set and they would overwrite the already existing timer handles. This means that these timers can't be killed anymore.
And how to check? Because there is no function to check if its timer active or something
Reply
#4

Page 4, still no solution
Any help?
Reply
#5

When you kill a timer, set FlashTimerR[vehicleid] and/or FlashTimerL[vehicleid] to 0, so you can check if timers are active or not.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)