Raised This Month: $51 Target: $400
 12% 

Solved improve my whistle script


Post New Thread Reply   
 
Thread Tools Display Modes
vegeta1241
AlliedModders Donor
Join Date: Apr 2017
Location: Switzerland
Old 11-22-2018 , 07:57   Re: improve my whistle script
Reply With Quote #11

http://fast.verygames.net/18/610429/

You will find this files on sound/ideas

Its .wav
vegeta1241 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-22-2018 , 10:28   Re: improve my whistle script
Reply With Quote #12

ok, there something different with that sound file, I don't know yeat what.

But you can test for example csgo in-game sound file

PHP Code:
PrecacheSound("commander/train_mainintro_01.wav");
EmitSoundToAll("commander/train_mainintro_01.wav"target); 
*edit
Now I understand, sound will work differently when it is either MONO or STEREO.
If you want sound work correctly in game, render sound file to MONO

*edit
Or try this first, use this ) in STEREO files
PHP Code:
PrecacheSound(")ideas/Whistle1.wav");
EmitSoundToAll(")ideas/Whistle1.wav"target); 
__________________
Do not Private Message @me

Last edited by Bacardi; 11-22-2018 at 10:46.
Bacardi is offline
vegeta1241
AlliedModders Donor
Join Date: Apr 2017
Location: Switzerland
Old 11-22-2018 , 11:52   Re: improve my whistle script
Reply With Quote #13

thank you for your answers my friend

I try with this ")" before precache and emit but not sound are emit

PHP Code:
#include <sourcemod> 
#include <sdktools> 

char g_sSounds[][] =  

    
"ideas/Whistle1.wav",
    
"ideas/Whistle2.wav" 
}; 

ConVar g_cVarLevel

bool HasWhistle[64]; 
bool HasForceWhistle[64]; 

public 
Plugin myinfo =  

    
name "New Plugin"
    
author "Unknown"
    
description "<- Description ->"
    
version "1.0"
    
url "<- URL ->" 


public 
void OnPluginStart() 

    
g_cVarLevel CreateConVar("sm_whistle_level""70""Pitch whistle"); 
    
RegConsoleCmd("sm_whistle"Whistle); 
    
RegConsoleCmd("sm_w"Whistle); 
    
RegConsoleCmd("sm_forcewhistle"ForceWhistle); 
    
RegConsoleCmd("sm_fw"ForceWhistle); 


public 
void OnMapStart() 

    for(
int i 0sizeof(g_sSounds); i++) 
    { 
        
char varchar[64]; 
        
Format(varchar64"sound/%s"g_sSounds[i]); 
        
AddFileToDownloadsTable(varchar); 
        
PrecacheSound(")g_sSounds[i]"true); 
    } 


public 
Action Whistle(int clientint args

    
args 0
    if(!
IsValidClient(client)) return Plugin_Handled
    if(!
IsPlayerAlive(client)) return Plugin_Handled
    if(
GetClientTeam(client) != 2
    { 
        
PrintToChat(client"[IDEAS] You cant whistle as CT"); 
        return 
Plugin_Handled
    } 
    if(
HasWhistle[client]) 
    { 
        
PrintToChat(client"[IDEAS] You can whistle only once very 30 seconds"); 
        return 
Plugin_Handled
    } 
     
    
float pos[3]; 
    
GetEntPropVector(clientProp_Send"m_vecOrigin"pos); 
    
EmitSoundToAll(")g_sSounds[GetRandomInt(0, sizeof(g_sSounds)-1)]"pos_g_cVarLevel.IntValue); 
    
HasWhistle[client] = true
    
CreateTimer(5.0WhistleAgainGetClientUserId(client)); 
    return 
Plugin_Handled


public 
Action WhistleAgain(Handle timerint userid

    
int client GetClientOfUserId(userid); 
    if(
IsValidClient(client)) 
    { 
        
HasWhistle[client] = false
    } 
    
delete timer
    return 
Plugin_Stop


public 
Action ForceWhistle(int clientint args

    
args 0
    if(!
IsValidClient(client)) return Plugin_Handled
    if(!
IsPlayerAlive(client)) return Plugin_Handled
    if(
GetClientTeam(client) != 3
    { 
        
PrintToChat(client"[IDEAS] You cant force whistle as T"); 
        return 
Plugin_Handled
    } 
    if(
HasForceWhistle[client]) 
    { 
        
PrintToChat(client"[IDEAS] You can force whistle only once very 30 seconds"); 
        return 
Plugin_Handled
    } 
    
HasForceWhistle[client] = true
    
CreateTimer(5.0ForceWhistleAgainGetClientUserId(client)); 
    
ForceRandomWhistle(); 
    return 
Plugin_Handled


public 
Action ForceWhistleAgain(Handle timerint userid

    
int client GetClientOfUserId(userid); 
    if(
IsValidClient(client)) 
    { 
        
HasForceWhistle[client] = false
    } 
    
delete timer
    return 
Plugin_Stop


void ForceRandomWhistle() 

    
int count 0cts[32]; 
    for(
int i 1<= MaxClientsi++) 
    { 
        if(
IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2
        { 
            
cts[count] = i
            
count++; 
        } 
    } 
    if(
count == 0
    { 
        
PrintToChatAll("Personne trouvé"); 
        return; 
    } 
    
int target cts[GetRandomInt(0count-1)]; 
    
PrintToChatAll("%N va siffler"target); 
    
float pos[3]; 
    
GetEntPropVector(targetProp_Send"m_vecOrigin"pos); 
    
EmitSoundToAll(")g_sSounds[GetRandomInt(0, sizeof(g_sSounds)-1)]"pos_g_cVarLevel.IntValue); 



bool IsValidClient(int client

    return 
client && client <= MaxClients && IsClientInGame(client); 

vegeta1241 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-22-2018 , 13:52   Re: improve my whistle script
Reply With Quote #14

Here. Keep practising
PHP Code:
#include <sdktools>

char samples[][] = 
{
    
"ideas/Whistle1.wav",
    
"ideas/Whistle2.wav"
}; 

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_whistle"Whistle);
    
RegConsoleCmd("sm_forcewhistle"ForceWhistle);
}

public 
void OnMapStart()
{
    
char buffer[PLATFORM_MAX_PATH];
    
int dot;

    for(
int a 0sizeof(samples); a++)
    {
        
dot FindCharInString(samples[a], '.'true);

        if( 
dot != -&& (StrEqual(samples[a][dot], ".wav"false) || StrEqual(samples[a][dot], ".mp3"false)) )
        {
        }
        else
        {
            
SetFailState("Invalid file '%s' "samples[a][dot]);
        }

        
Format(buffersizeof(buffer), "sound/%s"samples[a]);

        if(!
FileExists(buffertrue))
        {
            
SetFailState("File '%s' not exist"buffer);
        }


        
AddFileToDownloadsTable(buffer);

        
Format(buffersizeof(buffer), "~%s"samples[a]);
        
PrecacheSound(buffer);
    }
}

public 
Action Whistle(int clientint args)
{

    if( 
client == || !IsClientInGame(client) || !IsPlayerAlive(client)) return Plugin_Handled;

    if(
GetClientTeam(client) == 3)
    {
        
ReplyToCommand(client"[SM] You cant whistle as CT");
        return 
Plugin_Handled;
    }

    static 
float timestamps[MAXPLAYERS];
    
float timenow GetEngineTime();

    if(
timestamps[client] >= timenow)
    {
        
PrintToChat(client" \x02[SM] You need wait %.1f sec for next whistle"timestamps[client] - timenow);
        return 
Plugin_Handled;
    }

    
timestamps[client] = timenow 30.0;

    
char buffer[PLATFORM_MAX_PATH];
    
Format(buffersizeof(buffer), "~%s"samples[GetRandomInt(0sizeof(samples)-1)]);
    
EmitSoundToAll(bufferclient_SNDLEVEL_CONVO);

    
PrintToChatAll(" \x04[SM] ...%N whistled."client);

    return 
Plugin_Handled;
}

public 
Action ForceWhistle(int clientint args)
{

    if( 
client == || !IsClientInGame(client) || !IsPlayerAlive(client)) return Plugin_Handled;

    if(
GetClientTeam(client) == 2)
    {
        
ReplyToCommand(client"[SM] You cant force whistle as T");
        return 
Plugin_Handled;
    }


    
int[] targets = new int[MaxClients];
    
int count;

    for(
int i 1<= MaxClientsi++)
    {
        if( 
== client || !IsClientInGame(i) || !IsPlayerAlive(i) || GetClientTeam(i) != 2) continue;

        
targets[count++] = i;
    }

    if(
count == 0)
    {
        
PrintToChat(client"[SM] There is no alive players in another team to force whistle.");
        return 
Plugin_Handled;
    }

    
int victim targets[GetRandomInt(0count-1)];

    static 
float timestamps[MAXPLAYERS];
    
float timenow GetEngineTime();

    if(
timestamps[client] >= timenow)
    {
        
PrintToChat(client" \x02[SM] You need wait %.1f sec for next force whistle"timestamps[client] - timenow);
        return 
Plugin_Handled;
    }

    
timestamps[client] = timenow 30.0;



    
char buffer[PLATFORM_MAX_PATH];
    
Format(buffersizeof(buffer), "~%s"samples[GetRandomInt(0sizeof(samples)-1)]);
    
EmitSoundToAll(buffervictim_SNDLEVEL_CONVO);

    
PrintToChatAll(" \x04[SM] %N forced %N to whistle."clientvictim);

    return 
Plugin_Handled;

*edit
I used sound character '~', those seems use in footsteps.
__________________
Do not Private Message @me

Last edited by Bacardi; 11-22-2018 at 14:47. Reason: GetGameTime -> GetEngineTime
Bacardi is offline
vegeta1241
AlliedModders Donor
Join Date: Apr 2017
Location: Switzerland
Old 11-22-2018 , 14:19   Re: improve my whistle script
Reply With Quote #15

PHP Code:
#include <sourcemod>
#include <sdktools>

char g_sSounds[][] = 
{
    
")ideas/Whistle1.wav",
    
")ideas/Whistle2.wav"
};

ConVar g_cVarLevel;

bool HasWhistle[64];
bool HasForceWhistle[64];

public 
Plugin myinfo 
{
    
name "New Plugin",
    
author "Unknown",
    
description "<- Description ->",
    
version "1.0",
    
url "<- URL ->"
}

public 
void OnPluginStart()
{
    
g_cVarLevel CreateConVar("sm_whistle_level""70""Pitch whistle");
    
RegConsoleCmd("sm_whistle"Whistle);
    
RegConsoleCmd("sm_w"Whistle);
    
RegConsoleCmd("sm_forcewhistle"ForceWhistle);
    
RegConsoleCmd("sm_fw"ForceWhistle);
}

public 
void OnMapStart()
{
    for(
int i 0sizeof(g_sSounds); i++)
    {
        
char varchar[64];
        
Format(varchar64"sound/%s"g_sSounds[i]);
        
AddFileToDownloadsTable(varchar);
        
PrecacheSound(g_sSounds[i], true);
    }
}

public 
Action Whistle(int clientint args)
{
    
args 0;
    if(!
IsValidClient(client)) return Plugin_Handled;
    if(!
IsPlayerAlive(client)) return Plugin_Handled;
    if(
GetClientTeam(client) != 2)
    {
        
PrintToChat(client"[IDEAS] You cant whistle as SEEKER");
        return 
Plugin_Handled;
    }
    if(
HasWhistle[client])
    {
        
PrintToChat(client"[IDEAS] You have to wait to whistle again")
    }
    
    new 
Float:vecPos[3];
    
GetClientAbsOrigin(clientvecPos);
    
EmitSoundToAll(g_sSounds[GetRandomInt(0sizeof(g_sSounds)-1)], clientSNDCHAN_AUTOg_cVarLevel.IntValueSND_NOFLAGS1.0SNDPITCH_NORMAL, -1vecPosNULL_VECTORtrue0.0);
    
HasWhistle[client] = true;
    
CreateTimer(10.0WhistleAgainGetClientUserId(client));
    return 
Plugin_Handled;
}

public 
Action WhistleAgain(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    if(
IsValidClient(client))
    {
        
HasWhistle[client] = false;
    }
    
delete timer;
    return 
Plugin_Stop;
}

public 
Action ForceWhistle(int clientint args)
{
    
args 0;
    if(!
IsValidClient(client)) return Plugin_Handled;
    if(!
IsPlayerAlive(client)) return Plugin_Handled;
    if(
GetClientTeam(client) != 3)
    {
        
PrintToChat(client"[IDEAS] You cant force whistle as HIDER");
        return 
Plugin_Handled;
    }
    if(
HasForceWhistle[client])
    {
        
PrintToChat(client"[IDEAS] You have to wait to force whistle again");
        return 
Plugin_Handled;
    }
    
HasForceWhistle[client] = true;
    
CreateTimer(10.0ForceWhistleAgainGetClientUserId(client));
    
ForceRandomWhistle();
    return 
Plugin_Handled;
}

public 
Action ForceWhistleAgain(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    if(
IsValidClient(client))
    {
        
HasForceWhistle[client] = false;
    }
    
delete timer;
    return 
Plugin_Stop;
}

void ForceRandomWhistle()
{
    
int count 0cts[32];
    for(
int i 1<= MaxClientsi++)
    {
        if(
IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
        {
            
cts[count] = i;
            
count++;
        }
    }
    if(
count == 0)
    {
        
PrintToChatAll("[IDEAS] No HIDER found to force whistle");
        return;
    }
    
int target cts[GetRandomInt(0count-1)];
    
PrintToChatAll("[IDEAS] %N whistle"target);
    new 
Float:vecPos[3];
    
GetClientAbsOrigin(targetvecPos); 
    
EmitSoundToAll(g_sSounds[GetRandomInt(0sizeof(g_sSounds)-1)], targetSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGS1.0SNDPITCH_NORMAL, -1vecPosNULL_VECTORtrue0.0);
}


bool IsValidClient(int client)
{
    return 
client && client <= MaxClients && IsClientInGame(client);

FIXED !! THANK YOU FOR YOUR HELP !!!!
vegeta1241 is offline
vegeta1241
AlliedModders Donor
Join Date: Apr 2017
Location: Switzerland
Old 11-22-2018 , 14:29   Re: improve my whistle script
Reply With Quote #16

Your script run fine also, I take it and I add the cvar to up level when player is near another player and I like your colors for the time left
vegeta1241 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-22-2018 , 14:32   Re: improve my whistle script
Reply With Quote #17

your welcome
__________________
Do not Private Message @me
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-22-2018 , 14:49   Re: improve my whistle script
Reply With Quote #18

I update my last code... There were GetGameTime(), this actually reset back 0 after map change.
So you can't use whistle in loong time in the next map

I replaced with GetEngineTime()
__________________
Do not Private Message @me
Bacardi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode