Timer.
#1

Hello,
I wanted help with this code:
PHP Code:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/seatbelton"cmdtexttrue10) == 0)
    {
        if(
IsPlayerInAnyVehicle(playerid))
        {
            if(
PlayerInfo[playerid][seatbelt] = false)
            {
                
PlayerInfo[playerid][seatbelt] = true;
                
SendClientMessage(playerid,0xFFFFFF,"You have succesfully put your seatbelt on.");
            }
            else
            
SendClientMessage(playerid,0xFFFFFF,"You already have your seatbelt on.");
        }
        else
          
SendClientMessage(playerid,0xFFFFFF,"You are not in a vehicle!");
    }
    if (
strcmp("/seatbeltoff"cmdtexttrue10) == 0)
    {
        if(
IsPlayerInAnyVehicle(playerid))
        {
            if(
PlayerInfo[playerid][seatbelt] = true)
            {
                
PlayerInfo[playerid][seatbelt] = false;
                
SendClientMessage(playerid,0xFFFFFF,"You have succesfully put your seatbelt off.");
            }
            else
            
SendClientMessage(playerid,0xFFFFFF,"You already have your seatbelt off.");
        }
        else
          
SendClientMessage(playerid,0xFFFFFF,"You are not in a vehicle!");
    }
    return 
0;
}
public 
OnVehicleDamageStatusUpdate(vehicleidplayerid)
{
    
SetTimerEx("damage"5000false"b"playerid);
    return 
1;
}
forward damage(playerid);
public 
damage(playerid)
{
    if(
IsPlayerInAnyVehicle(playerid))
    {
        if(
PlayerInfo[playerid][seatbelt] = true)
        {
            
SetPlayerDrunkLevel(playerid,3000);
        }
        else
        return 
0;
    }
    else
    return 
0;
     return 
1;

I have two problems with this:
1:The timer does not end and the player is still in drunk Position.
2:Even if I do /seatbelton,when the player's car gets damaged,the player again apears to be drunk.I don't want this to happen if a player did /seatbelton.Please help.
Reply
#2

DO NOT IGNORE WARNINGS! They're there for a reason!

This;
pawn Code:
if(PlayerInfo[playerid][seatbelt] = false)
Should give you a warning: 211 possibly unintended assignment. That is because the comparison operator is == and not just =.
Reply
#3

yes these are the warning.There are 3 warings.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)