AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check team's on round end - problem (https://forums.alliedmods.net/showthread.php?t=241098)

krysteksulek 05-27-2014 18:46

Check team's on round end - problem
 
Hi.
I want to make a plugin, which will play sound for winning and loosing team (2 different sound's).
So i made that code:

Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Test"
#define VERSION "1.0"
#define AUTHOR "Test"


public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_event("SendAudio", "event_roundend_t", "a", "2&%!MRAD_terwin")
    register_event("SendAudio", "event_roundend_ct", "a", "2&%!MRAD_ctwin")
}

public plugin_precache()
{
    precache_sound("misc/win.mp3")
    precache_sound("misc/lose.mp3")

}
public event_roundend_t(id)
{
    if (get_user_team(id) == 2)
    {   
        //client_cmd(id, "mp3 play sound/misc/lose")
        client_print(id,print_center, "You are CT")
    }
    if ((get_user_team(id) == 1))
    {   
        //client_cmd(id, "mp3 play sound/misc/win")
        client_print(id,print_center, "You are TT")
    }
}
public event_roundend_ct(id)
{
    if (get_user_team(id) == 1)
    {   
        //client_cmd(id, "mp3 play sound/misc/lose")
        client_print(id,print_center, "You are CT")
    }
    if ((get_user_team(id) == 2))
    {   
        //client_cmd(id, "mp3 play sound/misc/win")
        client_print(id,print_center, "You are TT")
    }
}

When i'm not chcecking team's, sound/print is working, but when i'm doing it, nothing happens (and not error's). I also tried with cs_get_user_team, but same effect.

I tried to save checking team's on spawn, and then add it to MRAD, but nothing:

Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN "Test"
#define VERSION "1.0"
#define AUTHOR "Test"

new CsTeams:xTeam[33]


public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_event("SendAudio", "event_roundend_t", "a", "2&%!MRAD_terwin")
    //register_event("SendAudio", "event_roundend_ct", "a", "2&%!MRAD_ctwin")
   
    RegisterHam(Ham_Spawn, "player", "Spawn", 1);
}

public plugin_precache()
{
    precache_sound("misc/win.mp3")
    precache_sound("misc/lose.mp3")

}
public event_roundend_t(id)
{
    if(is_user_connected(id) && xTeam[id] == CS_TEAM_T)
    {   
        //client_cmd(id, "mp3 play sound/misc/win")
        client_print(id,print_center, "Jestes TT")
    }
}
public Spawn(id)
{
    xTeam[id] = cs_get_user_team(id)
    if(is_user_connected(id) && xTeam[id] == CS_TEAM_T)
    client_print(id, print_chat, "You're terro");
}

Any ideas? Maybe you know another way to play 2 different sound's when any team lose or win?

aron9forever 05-28-2014 00:24

Re: Check team's on round end - problem
 
Code:
new whichsound = random_num(1,2) switch(whichsound) { case 1: case 2: }

for 2 random sounds

im not sure about those events tho, what I'd do is count the players on the round end myself and determine the winning team
Code:
new countt = 0, countct = 0         new iPlayers[32];         new iNum;         new player;         get_players( iPlayers, iNum )         for( new i = 0; i < iNum; i++ )         {             player = iPlayers[i]             if(cs_get_user_team(player)==CS_TEAM_T)             countt=countt+1             else if(cs_get_user_team(player)==CS_TEAM_CT)             countct=countct+1         } if(!countct) { //cts win } else if(!coutt) { //ts win }


All times are GMT -4. The time now is 09:48.

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