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

[CS:GO] Last player of a team ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-15-2015 , 13:19   [CS:GO] Last player of a team ?
Reply With Quote #1

I need a code that does something (example: Sets 200HP, armor,weapon...) to the last player of a team
more examples ?
PHP Code:
GivePlayerItem(client"weapon_something");
SetEntityHealth(client, ...69?); 
I can set what it does, but I don't know what triggers the last player of a team.
__________________

Last edited by valio_skull; 12-15-2015 at 14:13. Reason: CS:GO tag...
valio_skull is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 12-15-2015 , 14:07   Re: Last player of a team ?
Reply With Quote #2

What game would this be for?

Last edited by Phil25; 12-15-2015 at 14:07.
Phil25 is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-15-2015 , 14:13   Re: Last player of a team ?
Reply With Quote #3

Quote:
Originally Posted by Phil25 View Post
What game would this be for?
CS:GO, I will edit in title
Edit:edited
__________________

Last edited by valio_skull; 12-15-2015 at 14:14.
valio_skull is offline
ESK0
BANNED
Join Date: May 2014
Location: Czech Republic
Old 12-15-2015 , 14:42   Re: [CS:GO] Last player of a team ?
Reply With Quote #4

Why you dont try to get it on your own instead of spamming forum ?
ESK0 is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-15-2015 , 14:49   Re: [CS:GO] Last player of a team ?
Reply With Quote #5

Quote:
Originally Posted by ESK0 View Post
Why you dont try to get it on your own instead of spamming forum ?
I can't get on my own what I don't know...
and that's why this section exist, for helping people with coding, am I right ?
I want to make an survivor plugin for furien, so the last man standong on a team gets some hp, armor, maybe weapon and an awesome model
__________________
valio_skull is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 12-15-2015 , 15:42   Re: [CS:GO] Last player of a team ?
Reply With Quote #6

1. Hook player death event - easy to google
2. Get player (lets name him Rambo) from that event - easy to google, have a look at SM scripting wiki
3. Count players in Rambo's team (end here if Rambo wasn't T or CT) - easy to do, many plugins do that (or at least loop players)
4. If players count is 1 then continue, otherwise end here
5. Get last living player of Rambo's team (you can do this when you are counting players - step 3)
6. Do something with that last player (like set health, weapons etc.) - you already know this
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.

Last edited by KissLick; 12-15-2015 at 15:44.
KissLick is offline
ESK0
BANNED
Join Date: May 2014
Location: Czech Republic
Old 12-15-2015 , 15:47   Re: [CS:GO] Last player of a team ?
Reply With Quote #7

Quote:
Originally Posted by valio_skull View Post
I can't get on my own what I don't know...
and that's why this section exist, for helping people with coding, am I right ?
I want to make an survivor plugin for furien, so the last man standong on a team gets some hp, armor, maybe weapon and an awesome model
How can we see. You don't know nothing.. just asking people instead of trying and thinking about how it could works.. Im right ? let me know if im isnt.

Anyway KillLick told you exact way how to do this.. but you will create new topic because you dont know how to loop clients.. so. You should start learning SP with editing not with creating whole gamemode.. That's my advice.. this is not good way how to learn.
ESK0 is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-15-2015 , 16:11   Re: [CS:GO] Last player of a team ?
Reply With Quote #8

Quote:
Originally Posted by KissLick View Post
1. Hook player death event - easy to google
2. Get player (lets name him Rambo) from that event - easy to google, have a look at SM scripting wiki
3. Count players in Rambo's team (end here if Rambo wasn't T or CT) - easy to do, many plugins do that (or at least loop players)
4. If players count is 1 then continue, otherwise end here
5. Get last living player of Rambo's team (you can do this when you are counting players - step 3)
6. Do something with that last player (like set health, weapons etc.) - you already know this
Quote:
Originally Posted by ESK0 View Post
How can we see. You don't know nothing.. just asking people instead of trying and thinking about how it could works.. Im right ? let me know if im isnt.

Anyway KillLick told you exact way how to do this.. but you will create new topic because you dont know how to loop clients.. so. You should start learning SP with editing not with creating whole gamemode.. That's my advice.. this is not good way how to learn.
Thanks, I can get this working tomorrow if I have time, and maybe I'll post it here
__________________
valio_skull is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 12-15-2015 , 16:53   Re: [CS:GO] Last player of a team ?
Reply With Quote #9

Not going to spoon feed you, but here is something I have in one of my plugins.

Have fun

PHP Code:
stock void CheckLastCT()
{
    if(
GetTeamClientCount(3) < 2)
    {
        return;
    }
    
    
int CTs 0Ts 0TsTotalHP 0;
    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i) && GetClientTeam(i) == && IsPlayerAlive(i))
        {
            
Ts++;
            
TsTotalHP += GetClientHealth(i);
        }
        if(
IsClientInGame(i) && GetClientTeam(i) == && IsPlayerAlive(i))
        {
            
CTs++;
            
lastCT i;
        }
    }
    if(
CTs != 1)
    {
        return;
    }
    
    if(
Ts == 1)
    {
        return;
    }
    if(
lastCT == 0)
    {
        return;
    }
    
    
int ctHealth GetClientHealth(lastCT);
    
int multiplier = (TsTotalHP/100) * 30;
    
    if(
multiplier >= 700)
    {
        
ctHealth 700;
    }
    
    if(
TsTotalHP 100 && Ts && multiplier 700)
    {
        
ctHealth += multiplier;
    }
    
    
LastGuardActive true;
    
ServerCommand("sm_beacon #%i"GetClientUserId(lastCT));
    
SetEntityHealth(lastCTctHealth);
    
CPrintToChatAll("[{blue}Jail{default}] Setting last guard's health to {green}%i{default} ({darkred}%i{default} prisoners with {purple}%i{default} health)"ctHealthTsTsTotalHP);
    
CPrintToChatAll("[{blue}Jail{default}]{green} %N is last ct!"lastCT);
    
CPrintToChatAll("[{blue}Jail{default}]{green} %N is last ct!"lastCT);
    
    
PrintHintTextToAll("%N is last ct! <font color='#00FF00'>Health:</font> <font color='#FF0000'>%i</font>"lastCTctHealth);

    
SetEntityRenderColor(lastCT25520147255);
    
    return;

Addicted. is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 12-19-2015 , 16:43   Re: [CS:GO] Last player of a team ?
Reply With Quote #10

Ok, I was busy some time, but now I got this:
PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

#define PLUGIN_VERSION "X"
#define MAX_FILE_LEN 80

public Plugin:myinfo 
{
    
name "Privat",
    
author "Mado",
    
description "none",
    
version PLUGIN_VERSION,
    
url "."
};

public 
OnPluginStart()
{
    
HookEvent("player_death"EventPlayerDeath);
}

public 
EventPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victimId GetEventInt(event"userid");

    new 
victimClient GetClientOfUserId(victimId);

    new 
killedTeam GetClientTeam(victimClient);

    new 
playersConnected GetMaxClients();

    new 
lastManId 0;
    for (new 
1playersConnectedi++)
    {
        if(
IsClientInGame(i))
        {
            if(
killedTeam==GetClientTeam(i) && IsPlayerAlive(i))
            {
                if(
lastManId)
                {
                    
lastManId = -1;
                } else {
                    
lastManId i;
                }
            }
        }
    }

    if(
lastManId 0)
    {
        new 
String:clientname[64];
        
GetClientName(lastManIdclientnamesizeof(clientname));
        if(
GetClientTeam(client) == CS_TEAM_T)
        {
            
PrintHintTextToAll("<font color='#ff0000'><b>%s is now a Survivor!</b></font>"clientname);
        }
        if(
GetClientTeam(client) == CS_TEAM_CT)
        {
            
PrintHintTextToAll("<font color='#0000ff'><b>%s is now a Survivor!</b></font>"clientname);
        }
    }


But...I don't know how to add "client"...
__________________
valio_skull is offline
Reply



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 11:29.


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