Need help please . - 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: Need help please . (
/showthread.php?tid=184344)
Need help please . -
Scriptissue - 19.10.2010
Is there a way to setplayer sounds until he uses a command ?
For example :
A player get's punched and he will hear the punching sound repeats it's self "Boom" then another Boom, until he uses a command is there any way ?
Re: Need help please . -
Slice - 19.10.2010
Well.. I'm not sure exactly what you mean, but what about this:
Filterscript:
pawn Код:
#include <a_samp>
new
g_BoomTimer[ MAX_PLAYERS ] = { -1, ... } // Make an array with one slot per player. Set each value to -1.
;
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
if ( !strcmp( cmdtext, "/boom", true ) ) // If the player types /boom..
{
// Start the "boom timer" for the player.
if ( g_BoomTimer[ playerid ] != -1 ) // If the boom timer already exists (isn't -1)
{
KillTimer( g_BoomTimer[ playerid ] ); // Then stop the timer
g_BoomTimer[ playerid ] = -1; // Set the boom timer to -1 so the script knows it isn't used.
}
else // if the player didn't have an active boom timer!
{
g_BoomTimer[ playerid ] = SetTimerEx( "BoomSound", 1000, true, "i", playerid );
// Because I used forward and public on "BoomSound", I can use it in timers.
// 1000 is the number of milliseconds to wait between repeating the timer. 1000 milliseconds is 1 second.
// true tells the server to keep repeating the BoomSound function.
// "i", playerid will send an _i_nteger (number) to the function, containing the playerid.
}
return 1;
}
return 0;
}
forward BoomSound( playerid );
public BoomSound( playerid )
{
// do your sound stuff in here
// PlayerPlaySound( ...
}
public OnPlayerDisconnect( playerid, reason )
{
// We have to destroy the timer when the player disconnects! Otherwise, players with the same ID will hear sounds when they join.
if ( g_BoomTimer[ playerid ] != -1 ) // If the boom timer already exists (isn't -1)
{
KillTimer( g_BoomTimer[ playerid ] ); // Then stop the timer
g_BoomTimer[ playerid ] = -1; // Set the boom timer to -1 so the script knows it isn't used.
}
}
Re: Need help please . -
Scriptissue - 19.10.2010
It works, but It doesn't stop when I want it to happen only in a vehicle, but when I exit the vehicle it keeps playing the sound.
Re: Need help please . -
Slice - 19.10.2010
pawn Код:
forward BoomSound( playerid );
public BoomSound( playerid )
{
// do your sound stuff in here
// PlayerPlaySound( ...
if ( IsPlayerInAnyVehicle( playerid ) )
{
}
}
Re: Need help please . -
Scriptissue - 19.10.2010
Thanks, I have last bug, when the sounds plays only I can hear them, the players who stand near me can't hear it.
how can I make them hear it ? .