AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ignoring (id) from a command (https://forums.alliedmods.net/showthread.php?t=126659)

Speedy' 05-12-2010 06:23

Ignoring (id) from a command
 
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.

DarkGod 05-12-2010 09:23

Re: Ignoring (id) from a command
 
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.

Exolent[jNr] 05-12-2010 16:07

Re: Ignoring (id) from a command
 
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



Speedy' 05-12-2010 16:55

Re: Ignoring (id) from a command
 
@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 :)

Exolent[jNr] 05-12-2010 17:12

Re: Ignoring (id) from a command
 
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.


All times are GMT -4. The time now is 03:40.

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