Raised This Month: $ Target: $400
 0% 

[CS:GO] My survivor plugin isn't fair at all


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 10-25-2016 , 17:13   [CS:GO] My survivor plugin isn't fair at all
Reply With Quote #1

Hello everyone! So I have this "Survivor" plugin witch gives some bonuses to the last player alive of a team.
PHP Code:
#
#define MAX_FILE_LEN 80

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));
        new 
MaxHealth GetConVarInt(cvarAmount);
        
SetEntData(lastManIdFindDataMapOffs(lastManId"m_iMaxHealth"), MaxHealth4true);
        
SetEntData(lastManIdFindDataMapOffs(lastManId"m_iHealth"), MaxHealth4true);
        if(
GetClientTeam(lastManId) == CS_TEAM_T)
        {
            
// T Bonuses
        
}
        if(
GetClientTeam(lastManId) == CS_TEAM_CT)
        {
            
// CT Bonuses
        
}
    }

But in a situation where there are 2 CT and 1 T, it is unfair for the terrorist but the plugin makes it even MORE UNFAIR. The terrorist doesn't spawn as a survivor and when he kills a CT, the other one becomes a Survivor, so a normal HP terrorist has to fight a 500 HP Survivor CT (that 500 HP comes from the bonuses, this isn't normal casual/competitive gamemode)...

When there's only one player in a team at the beginning of the round, I want that player to become a survivor or to spawn as a survivor.
__________________

Last edited by valio_skull; 10-25-2016 at 17:14.
valio_skull is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 10-26-2016 , 10:44   Re: [CS:GO] My survivor plugin isn't fair at all
Reply With Quote #2

try use somthing like
PHP Code:
#include <cstrike>

new teamSize[4];
new 
aliveNum[4];

public 
OnPluginStart()
{
    
HookEvent("player_death"EventPlayerDeath);
    
HookEvent("player_spawn"EventPlayerSpawn);
    
HookEvent("player_team"EventPlayerTeam);
}

public 
OnMapStart()
{
    
teamSize = {0000};
    
aliveNum = {0000};
}

public 
OnClientDisconnect(client)
{
    new 
team GetClientTeam(client);
    if(
team 2) return;

    
aliveNum[team]--;
    if(
aliveNum[team] == 1OnLastMan(team);
}

public 
EventPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
team GetClientTeam(GetClientOfUserId(GetEventInt(event"userid")));
    if(
team 2) return;

    
aliveNum[team]--;
    if(
aliveNum[team] == 1OnLastMan(team);
}

public 
EventPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
oldTeam GetEventInt(event"oldteam");
    if(
oldTeam 1teamSize[oldTeam]--;
    new 
newTeam GetEventInt(event"team");
    if(
newTeam 1teamSize[newTeam]++;
}

public 
EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
team GetClientTeam(GetClientOfUserId(GetEventInt(event"userid")));
    if(
team 1aliveNum[team]++;
}

OnLastMan(const team)
{
    if(
aliveNum[team 3] < 2) return;
    new 
playersConnected MaxClients;
    new 
lastManId;
    for (new 
1playersConnectedi++)
    {
        if(
IsClientInGame(i) && IsPlayerAlive(i) && team == GetClientTeam(i))
        {
            
lastManId i;
            break;
        }
    }

    if(
lastManId 0)
    {
        new 
String:clientname[64];
        
GetClientName(lastManIdclientnamesizeof(clientname));
        new 
MaxHealth GetConVarInt(cvarAmount);
        
SetEntProp(lastManIdProp_Data"m_iMaxHealth"MaxHealth);
        
SetEntProp(lastManIdProp_Data"m_iHealth"MaxHealth);

        if(
team == CS_TEAM_T)
        {
            
// T Bonuses
        
}
        else
        {
            
// CT Bonuses
        
}
    }

__________________

Last edited by Grey83; 10-27-2016 at 08:51.
Grey83 is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 10-26-2016 , 14:52   Re: [CS:GO] My survivor plugin isn't fair at all
Reply With Quote #3

Quote:
Originally Posted by Grey83 View Post
try use somthing like
I have to wait until tomorrow to test it, I don't have a hosted server right now. I'll tell you if it works, thank you.
__________________
valio_skull is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 10-28-2016 , 13:00   Re: [CS:GO] My survivor plugin isn't fair at all
Reply With Quote #4

I just noticed that I already have a plugin that gives you other bonuses when you spawn...The survivor plugin can't give you those bonuses when you spawn unless you create a timer that gives you the bonuses 10 seconds after you spawn...It sounds a lot more complicated to me -.-
__________________
valio_skull is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 10-29-2016 , 07:53   Re: [CS:GO] My survivor plugin isn't fair at all
Reply With Quote #5

Just do
PHP Code:
if(team == CS_TEAM_T)
        {
            
// T Bonuses
            
CreateTimer(10.0Timer_TBonusesGetClientSerial(lastManId));
        }
        else
        {
            
// CT Bonuses
            
CreateTimer(10.0Timer_CTBonuseslastManId);
        } 
after that do
PHP Code:
Public Action:Timer_TBonuses(Handle:timerany:clientSerial)
{
    new 
client GetClientFromSerial(clientSerial);
    if(
client)
    {
        
// Give TBonuses
    
}
}

Public 
Action:Timer_CTBonuses(Handle:timerany:clientSerial)
{
    new 
client GetClientFromSerial(clientSerial);
    if(
client)
    {
        
// Give CTBonuses
    
}

__________________

Last edited by Grey83; 10-29-2016 at 07:55.
Grey83 is offline
valio_skull
Senior Member
Join Date: Jan 2013
Location: at home
Old 10-29-2016 , 11:28   Re: [CS:GO] My survivor plugin isn't fair at all
Reply With Quote #6

Now this plugin is a huge mess. It gets a lot of compilation errors and idk how to fix them.
Here's the whole .sp, I think that would help more than giving you a part of it.

PHP Code:
#include <sourcemod>
#include <cstrike>
#include <clientprefs>
#include <sdktools>
#include <sdkhooks>

#pragma semicolon 1

#define PLUGIN_VERSION "X"
#define MAX_FILE_LEN 80

new Handle:cvarAmount;
new 
teamSize[4];
new 
aliveNum[4];

stock Client_GiveWeaponAndAmmo(client, const String:className[], bool:switchTo=trueprimaryAmmo=-1secondaryAmmo=-1primaryClip=-1secondaryClip=-1); 

stock Client_RemoveAllWeapons(client, const String:exclude[]=""bool:clearAmmo=false);


public 
OnPluginStart()
{
    
cvarAmount CreateConVar("sm_survivor_maxhp""500""Survivor's MAX health"FCVAR_PLUGINtrue1.0false_);
    
HookEvent("player_death"EventPlayerDeath);
    
HookEvent("player_spawn"EventPlayerSpawn);
    
HookEvent("player_team"EventPlayerTeam);
}

public 
OnMapStart()
{
    
teamSize = {0000};
    
aliveNum = {0000};

    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/belt.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/belt.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/belt_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/eyes.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/eyes.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/gloves.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/gloves.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/gloves_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/hands.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/hands.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/hands_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/hair.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/hair.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/hair_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/head_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/magnum.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/magnum.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/magnum_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/pants.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/pants.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/pants_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/shirt.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/shirt.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/shirt_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/shoes.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/shoes.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/shoes_n.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/upperbody.vmt");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/upperbody.vtf");
    
AddFileToDownloadsTable("materials/models/player/custom_player/walkingdead/rickgrimes/upperbody_n.vtf");

    
AddFileToDownloadsTable("models/player/custom_player/walkingdead/rickgrimes/rick_v2.dx90.vtx");
    
AddFileToDownloadsTable("models/player/custom_player/walkingdead/rickgrimes/rick_v2.mdl");
    
AddFileToDownloadsTable("models/player/custom_player/walkingdead/rickgrimes/rick_v2.phy");
    
AddFileToDownloadsTable("models/player/custom_player/walkingdead/rickgrimes/rick_v2.vvd");

    
PrecacheModel("models/player/custom_player/walkingdead/rickgrimes/rick_v2.mdl");
}

public 
OnClientDisconnect(client)
{
    new 
team GetClientTeam(client);
    if(
team 2) return;

    
aliveNum[team]--;
    if(
aliveNum[team] == 1OnLastMan(team);
}

public 
EventPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
team GetClientTeam(GetClientOfUserId(GetEventInt(event"userid")));
    if(
team 2) return;

    
aliveNum[team]--;
    if(
aliveNum[team] == 1OnLastMan(team);
}

public 
EventPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
oldTeam GetEventInt(event"oldteam");
    if(
oldTeam 1teamSize[oldTeam]--;
    new 
newTeam GetEventInt(event"team");
    if(
newTeam 1teamSize[newTeam]++;
}

public 
EventPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
team GetClientTeam(GetClientOfUserId(GetEventInt(event"userid")));
    if(
team 1aliveNum[team]++;
}

OnLastMan(const team)
{
    if(
teamSize[team 3] < 2) return;
    new 
playersConnected MaxClients;
    new 
lastManId;
    for (new 
1playersConnectedi++)
    {
        if(
IsClientInGame(i) && IsPlayerAlive(i) && team == GetClientTeam(i))
        {
            
lastManId i;
            break;
        }
    }

    if(
team == CS_TEAM_T)
    {
        
// T Bonuses
        
CreateTimer(10.0Timer_TBonusesGetClientSerial(lastManId));
    }
    else
    {
        
// CT Bonuses
        
CreateTimer(10.0Timer_CTBonuseslastManId);
    }  
}  

stock StripAllWeapons(lastManId)
{
    new 
iEnt;
    for (new 
0<= 4i++)
    {
        while ((
iEnt GetPlayerWeaponSlot(lastManIdi)) != -1)
        {
            
RemovePlayerItem(lastManIdiEnt);
            
AcceptEntityInput(iEnt"Kill");
        }
    }
}  

public 
Action:Timer_Weapon(Handle:TimerlastManId)
{
    
GivePlayerItem(lastManId"weapon_xm1014");
    return 
Plugin_Stop;
}

Public 
Action:Timer_TBonuses(Handle:timerany:clientSerial)
{
    new 
client GetClientFromSerial(clientSerial);
    if(
client)
    {
        
PrintHintTextToAll("<font color='#ff0000'><b>%s is now Kage!</b></font>"clientname);
        
SetEntProp(lastManIdProp_Send"m_ArmorValue"1004);
        
SetEntProp(lastManIdProp_Send"m_bHasHelmet"1);
        
SetEntityGravity(lastManId0.3);
        
SetEntPropFloat(lastManIdProp_Data"m_flLaggedMovementValue"2.5);
        
SetEntityHealth(lastManId500);
    }
}

Public 
Action:Timer_CTBonuses(Handle:timerany:clientSerial)
{
    new 
client GetClientFromSerial(clientSerial);
    if(
client)
    {
        
PrintHintTextToAll("<font color='#00ffff'><b>%s is now Psycho!</b></font>"clientname);
        
SetEntityModel(lastManId"models/player/custom_player/walkingdead/rickgrimes/rick_v2.mdl");
        
SetEntProp(lastManIdProp_Send"m_ArmorValue"1004);
        
SetEntityGravity(lastManId0.6);
        
SetEntPropFloat(lastManIdProp_Data"m_flLaggedMovementValue"1.6);
        
StripAllWeapons(lastManId);
        
GivePlayerItem(lastManId"weapon_p90");
        
GivePlayerItem(lastManId"weapon_knife");
        
SetEntityHealth(lastManId300);
        
CreateTimer(0.5Timer_Weapon_TIMER_DATA_HNDL_CLOSE);
    }

__________________
valio_skull is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 10-29-2016 , 14:39  
Reply With Quote #7

valio_skull, fixed
Attached Files
File Type: sp Get Plugin or Get Source (valio_skull.sp - 225 views - 7.3 KB)
__________________
Grey83 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 13:39.


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