Problem - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem (
/showthread.php?tid=184359)
Problem -
Scriptissue - 19.10.2010
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);
}
}
Re: Problem -
JaTochNietDan - 19.10.2010
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.