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

[ CSGO ] dead players respawn as chicken


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nguyenbaodanh
AlliedModders Donor
Join Date: Jun 2007
Location: HCMC, Vietnam
Old 03-22-2018 , 03:44   [ CSGO ] dead players respawn as chicken
Reply With Quote #1

Hi guys!
I'm trying to make some custom server mode like hunger game and battle royale. The problem is, some people will have to die very soon since the round start. They only can spectate and getting bored very soon.
To avoid that, spec mode changed to free for both team, but then they turn to spoiling alive players position.

So... I have an idea like:
- if a client dead , after 40 seconds they will respawn as chicken
- chicken can't use or pickup any items
- chicken gravity set to 100 or 200
- chicken speed can be set
- chicken hp can be set 100 to X
- chicken radar disable
__________________

Last edited by nguyenbaodanh; 03-24-2018 at 01:23.
nguyenbaodanh is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 03-24-2018 , 11:02   Re: [ CSGO ] dead players respawn as chicken
Reply With Quote #2

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

#define HIDE_RADAR_CSGO 1<<12 

bool RevivedAsChicken[MAXPLAYERS+1];
Handle ReviveAsChickenTimer[MAXPLAYERS+1];
ConVar ChickenHealthChickenRespawnChickenGravityChickenSpeed;

public 
void OnPluginStart()
{
    
ChickenHealth CreateConVar("sm_chicken_health""250""Chicken Health"0true0.0false2.0);
    
ChickenRespawn CreateConVar("sm_chicken_respawn_time""40.0""Time after death for respawn"0true0.1false1.0);
    
ChickenGravity CreateConVar("sm_chicken_gravity""0.1""0,1 = 100, 0,2 = 200, etc."0true0.1false1.0);
    
ChickenSpeed CreateConVar("sm_chicken_speed""2.5""1.0 - normal speed"0true0.1false1.0);

    
HookEvent("player_spawn"PlayerSpawn);
    
HookEvent("player_death"PlayerDeath);
    
HookEvent("round_end"RoundEnd);

    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i)) OnClientPutInServer(i);
    }
}

public 
void OnMapStart()
{
    
PrecacheModel("models/chicken/chicken.mdl"true);
    
AddFileToDownloadsTable("materials/models/props_farm/chicken_white.vmt");
    
AddFileToDownloadsTable("materials/models/props_farm/chicken_white.vtf");
    
AddFileToDownloadsTable("models/chicken/chicken.dx90.vtx");
    
AddFileToDownloadsTable("models/chicken/chicken.phy");
    
AddFileToDownloadsTable("models/chicken/chicken.vvd");
    
AddFileToDownloadsTable("models/chicken/chicken.mdl");
}
public 
void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_WeaponEquipOnWeaponEquip); 
    
RevivedAsChicken[client] = false;
}

public 
void OnClientDisconnect(int client)
{
    
SDKUnhook(clientSDKHook_WeaponEquipOnWeaponEquip); 
    if (
ReviveAsChickenTimer[client] != null)
    {
        
KillTimer(ReviveAsChickenTimer[client]);
        
ReviveAsChickenTimer[client] = null;
    }
}

public 
Action PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (
RevivedAsChicken[client])
    {
        
SetEntProp(clientProp_Send"m_iHideHUD"GetEntProp(clientProp_Send"m_iHideHUD") | HIDE_RADAR_CSGO);  
        
SetEntityModel(client"models/chicken/chicken.mdl");
        
SetEntityHealth(clientChickenHealth.IntValue);
        
SetGravity(clientChickenGravity.FloatValue);
        
SetSpeed(clientChickenSpeed.FloatValue);
        
FirstPerson(client);
        return 
Plugin_Handled;
    }

    
SetEntProp(clientProp_Send"m_iHideHUD"GetEntProp(clientProp_Send"m_iHideHUD") & ~HIDE_RADAR_CSGO);  
    
SetGravity(client1.0);
    
SetSpeed(client1.0);
    
FirstPerson(client);
    return 
Plugin_Continue;
}

public 
Action PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (!
RevivedAsChicken[client])
    {
        
ReviveAsChickenTimer[client] = CreateTimer(ChickenRespawn.FloatValueRevivePlayerAsChickenGetClientUserId(client));
    }
}

public 
Action RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        if(
IsValidClient(i) && RevivedAsChicken[i])
        {
            
RevivedAsChicken[i] = false;
        }

        if (
ReviveAsChickenTimer[i] != null)
        {
            
KillTimer(ReviveAsChickenTimer[i]);
            
ReviveAsChickenTimer[i] = null;
        }
    }
}

public 
Action RevivePlayerAsChicken(Handle timerany userid)
{
   
int client GetClientOfUserId(userid);
   if(
client == 0) return;

   
RevivedAsChicken[client] = true;
   
CS_RespawnPlayer(client);
}

public 
Action OnWeaponEquip(int clientint weapon)  
{
    
char weaponname[32];
    
GetEdictClassname(weaponweaponnamesizeof(weaponname)); 

    if(
RevivedAsChicken[client] && !StrEqual(weaponname"weapon_knife"))
    {
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;    
}  

public 
void SetSpeed(int clientfloat speed)
{
    
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"speed);
}

public 
void SetGravity(int clientfloat amount)
{
    
SetEntityGravity(clientamount GetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"));
}

void FirstPerson(int client)
{
    if (
IsValidClient(client) && RevivedAsChicken[client])
    {
        
ClientCommand(client"firstperson");
    }
    else
    {
        
ClientCommand(client"thirdperson");    
    }
}

stock bool IsValidClient(int client)
{
    return (
<= client <= MaxClients && IsClientInGame(client));

Cvars:
PHP Code:
sm_chicken_health <Int Value> - sets the chicken health.
sm_chicken_respawn_time <Float Value> - sets the second when the player will be respawned after he dies.
sm_chicken_gravity <Float Value> - sets the gravity of the chicken. (0.1 -> 1000.2 -> 200etc.)
sm_chicken_speed <Float Value> - sets the speed of the chicken. (1.0 normal speed
Give that a try.
Attached Files
File Type: zip chicken_model.zip (189.3 KB, 121 views)
__________________

Last edited by PinHeaDi; 03-24-2018 at 19:59.
PinHeaDi is offline
nguyenbaodanh
AlliedModders Donor
Join Date: Jun 2007
Location: HCMC, Vietnam
Old 03-25-2018 , 22:40   Re: [ CSGO ] dead players respawn as chicken
Reply With Quote #3

Quote:
Originally Posted by PinHeaDi View Post
PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>

#define HIDE_RADAR_CSGO 1<<12 

bool RevivedAsChicken[MAXPLAYERS+1];
Handle ReviveAsChickenTimer[MAXPLAYERS+1];
ConVar ChickenHealthChickenRespawnChickenGravityChickenSpeed;

public 
void OnPluginStart()
{
    
ChickenHealth CreateConVar("sm_chicken_health""250""Chicken Health"0true0.0false2.0);
    
ChickenRespawn CreateConVar("sm_chicken_respawn_time""40.0""Time after death for respawn"0true0.1false1.0);
    
ChickenGravity CreateConVar("sm_chicken_gravity""0.1""0,1 = 100, 0,2 = 200, etc."0true0.1false1.0);
    
ChickenSpeed CreateConVar("sm_chicken_speed""2.5""1.0 - normal speed"0true0.1false1.0);

    
HookEvent("player_spawn"PlayerSpawn);
    
HookEvent("player_death"PlayerDeath);
    
HookEvent("round_end"RoundEnd);

    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i)) OnClientPutInServer(i);
    }
}

public 
void OnMapStart()
{
    
PrecacheModel("models/chicken/chicken.mdl"true);
    
AddFileToDownloadsTable("materials/models/props_farm/chicken_white.vmt");
    
AddFileToDownloadsTable("materials/models/props_farm/chicken_white.vtf");
    
AddFileToDownloadsTable("models/chicken/chicken.dx90.vtx");
    
AddFileToDownloadsTable("models/chicken/chicken.phy");
    
AddFileToDownloadsTable("models/chicken/chicken.vvd");
    
AddFileToDownloadsTable("models/chicken/chicken.mdl");
}
public 
void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_WeaponEquipOnWeaponEquip); 
    
RevivedAsChicken[client] = false;
}

public 
void OnClientDisconnect(int client)
{
    
SDKUnhook(clientSDKHook_WeaponEquipOnWeaponEquip); 
    if (
ReviveAsChickenTimer[client] != null)
    {
        
KillTimer(ReviveAsChickenTimer[client]);
        
ReviveAsChickenTimer[client] = null;
    }
}

public 
Action PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (
RevivedAsChicken[client])
    {
        
SetEntProp(clientProp_Send"m_iHideHUD"GetEntProp(clientProp_Send"m_iHideHUD") | HIDE_RADAR_CSGO);  
        
SetEntityModel(client"models/chicken/chicken.mdl");
        
SetEntityHealth(clientChickenHealth.IntValue);
        
SetGravity(clientChickenGravity.FloatValue);
        
SetSpeed(clientChickenSpeed.FloatValue);
        
FirstPerson(client);
        return 
Plugin_Handled;
    }

    
SetEntProp(clientProp_Send"m_iHideHUD"GetEntProp(clientProp_Send"m_iHideHUD") & ~HIDE_RADAR_CSGO);  
    
SetGravity(client1.0);
    
SetSpeed(client1.0);
    
FirstPerson(client);
    return 
Plugin_Continue;
}

public 
Action PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (!
RevivedAsChicken[client])
    {
        
ReviveAsChickenTimer[client] = CreateTimer(ChickenRespawn.FloatValueRevivePlayerAsChickenGetClientUserId(client));
    }
}

public 
Action RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        if(
IsValidClient(i) && RevivedAsChicken[i])
        {
            
RevivedAsChicken[i] = false;
        }

        if (
ReviveAsChickenTimer[i] != null)
        {
            
KillTimer(ReviveAsChickenTimer[i]);
            
ReviveAsChickenTimer[i] = null;
        }
    }
}

public 
Action RevivePlayerAsChicken(Handle timerany userid)
{
   
int client GetClientOfUserId(userid);
   if(
client == 0) return;

   
RevivedAsChicken[client] = true;
   
CS_RespawnPlayer(client);
}

public 
Action OnWeaponEquip(int clientint weapon)  
{
    
char weaponname[32];
    
GetEdictClassname(weaponweaponnamesizeof(weaponname)); 

    if(
RevivedAsChicken[client] && !StrEqual(weaponname"weapon_knife"))
    {
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;    
}  

public 
void SetSpeed(int clientfloat speed)
{
    
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"speed);
}

public 
void SetGravity(int clientfloat amount)
{
    
SetEntityGravity(clientamount GetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"));
}

void FirstPerson(int client)
{
    if (
IsValidClient(client) && RevivedAsChicken[client])
    {
        
ClientCommand(client"firstperson");
    }
    else
    {
        
ClientCommand(client"thirdperson");    
    }
}

stock bool IsValidClient(int client)
{
    return (
<= client <= MaxClients && IsClientInGame(client));

Cvars:
PHP Code:
sm_chicken_health <Int Value> - sets the chicken health.
sm_chicken_respawn_time <Float Value> - sets the second when the player will be respawned after he dies.
sm_chicken_gravity <Float Value> - sets the gravity of the chicken. (0.1 -> 1000.2 -> 200etc.)
sm_chicken_speed <Float Value> - sets the speed of the chicken. (1.0 normal speed
Give that a try.
tested.
idk if it work or not because testing alone in server, but can you disable thirdperson at dafault ? currently plugin force thirdperson on spawn.
__________________
nguyenbaodanh is offline
Zyten
Senior Member
Join Date: Jan 2018
Old 03-26-2018 , 08:20   Re: [ CSGO ] dead players respawn as chicken
Reply With Quote #4

Can this be applied on death ppl at gerenal and not only spec. i tested this on jailbreak server xD. the chikens can come back and kill others xD. i would like it be more like u could do activitys and stuff while new round start without effecting the alive game
Zyten is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 03-26-2018 , 11:50   Re: [ CSGO ] dead players respawn as chicken
Reply With Quote #5

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

#pragma semicolon 1
#pragma newdecls required

#define HIDE_RADAR_CSGO 1<<12
#define ChickenModel "models/chicken/chicken.mdl"

bool RevivedAsChicken[MAXPLAYERS+1];
Handle ReviveAsChickenTimer[MAXPLAYERS+1];
ConVar ChickenUseChickenTPChickenHealthChickenRespawnChickenGravityChickenSpeed;

public 
void OnPluginStart()
{
    
ChickenUse CreateConVar("sm_chicken_use""1""Disables '+use' for chickens. 1 - yes, 0 - no."0true0.0true1.0);
    
ChickenTP CreateConVar("sm_chicken_thirdperson""0""1 - Chickens will be in thirdperson, 0 - Chickens will be in firstperson."0true0.0true1.0);
    
ChickenHealth CreateConVar("sm_chicken_health""250""Chicken Health"0true0.0false2.0);
    
ChickenRespawn CreateConVar("sm_chicken_respawn_time""40.0""Time after death for respawn"0true0.1false1.0);
    
ChickenGravity CreateConVar("sm_chicken_gravity""0.1""0,1 = 100, 0,2 = 200, etc."0true0.1false1.0);
    
ChickenSpeed CreateConVar("sm_chicken_speed""2.5""1.0 - normal speed"0true0.1false1.0);

    
HookEvent("player_spawn"PlayerSpawn);
    
HookEvent("player_death"PlayerDeath);
    
HookEvent("round_end"RoundEnd);

    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i)) OnClientPutInServer(i);
    }
}

public 
void OnMapStart()
{
    
PrecacheModel(ChickenModel);
    
AddFileToDownloadsTable("materials/models/props_farm/chicken_white.vmt");
    
AddFileToDownloadsTable("materials/models/props_farm/chicken_white.vtf");
    
AddFileToDownloadsTable("models/chicken/chicken.dx90.vtx");
    
AddFileToDownloadsTable("models/chicken/chicken.phy");
    
AddFileToDownloadsTable("models/chicken/chicken.vvd");
    
AddFileToDownloadsTable("models/chicken/chicken.mdl");
}

public 
void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_WeaponEquipOnWeaponEquip);
    
SDKHook(clientSDKHook_OnTakeDamageAliveOnTakeDamage);
    
RevivedAsChicken[client] = false;
}

public 
void OnClientDisconnect(int client)
{
    
SDKUnhook(clientSDKHook_WeaponEquipOnWeaponEquip);
    
SDKUnhook(clientSDKHook_OnTakeDamageAliveOnTakeDamage);
    if (
ReviveAsChickenTimer[client] != null)
    {
        
KillTimer(ReviveAsChickenTimer[client]);
        
ReviveAsChickenTimer[client] = null;
    }
}

//*******************************************************//
//                   EVENTS                             //
//*****************************************************//
public Action PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));

    if (
ReviveAsChickenTimer[client] != null//In case of an admin revives the player, before the time runs out. Or he's respawned in other ways.
    
{
        
KillTimer(ReviveAsChickenTimer[client]);
        
ReviveAsChickenTimer[client] = null;
    }

    if(
ChickenTP.IntValue)
    {
        
FirstPerson(client);
    }

    if (
RevivedAsChicken[client])
    {
        
SetEntProp(clientProp_Send"m_lifeState"1);  

        
Client_RemoveAllWeapons(client""true);
        
SetEntProp(clientProp_Send"m_iHideHUD"GetEntProp(clientProp_Send"m_iHideHUD") | HIDE_RADAR_CSGO);
        
SetEntProp(clientProp_Data"m_takedamage"01);
        
SetEntityModel(clientChickenModel);
        
SetEntityHealth(clientChickenHealth.IntValue);
        
SetGravity(clientChickenGravity.FloatValue);
        
SetSpeed(clientChickenSpeed.FloatValue);  
        return 
Plugin_Handled;
    }

    
SetEntProp(clientProp_Data"m_takedamage"21);
    
SetEntProp(clientProp_Send"m_iHideHUD"GetEntProp(clientProp_Send"m_iHideHUD") & ~HIDE_RADAR_CSGO);
    
SetGravity(client1.0);
    
SetSpeed(client1.0);
    return 
Plugin_Continue;
}

public 
Action PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (!
RevivedAsChicken[client])
    {
        
ReviveAsChickenTimer[client] = CreateTimer(ChickenRespawn.FloatValueRevivePlayerAsChickenGetClientUserId(client));
    }
}

public 
Action RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        if(
IsValidClient(i) && RevivedAsChicken[i])
        {
            
RevivedAsChicken[i] = false;
        }

        if (
ReviveAsChickenTimer[i] != null)
        {
            
KillTimer(ReviveAsChickenTimer[i]);
            
ReviveAsChickenTimer[i] = null;
        }
    }
}

public 
Action RevivePlayerAsChicken(Handle timerany userid)
{
   
int client GetClientOfUserId(userid);
   if(
client == 0) return;

   
RevivedAsChicken[client] = true;
   
CS_RespawnPlayer(client);
}

//*******************************************************//
//                   ACTIONS                            //
//*****************************************************//

public Action OnPlayerRunCmd(int clientint &buttonsint &impulsefloat vel[3], float angles[3], int &weaponint &subtypeint &cmdnumint &tickcountint &seedint mouse[2])
{
    if(
RevivedAsChicken[client] && ChickenUse.IntValue)
    {
        
buttons buttons &= ~IN_USE;
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;
}

public 
Action OnWeaponEquip(int clientint weapon)  
{
    
char weaponname[32];
    
GetEdictClassname(weaponweaponnamesizeof(weaponname)); 

    if(
RevivedAsChicken[client] && !StrEqual(weaponname"weapon_knife"))
    {
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;    


public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype)
{
    if(
RevivedAsChicken[attacker])
    {
        
damage 0.0
        return 
Plugin_Handled
    }

    return 
Plugin_Continue;
}

//*******************************************************//
//                    VOIDS                             //
//*****************************************************//
void FirstPerson(int client)
{
    if (
IsValidClient(client) && RevivedAsChicken[client])
    {
        
ClientCommand(client"firstperson");
    }
    else
    {
        
ClientCommand(client"thirdperson");    
    }
}

public 
void SetSpeed(int clientfloat speed)
{
    
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"speed);
}

public 
void SetGravity(int clientfloat amount)
{
    
SetEntityGravity(clientamount GetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"));
}

stock bool IsValidClient(int client)
{
    return (
<= client <= MaxClients && IsClientInGame(client));

PHP Code:
sm_chicken_use <Int Value> - Disables +use(Use buttons) for chickensyesno.
sm_chicken_thirdperson <Int Value> - Chickens will be in thirdpersonChickens will be in firstperson (like normal players).
sm_chicken_health <Int Value> - sets the chicken health.
sm_chicken_respawn_time <Float Value> - sets the second when the player will be respawned after he dies.
sm_chicken_gravity <Float Value> - sets the gravity of the chicken. (0.1 -> 1000.2 -> 200etc.)
sm_chicken_speed <Float Value> - sets the speed of the chicken. (1.0 normal speed
Also, you need smlib to compile the plugin, since I added a strip, so the chickens won't spawn with knifes. Chickens can't hurt alive players or hurt anyone at all.
__________________

Last edited by PinHeaDi; 03-26-2018 at 21:03.
PinHeaDi is offline
Zyten
Senior Member
Join Date: Jan 2018
Old 03-26-2018 , 21:07   Re: [ CSGO ] dead players respawn as chicken
Reply With Quote #6

Its almost perfect but the player after death will respawn to chicken he is count as alive so when normal round game should be finished instead its will continue cos the chickens still count as alive ppl so round goes on
Zyten is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 03-26-2018 , 21:09   Re: [ CSGO ] dead players respawn as chicken
Reply With Quote #7

Try the updated code "Last edited by PinHeaDi; Today at 08:03 PM. " of my last post. I think I fixed that.
__________________
PinHeaDi is offline
nguyenbaodanh
AlliedModders Donor
Join Date: Jun 2007
Location: HCMC, Vietnam
Old 03-26-2018 , 23:53   Re: [ CSGO ] dead players respawn as chicken
Reply With Quote #8

hhahaha seems good. But now spectator can block alive player too.
Requesting noblock for chickens =))

I'm testing for more problems if there is
__________________
nguyenbaodanh is offline
PinHeaDi
Senior Member
Join Date: Jul 2013
Location: Bulgaria
Old 03-27-2018 , 01:32   Re: [ CSGO ] dead players respawn as chicken
Reply With Quote #9

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

#pragma semicolon 1
#pragma newdecls required

#define HIDE_RADAR_CSGO 1<<12
#define ChickenModel "models/chicken/chicken.mdl"

bool RevivedAsChicken[MAXPLAYERS+1];
Handle ReviveAsChickenTimer[MAXPLAYERS+1];
ConVar ChickenUseChickenTPChickenHealthChickenRespawnChickenGravityChickenSpeedChickenNoCollusion;

public 
void OnPluginStart()
{
    
ChickenNoCollusion CreateConVar("sm_chicken_nocollusion""1""Disbles collusions between chickens and normal players. 1 - on, 0 - off"0true0.0true1.0);
    
ChickenUse CreateConVar("sm_chicken_use""1""Disables '+use' for chickens. 1 - yes, 0 - no."0true0.0true1.0);
    
ChickenTP CreateConVar("sm_chicken_thirdperson""0""1 - Chichens will be in thirdperson, 0 - Chichens will be in firstperson."0true0.0true1.0);
    
ChickenHealth CreateConVar("sm_chicken_health""250""Chicken Health"0true0.0false2.0);
    
ChickenRespawn CreateConVar("sm_chicken_respawn_time""40.0""Time after death for respawn"0true0.1false1.0);
    
ChickenGravity CreateConVar("sm_chicken_gravity""0.1""0,1 = 100, 0,2 = 200, etc."0true0.1false1.0);
    
ChickenSpeed CreateConVar("sm_chicken_speed""2.5""1.0 - normal speed"0true0.1false1.0);

    
HookEvent("player_spawn"PlayerSpawn);
    
HookEvent("player_death"PlayerDeath);
    
HookEvent("round_end"RoundEnd);

    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i)) OnClientPutInServer(i);
    }
}

public 
void OnMapStart()
{
    
PrecacheModel(ChickenModel);
    
AddFileToDownloadsTable("materials/models/props_farm/chicken_white.vmt");
    
AddFileToDownloadsTable("materials/models/props_farm/chicken_white.vtf");
    
AddFileToDownloadsTable("models/chicken/chicken.dx90.vtx");
    
AddFileToDownloadsTable("models/chicken/chicken.phy");
    
AddFileToDownloadsTable("models/chicken/chicken.vvd");
    
AddFileToDownloadsTable("models/chicken/chicken.mdl");
}

public 
void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_WeaponEquipOnWeaponEquip);
    
SDKHook(clientSDKHook_OnTakeDamageAliveOnTakeDamage);
    
SDKHook(clientSDKHook_StartTouchOnPlayerTouch);
    
RevivedAsChicken[client] = false;
}

public 
void OnClientDisconnect(int client)
{
    
SDKUnhook(clientSDKHook_WeaponEquipOnWeaponEquip);
    
SDKUnhook(clientSDKHook_OnTakeDamageAliveOnTakeDamage);
    if (
ReviveAsChickenTimer[client] != null)
    {
        
KillTimer(ReviveAsChickenTimer[client]);
        
ReviveAsChickenTimer[client] = null;
    }
}

//*******************************************************//
//                   EVENTS                             //
//*****************************************************//
public Action PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));

    if (
ReviveAsChickenTimer[client] != null//In case of an admin revives the player, before the time runs out. Or he's respawned in other ways.
    
{
        
KillTimer(ReviveAsChickenTimer[client]);
        
ReviveAsChickenTimer[client] = null;
    }

    if(
ChickenTP.IntValue)
    {
        
FirstPerson(client);
    }

    if (
RevivedAsChicken[client])
    {
        
SetEntProp(clientProp_Send"m_lifeState"1);  

        
Client_RemoveAllWeapons(client""true);
        
SetEntProp(clientProp_Send"m_iHideHUD"GetEntProp(clientProp_Send"m_iHideHUD") | HIDE_RADAR_CSGO);
        
SetEntProp(clientProp_Data"m_takedamage"01);
        
SetEntityModel(clientChickenModel);
        
SetEntityHealth(clientChickenHealth.IntValue);
        
SetGravity(clientChickenGravity.FloatValue);
        
SetSpeed(clientChickenSpeed.FloatValue);  
        return 
Plugin_Handled;
    }

    
SetEntProp(clientProp_Data"m_takedamage"21);
    
SetEntProp(clientProp_Send"m_iHideHUD"GetEntProp(clientProp_Send"m_iHideHUD") & ~HIDE_RADAR_CSGO);
    
SetGravity(client1.0);
    
SetSpeed(client1.0);
    return 
Plugin_Continue;
}

public 
Action PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    if (!
RevivedAsChicken[client])
    {
        
ReviveAsChickenTimer[client] = CreateTimer(ChickenRespawn.FloatValueRevivePlayerAsChickenGetClientUserId(client));
    }
}

public 
Action RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    for (
int i 1<= MaxClientsi++)
    {
        if(
IsValidClient(i) && RevivedAsChicken[i])
        {
            
RevivedAsChicken[i] = false;
        }

        if (
ReviveAsChickenTimer[i] != null)
        {
            
KillTimer(ReviveAsChickenTimer[i]);
            
ReviveAsChickenTimer[i] = null;
        }
    }
}

public 
Action RevivePlayerAsChicken(Handle timerany userid)
{
   
int client GetClientOfUserId(userid);
   if(
client == 0) return;

   
RevivedAsChicken[client] = true;
   
CS_RespawnPlayer(client);
}

//*******************************************************//
//                   ACTIONS                            //
//*****************************************************//

public Action OnPlayerRunCmd(int clientint &buttonsint &impulsefloat vel[3], float angles[3], int &weaponint &subtypeint &cmdnumint &tickcountint &seedint mouse[2])
{
    if(
RevivedAsChicken[client] && ChickenUse.IntValue)
    {
        
buttons buttons &= ~IN_USE;
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;
}

public 
Action OnWeaponEquip(int clientint weapon)  
{
    
char weaponname[32];
    
GetEdictClassname(weaponweaponnamesizeof(weaponname)); 

    if(
RevivedAsChicken[client] && !StrEqual(weaponname"weapon_knife"))
    {
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;    


public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype)
{
    if(
RevivedAsChicken[attacker])
    {
        
damage 0.0
        return 
Plugin_Handled
    }

    return 
Plugin_Continue;
}

//*******************************************************//
//                    VOIDS                             //
//*****************************************************//
public void OnPlayerTouch(int clientint ent)
{
    if(
RevivedAsChicken[client] && ChickenNoCollusion.IntValue && IsValidClient(client))
    {
        
SetEntProp(clientProp_Data"m_CollisionGroup", (ent <= MaxClients) ? 5);
    }  
}

public 
void SetSpeed(int clientfloat speed)
{
    
SetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"speed);
}

public 
void SetGravity(int clientfloat amount)
{
    
SetEntityGravity(clientamount GetEntPropFloat(clientProp_Data"m_flLaggedMovementValue"));
}

void FirstPerson(int client)
{
    if (
IsValidClient(client) && RevivedAsChicken[client])
    {
        
ClientCommand(client"firstperson");
    }
    else
    {
        
ClientCommand(client"thirdperson");    
    }
}

stock bool IsValidClient(int client)
{
    return (
<= client <= MaxClients && IsClientInGame(client));

PHP Code:
sm_chicken_nocollusion <Int Value> - Disbles collusions between chickens and normal playersonoff 
Try it now.
__________________
PinHeaDi is offline
Zyten
Senior Member
Join Date: Jan 2018
Old 03-27-2018 , 03:13   Re: [ CSGO ] dead players respawn as chicken
Reply With Quote #10

can there be a command that make client make his chicken gravity level? and ofc make it on/off by cvar
!cg could be good = chickengravity

Also this need noclip and same as above (i am asking that because when u do some activitys u pass and there is doors faceing you then u are locked untill end of round).

also would be cool if there is question asking if he would like to become chicken or stay spec as i have noticed there is no way back after u are chicken.

also jump sounds etc could it be off? (normal player can hear checkens jump "like normal player")

Blocking chickens to pick up guns/granades (knifes is okey)

i dont know if this posssiple but spec death chicken and ban by steamid for some ppl to use it

also mabey vip a flag if this will be so imposiple to control only for few ppl

Last edited by Zyten; 03-27-2018 at 09:03.
Zyten 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 10:57.


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