Problem
#1

I was working on a script but the plays a sounds where you are in a vehicle I use a command and it plays a sounds when I exit the vehicle it stops the sounds but no matter which vehicle I enter it keeps playing the sound, how can I make the command to be specific on a vehicle that I used the command on ?
code:
this is the command that activates the sounds
pawn Код:
if ( g_BoomTimer[ playerid ] != -1 )
                   {
                    KillTimer( g_BoomTimer[ playerid ] );
                    g_BoomTimer[ playerid ] = -1;
                    }
                    else
                    {
                    g_BoomTimer[ playerid ] = SetTimerEx( "BoomSound", 1000, true, "i", playerid );
                    }
                    gEngine[playerid] = 1;
                    return 1;
                }
pawn Код:
forward BoomSound( playerid );
public  BoomSound( playerid )
{
  new Float:x, Float:y, Float:z;
 
    if(IsPlayerInAnyVehicle(playerid))
            {
  PlayerPlaySound(playerid, 1147, x, y, z);
}
}
Reply
#2

Add some sort of vehicle check to your script. Such as:

pawn Код:
if ( g_BoomTimer[ playerid ] != -1 && GetVehicleModel(GetPlayerVehicleID(playerid)) == 400) // 400 is the model of landstalker vehicle, only play when entering that for example
    {
        KillTimer( g_BoomTimer[ playerid ] );
        g_BoomTimer[ playerid ] = -1;
    }
    else
    {
        g_BoomTimer[ playerid ] = SetTimerEx( "BoomSound", 1000, true, "i", playerid );
    }
    gEngine[playerid] = 1;
    return 1;
}
So you can change it to whatever vehicles you want it to work in.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)