Need help please .
#1

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 ?
Reply
#2

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.
    }
}
Reply
#3

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.
Reply
#4

pawn Код:
forward BoomSound( playerid );
public  BoomSound( playerid )
{
    // do your sound stuff in here
    // PlayerPlaySound( ...
    if ( IsPlayerInAnyVehicle( playerid ) )
    {
   
    }
}
Reply
#5

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 ? .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)