This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[WRONG SECTION] Bomb Explode Code only On 1 player??


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Trippp
Member
Join Date: Jul 2015
Old 02-07-2016 , 05:10   [WRONG SECTION] Bomb Explode Code only On 1 player??
Reply With Quote #1

Hey guys Trippp again. Having some problem with my plugin again.
I made a plugin that for example plays a sound on bomb_explode.
You can disable/enable it by using cookies.
The only problem is that the code only executes for the player who planted the bomb?
I tried to resolve it by making a loop, but either that didn't work or I did it incorrect?

Code:
#include <sourcemod>
#include <sdktools>
#include <emitsoundany>
#include <colors>
#include <clientprefs>

new Handle:g_hDefuseSound;
new Handle:g_hHeadshotSound;
new Handle:g_hBombSound;

public OnMapStart()
{
    AddFileToDownloadsTable("sound/plugin/krakaka.mp3");
    AddFileToDownloadsTable("sound/plugin/zing.mp3");
    AddFileToDownloadsTable("sound/plugin/taunt.mp3");
    AddFileToDownloadsTable("sound/plugin/tirol.mp3");
    PrecacheSoundAny("*/plugin/krakaka.mp3");
    PrecacheSoundAny("*/plugin/zing.mp3");
    PrecacheSoundAny("*/plugin/taunt.mp3");
    PrecacheSoundAny("*/plugin/tirol.mp3");
}



public void OnPluginStart()
{
        g_hDefuseSound = RegClientCookie("defusesound_cookie", "Defuse Sound ON/OFF", CookieAccess_Public);
        g_hBombSound = RegClientCookie("bombsound_cookie", "Bomb Sound ON/OFF", CookieAccess_Public);
        g_hHeadshotSound = RegClientCookie("headshotsound_cookie", "Headshot Sound ON/OFF", CookieAccess_Public);
        HookEvent("player_death", Event_PlayerDeath, EventHookMode_Pre);
        HookEvent("bomb_exploded", Event_BombExploded);
        HookEvent("bomb_defused", Event_BombDefused);
        HookEvent("cs_win_panel_match", Event_MatchEnd);
        SetCookiePrefabMenu(g_hBombSound, CookieMenu_OnOff_Int, "Bomb Sound ON/OFF");
        SetCookiePrefabMenu(g_hDefuseSound, CookieMenu_OnOff_Int, "Defuse Sound ON/OFF");
        SetCookiePrefabMenu(g_hHeadshotSound, CookieMenu_OnOff_Int, "Headshot Sound ON/OFF");
}


public Action Event_BombExploded(Handle:event, const String:name[], bool:dontBroadcast)
{

    for(new i = 1; i <= MAXPLAYERS; i++)
    {

    int userid = GetEventInt(event, "userid");
    int client = GetClientOfUserId(userid);
    
    decl String:sBuffer[4];
    GetClientCookie(client, g_hBombSound, sBuffer, sizeof(sBuffer));
    if(StrEqual(sBuffer, "1") && IsValidClient(client))  
        EmitSoundToClientAny(client, "*/plugin/taunt.mp3");    
    
    return Plugin_Continue;
    }
}

Last edited by Trippp; 02-07-2016 at 05:14.
Trippp is offline
Trippp
Member
Join Date: Jul 2015
Old 02-07-2016 , 05:14   Re: [HELP] Bomb Explode Code only On 1 player??
Reply With Quote #2

Wrong Section..
Trippp is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 02-07-2016 , 05:27   Re: [HELP] Bomb Explode Code only On 1 player??
Reply With Quote #3

Quote:
Originally Posted by Trippp View Post
Wrong Section..
You can use the Report Button () to suggest that it would be moved to the right section.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 02-07-2016 , 05:46  
Reply With Quote #4

Maybe it should be like this:
PHP Code:
public Action Event_BombExploded(Handle:event, const String:name[], bool:dontBroadcast)
{

    for(new 
1<= MAXPLAYERSi++)
    {
        
decl String:sBuffer[4];
        if(
IsValidClient(i))
        {
            
GetClientCookie(ig_hBombSoundsBuffersizeof(sBuffer));
            if(
StrEqual(sBuffer"1"))
                
EmitSoundToClientAny(i"*/plugin/taunt.mp3");
        }
    }
    return 
Plugin_Continue;

__________________

Last edited by Grey83; 02-08-2016 at 15:51.
Grey83 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 21:02.


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