AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   checking for last player (https://forums.alliedmods.net/showthread.php?t=113038)

Zombiezzz 12-23-2009 00:07

checking for last player
 
I need a code that checks for last player alive. Like it gives he last player alive a M249 but it wouldnt work if there are only 4 people in the server.
Crab if you help :crab:

hectorz0r 12-23-2009 00:20

Re: checking for last player
 
...

Zombiezzz 12-23-2009 00:21

Re: checking for last player
 
thats not realy what im looking for.

Bugsy 12-23-2009 09:00

Re: checking for last player
 
Quote:

Originally Posted by Zombiezzz (Post 1027850)
thats not realy what im looking for.

If you used it properly then it would work just fine.

Zombiezzz 12-23-2009 11:40

Re: checking for last player
 
ill see what i can do :S ty hecktor

so your plugin has this.
PHP Code:

public GetLastPlayer( &iTerrorist , &iCT )
{
    new 
iPlayers32 ] , iNum iPlayer;
 
    
iTerrorist = -1;
    
iCT = -1;
 
    
get_playersiPlayers iNum );
 
    for ( new 
iNum i++ )
    {
        
iPlayer iPlayers];
 
        if ( 
is_user_aliveiPlayer ) )
        {
            switch ( 
get_user_teamiPlayer ) )
            {
                case 
1iTerrorist = ( iTerrorist == -) ? iPlayer 0;
                case 
2iCT = ( iCT == -) ? iPlayer 0;
            }
        }
    }


would it work if i do this?
PHP Code:

public GetLastPlayer( &iTerrorist , &iCT )
{
    new 
iPlayers32 ] , iNum iPlayer;
 
    
iTerrorist = -1;
    
iCT = -1;
    
get_playersiPlayers iNum );
    for ( new 
iNum i++ )
    {
        
iPlayer iPlayers];
 
        if ( 
is_user_aliveiPlayer ) )
        {
                 
give_item(id,, "weapon_m249")
        }
    }



hectorz0r 12-23-2009 13:12

Re: checking for last player
 
...

Bugsy 12-24-2009 09:11

Re: checking for last player
 
This will check if only one player is remaining and if so give him m249. You can add a hook to DeathMsg or Ham_Killed and call GiveM249() from within. (untested)
PHP Code:

public GiveM249()
{
    new 
iT iCT ;
    
    
GetLastPlayeriT iCT );
    
    if ( ( 
iT ) && ( iCT == -) )
        
give_itemiT "weapon_m249");
    else if ( ( 
iCT ) && ( iT == -) )
        
give_itemiCT "weapon_m249");
}

public 
GetLastPlayer( &iTerrorist , &iCT )
{
    new 
iPlayers32 ] , iNum iPlayer;
    
    
iTerrorist = -1;
    
iCT = -1;

    
get_playersiPlayers iNum );

    for ( new 
iNum i++ )
    {
        
iPlayer iPlayers];
        
        if ( 
is_user_aliveiPlayer ) )
        {
            switch ( 
get_user_teamiPlayer ) )
            {
                case 
1iTerrorist = ( iTerrorist == -) ? iPlayer 0;
                case 
2iCT = ( iCT == -) ? iPlayer 0;
            }
        }
    }



Zombiezzz 12-24-2009 13:36

Re: checking for last player
 
ty :P


All times are GMT -4. The time now is 04:15.

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