Raised This Month: $12 Target: $400
 3% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cigzag
AlliedModders Donor
Join Date: Nov 2014
Location: NZ
Old 04-26-2017 , 21:00   How to give attributes / perks to the last guy alive on a singular team.
Reply With Quote #1

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

Last edited by cigzag; 04-27-2017 at 05:42.
cigzag is offline
africanspacejesus
Senior Member
Join Date: Nov 2016
Location: Bay Area, CA
Old 04-26-2017 , 22:26   Re: How to give attributes / perks to the last guy alive on a singular team.
Reply With Quote #2

Are you using a plugin that already allows some clients to have these "perks"
__________________
Taking paid plugin requests
africanspacejesus is offline
cigzag
AlliedModders Donor
Join Date: Nov 2014
Location: NZ
Old 04-26-2017 , 23:33   Re: How to give attributes / perks to the last guy alive on a singular team.
Reply With Quote #3

Quote:
Originally Posted by africanspacejesus View Post
Are you using a plugin that already allows some clients to have these "perks"
Not exactly.
cigzag is offline
cigzag
AlliedModders Donor
Join Date: Nov 2014
Location: NZ
Old 04-28-2017 , 20:46   Re: How to give attributes / perks to the last guy alive on a singular team.
Reply With Quote #4

????? Can someone help me?
cigzag is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 04-28-2017 , 21:06   Re: How to give attributes / perks to the last guy alive on a singular team.
Reply With Quote #5

Quote:
Originally Posted by SnowTigerVidz View Post
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;

__________________
coding & free software

Last edited by shanapu; 04-28-2017 at 21:08. Reason: typos
shanapu 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 13:50.


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