19.10.2010, 13:03
Well.. I'm not sure exactly what you mean, but what about this:
Filterscript:
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.
}
}