Raised This Month: $ Target: $400
 0% 

Ignoring (id) from a command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Speedy'
Member
Join Date: Jan 2009
Old 05-12-2010 , 06:23   Ignoring (id) from a command
Reply With Quote #1

This is for the Deathrace Mod. Original code, it executes user_silentkill to kill all the players when someone wins the round (the mod it's played only as a Counter-Terrorist), but i founded the Round Terminator plugin wich can make the round terminate without killing all the players. The problem is, how to ignore the player who wins the deathrace (Pressing the finish button, last man alive) so the command user_silentkill will have effect only the rest of the players? Heres the part of the code wich i'm talking about:
PHP Code:
    new Players[32
    new 
playerCountiplayerdr
    get_players
(PlayersplayerCount"a"
    
    for (
i=0i<playerCounti++) 
        {
        
playerdr Players[i]
        new 
frags get_pcvar_num(dr_winfrags)
        
set_user_frags(idget_user_frags(id) + frags) - how to ignore him(idfrom the bellow task
        user_silentkill
(playerdr) - this kills the players when the button it's pushed
    }

P.S I've already asked in the Mod topic, but the author didn't knew a method.
__________________
Sorry for my English
Speedy' is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 05-12-2010 , 09:23   Re: Ignoring (id) from a command
Reply With Quote #2

Make the function something like this:
PHP Code:
public ButtonUse(entid)
{
    if(
is_user_connected(id) && get_pcvar_num(dr_status))
    {        
        new 
target[32]
        
pev(entpev_targetnametarget31)
        
        if(
equal(target"winbut")) { // End-Button
            
            
new szName[32]
            
get_user_name(idszName31)
            
ChatColor(id"%L"LANG_PLAYER"WON"szName)
            
            
cs_set_user_deaths(idget_user_deaths(id) - 1);
            
ButtonUsed true
            
            
if(get_pcvar_num(dr_lives))
                
g_Respawns[id]++;
            if(
get_pcvar_num(dr_stats))
                
g_Wins[id]++;
                
            new 
Players[32
            new 
playerCountiplayerdr
            get_players
(PlayersplayerCount"a"
            
            for (
i=0i<playerCounti++) 
            {
                
playerdr Players[i]
                
set_user_frags(idget_user_frags(id) + get_pcvar_num(dr_winfrags))
                                if(
id)
                    return 
PLUGIN_HANDLED
                user_silentkill
(playerdr)
            }
        }
    }
    return 
PLUGIN_HANDLED

Try that.

Editing messed up indent. I'm too lazy to fix that.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-12-2010 , 16:07   Re: Ignoring (id) from a command
Reply With Quote #3

PHP Code:
public ButtonUse(entid)
{
    if(
is_user_connected(id) && get_pcvar_num(dr_status))
    {        
        new 
target[32]
        
pev(entpev_targetnametarget31)
        
        if(
equal(target"winbut")) { // End-Button
            
            
new szName[32]
            
get_user_name(idszName31)
            
ChatColor(id"%L"LANG_PLAYER"WON"szName)
            
            
cs_set_user_deaths(idget_user_deaths(id) - 1);
            
ButtonUsed true
            
            
if(get_pcvar_num(dr_lives))
                
g_Respawns[id]++;
            if(
get_pcvar_num(dr_stats))
                
g_Wins[id]++;
            
            
set_user_frags(idget_user_frags(id) + get_pcvar_num(dr_winfrags)) // shouldn't be inside the loop
                
            
new Players[32
            new 
playerCountiplayerdr
            get_players
(PlayersplayerCount"a"
            
            for (
i=0i<playerCounti++) 
            {
                
playerdr Players[i]
    
                if(
id != playerdr// player index from the list is not the winner player index
                    
user_silentkill(playerdr)
            }
        }
    }
    return 
PLUGIN_HANDLED

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Speedy'
Member
Join Date: Jan 2009
Old 05-12-2010 , 16:55   Re: Ignoring (id) from a command
Reply With Quote #4

@DarkGod - Wasn't working... the players weren't killed when the button was pressed.

Thank you Exolent[jNr]. It works like a charm ! Just another little problem: How can i set a delay for the +use command (because i set the server_cmd ( "amx_roundterminate ct" ) when the button it's pressed... so if the player is pressing multiple times.. not only that a new round doesn't begin, but the server it's flooded. Thank you again Exolent
__________________
Sorry for my English
Speedy' is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-12-2010 , 17:12   Re: Ignoring (id) from a command
Reply With Quote #5

Just use a global variable to check if the button was pressed already.
At every round start, set it to false.
Then when the button is pressed, check if it was pressed already.
If the variable is false, do your round end stuff and set the variable to true.
Otherwise, don't do anything.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


Thread Tools
Display Modes

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 03:40.


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