AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   How to give attributes / perks to the last guy alive on a singular team. (https://forums.alliedmods.net/showthread.php?t=296692)

cigzag 04-26-2017 21:00

How to give attributes / perks to the last guy alive on a singular team.
 
Title says it, I just need to know how (This includes mini crits, longer range or something)

Also, why doesnt this work?

public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
if (GetPlayerCount() == 1)
{
for(new i = 1; i <= MaxClients; i++)
{
if(IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
{
CPrintToChatAll("{red}%N is getting an boost!", i);
ServerCommand("sm_givew_ex @red 8001");
ServerCommand("sm_givew @red 8001");
}
}
}
}

On TF2 ^^^ Last guy on red team should get that weapon

africanspacejesus 04-26-2017 22:26

Re: How to give attributes / perks to the last guy alive on a singular team.
 
Are you using a plugin that already allows some clients to have these "perks"

cigzag 04-26-2017 23:33

Re: How to give attributes / perks to the last guy alive on a singular team.
 
Quote:

Originally Posted by africanspacejesus (Post 2516025)
Are you using a plugin that already allows some clients to have these "perks"

Not exactly.

cigzag 04-28-2017 20:46

Re: How to give attributes / perks to the last guy alive on a singular team.
 
????? Can someone help me?

shanapu 04-28-2017 21:06

Re: How to give attributes / perks to the last guy alive on a singular team.
 
Quote:

Originally Posted by SnowTigerVidz (Post 2516009)
Title says it, I just need to know how (This includes mini crits, longer range or something)

Also, why doesnt this work?

[CODE]

On TF2 ^^^ Last guy on red team should get that weapon

please don't bump your threads.
I think this question belongs to the scripting section.
Maybe take a second look at the forum rules

please put your code in [php][/php]-tags for better readabilty.

you should show us the full code or all necessary code parts for this function.

I assume your problem is: the function don't fire cause GetPlayerCount count all players (maybe even alive) and not only from team red. But I don't know how your GetPlayerCount works.

But this should do the job:
PHP Code:

public void OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath);
}

public 
Action Event_PlayerDeath(Handle eventchar [] namebool dontBroadcast)
{
    if (
GetAlivePlayersCount(2) == 1)
    {
        for(
int i 1<= MaxClientsi++)
        {
            if(
IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == 2)
            {
                
PrintToChatAll("{red}%N is getting an boost!"i);
                
ServerCommand("sm_givew_ex @red 8001");
                
ServerCommand("sm_givew @red 8001");
            }
        }
    }
}

int GetAlivePlayersCount(int team)
{
    
int iCountiiCount 0;

    for (
1<= MaxClientsi++)
        if (
IsValidClient(i) && IsPlayerAlive(i) && GetClientTeam(i) == team)
        
iCount++;

    return 
iCount;
}

bool IsValidClient(int client)
{
    if(
client && client <= MaxClients && IsClientInGame(client))
    {
        return 
true;
    }
    return 
false;




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

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