AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   last players (https://forums.alliedmods.net/showthread.php?t=243176)

pob18 06-30-2014 15:55

last players
 
Hi, I need a function that will do some fun when at the round stays 2 players,
play some sounds/etc when one wins

Porta0123 06-30-2014 16:30

Re: last players
 
i think this will works but im not sure....
Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "Play sound" #define VERSION "1.0" #define AUTHOR "Porta0123" new bool:are_2players = false public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event( "DeathMsg" , "DeathMsgEvent" , "a" ); } public DeathMsgEvent() {     new pnum     new players[32], tempid;     new count = 0         get_players(players, pnum);         for(new i=0; i < pnum; i++)     {         tempid = players[i];                 if(is_user_alive(tempid))         {         count++         }     }         if(are_2players == true)     {         are_2players = false         //here the sounds etc...     }       if(count == 2)     dosound() } public dosound() {     set_hudmessage(255, 0, 0, -1.0, -1.0, 0, 6.0, 12.0)     show_hudmessage(0, "1 vs 1")     are_2players = true         //here you can add one sound like "you are alone" or something... }

Freezo Begin 06-30-2014 16:55

Re: last players
 
Code:
#include <amxmodx> public plugin_init() {     register_plugin("Last 2 players", "1.0", "Freezo")         register_event( "DeathMsg" , "DeathMsgEvent" , "a" ); } public DeathMsgEvent() {     new players[ 32 ], iNum       get_players( players, iNum, "ach" )           if( iNum == 2 )     {         for ( new i=0,id ; i < iNum ; i++ )         {             id = players[ i ]             // Do your stuf         }     } }

Flick3rR 06-30-2014 17:07

Re: last players
 
Freezo, if the two players are from the same team?
(Also, it's not good to post ready codes in scripting help. Let them do it theirself ;))

NikKOo31 06-30-2014 17:17

Re: last players
 
Hey Flick3rR
What about mine? xD

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Play sound"
#define VERSION "2.0"
#define AUTHOR "Porta0123"

new const my_sound[] = "jbextreme/nm_goodbadugly.wav"
new bool:duel

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event"DeathMsg" "DeathMsgEvent" "a" );
}

public 
plugin_precache()
{
    
precache_sound(my_sound)
}

public 
DeathMsgEvent()
{
    new 
pnumplayers[32]
    
get_players(playerspnum"a"//get all alive players

    
if(duel && pnum == 1)    //duel ended
    
{
        
duel false
        duelends
(players[0]) //show who won :)
    
}
    else
    {
        if(
pnum == 2//only 2 alives?
        
{
            if(
get_user_team(players[0]) != get_user_team(players[1])) //diferent team?
            
{
                
duel true    // duel started!
                
duelstart(players[0], players[1]) //show who vs who
            
}
        }
        else
        {
            
duel false
        
}
    }
}

stock duelstart(id1id2)
{
    if(
id1 && id2)
    {
        new 
name1[32], name2[32]
        
get_user_name(id1name131)
        
get_user_name(id2name231)
        
        
set_hudmessage(25500, -1.0, -1.006.012.0)
        
show_hudmessage(0"%s vs %s"name1name2)
        
emit_sound(0CHAN_AUTOmy_sound1.0ATTN_NORM0PITCH_NORM)
    }
}

stock duelends(id)
{
    if(
id)
    {
        new 
name1[32]
        
get_user_name(idname131)
        
        
set_hudmessage(25500, -1.0, -1.006.012.0)
        
show_hudmessage(0"%s wons"name1)
        
//emit_sound(0, CHAN_AUTO, my_sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
    
}


I can't upload the sound but can be downloaded from jbextreme resources

Freezo Begin 06-30-2014 17:17

Re: last players
 
Quote:

Originally Posted by Flick3rR (Post 2159953)
Freezo, if the two players are from the same team?

yes i know what i have done ! because he didn't give enough information !

Flick3rR 06-30-2014 17:26

Re: last players
 
Yup, I think nikko's one is good enough (it will be strange if I say "Ahh sh*t it's AWESOME", right?). There could be added more funny stuff (I'm thinking about some Mortal Kombat sounds :D). Also, Nikko, there are some stuff you can do in your code (redundant or could be improved.) Mainly that emit_sound, will be better with spk.

pob18 06-30-2014 21:04

Re: last players
 
sorry for no info, when 2 players stay alive (ct and tt), show message/stuff who won

Porta0123 07-01-2014 09:33

Re: last players
 
if the 2 players are in the same team and there are 2 players thats means that the round its ended , Freezo Begin and mine are correct, i think

or add this:

Code:
register_event("HLTV", "event_new_round", "a", "1=0", "2=0")

and then:
Code:
public event_new_round() { are_2players = false }


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

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