View Single Post
DieTeetasse
Senior Member
Join Date: Jul 2009
Old 06-21-2010 , 20:24   Re: L4d1 realism mode - plugin request
Reply With Quote #8

I wrote something ages ago... maybe it will help...

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

#pragma semicolon 1
#define CVAR_FLAGS FCVAR_PLUGIN|FCVAR_NOTIFY
#define PLUGIN_VERSION "1.0"

//Global variables
new Float:startpos[4][3];

//Plugin info
public Plugin:myinfo =
{
    
name "Realistic Mod",
    
author "Die Teetasse",
    
description "More realism for L4D!",
    
version PLUGIN_VERSION,
    
url ""
};

public 
OnPluginStart()
{
    
//Create cvars
    //Version
    
CreateConVar("l4d_real_version"PLUGIN_VERSION"Realistic mod version"CVAR_FLAGS|FCVAR_DONTRECORD);
}

public 
OnMapStart()
{
    
//Changing cvars of server
    //Survivornames disappear in the sky ;) (0 is not working) - Default: 10
    
change_convar("hud_targetid_name_height"1000); 

    
//Talkbubble like names - Default: 20
    
change_convar("voice_head_icon_height"1000);
    
    
//Less shaking in incap mode - Default: 0.4
    
change_convar_float("survivor_incapacitated_accuracy_penalty"0.1);
}

public 
change_convar(String:name[], value)
{
    new 
Handle:hndl FindConVar(name);
    
SetConVarInt(hndlvaluefalsefalse);
}

public 
change_convar_float(String:name[], Float:value)
{
    new 
Handle:hndl FindConVar(name);
    
SetConVarFloat(hndlvaluefalsefalse);
}

public 
Action:OnClientCommand(clientargs)
{
    
//PrintToChatAll("1");

    //Bot?
    
if (!IsFakeClient(client))
    {
        new 
String:buffer[100];
        
GetCmdArgString(buffersizeof(buffer));
        
        
//PrintToChatAll(buffer);
        
        
if (StrContains(buffer"crosshair") > -|| StrContains(buffer"cl_glow_") > -1)
        {
            
//Run commands to overwrite cheat attemp
            
run_commands(clientfalse);
            
            
//PrintToChatAll("???");
        
}
    }
}

public 
OnClientPutInServer(client)
{
    
//Bot?
    
if (!IsFakeClient(client))
    {    
        
//Running change commands on client
        
run_commands(clienttrue);
        
        
//Show welcome message
        
CreateTimer(5.0Timer_WelcomeMessageclient);
    }
}

public 
Action:Timer_WelcomeMessage(Handle:timerany:client)
{
    
PrintToChat(client"[Real] Welcome on a realistic mod server.");
    
PrintToChat(client"[Real] On this server the glow for survivors is mostly deactivated.");
    
PrintToChat(client"[Real] Only in front of an item there will be a glow.");
    
PrintToChat(client"[Real] The crosshair and the healthbar part of the hud are deactivated too.");
    
PrintToChat(client"[Real] Have fun with this new challange.");
}

public 
Action:Timer_WaitForModel(Handle:timerany:client)
{
    new 
number getmodel(client);
    
    if (
number > -1)
    {        
        
//Save position
        
GetClientAbsOrigin(clientstartpos[number]);    
        
CreateTimer(1.0Timer_WaitForHUDclientTIMER_REPEAT);
        
        
//Timer stop
        
return Plugin_Stop;
    }
    
    
//Timer repeat
    
return Plugin_Continue;
}

public 
Action:Timer_WaitForHUD(Handle:timerany:client)
{
    
//Position changed?
    
new number getmodel(client);
    new 
Float:pos[3];
    
GetClientAbsOrigin(clientpos);
    
    if (
GetVectorDistance(posstartpos[number]) > 1.0)
    {
        
//Hide parts of the hud
        
SetEntProp(clientProp_Send"m_iHideHUD"64);
        
        return 
Plugin_Stop;
    }
    
    return 
Plugin_Continue;
}

run_commands(clientbool:hud)
{
    
//Hide glow from survivors and item that are far away, strength glow of near items
    
ClientCommand(client"cl_glow_survivor_r 0.0");
    
ClientCommand(client"cl_glow_survivor_g 0.0");
    
ClientCommand(client"cl_glow_survivor_b 0.0");
    
ClientCommand(client"cl_glow_survivor_hurt_r 0.0");
    
ClientCommand(client"cl_glow_survivor_hurt_g 0.0");
    
ClientCommand(client"cl_glow_survivor_hurt_b 0.0");
    
ClientCommand(client"cl_glow_survivor_vomit_r 0.0");
    
ClientCommand(client"cl_glow_survivor_vomit_g 0.0");
    
ClientCommand(client"cl_glow_survivor_vomit_b 0.0");
    
ClientCommand(client"cl_glow_item_r 1.0");
    
ClientCommand(client"cl_glow_item_g 1.0");
    
ClientCommand(client"cl_glow_item_b 1.0");
    
ClientCommand(client"cl_glow_item_far_r 0.0");
    
ClientCommand(client"cl_glow_item_far_g 0.0");
    
ClientCommand(client"cl_glow_item_far_b 0.0");
    
ClientCommand(client"cl_glow_ability_r 0.0");
    
ClientCommand(client"cl_glow_ability_g 0.0");
    
ClientCommand(client"cl_glow_ability_b 0.0");
    
    
//Hide crosshair
    
ClientCommand(client"crosshair 0");
    
    
//Wait for model (HUD deactivation)
    
if (hudCreateTimer(1.0Timer_WaitForModelclientTIMER_REPEAT);
    
    
/*
    //Allow fog changes
    flags = GetCommandFlags("fog_override");
    SetCommandFlags("fog_override", flags & ~FCVAR_CHEAT);    
    ClientCommand(client, "fog_override 1");
    SetCommandFlags("fog_override", flags);
    
    //Change fog
    flags = GetCommandFlags("fog_start");
    SetCommandFlags("fog_start", flags & ~FCVAR_CHEAT);    
    ClientCommand(client, "fog_start 2000");
    SetCommandFlags("fog_start", flags);
    */
}

getmodel(client)
{
    
//Get model
    
new String:modelname[200];
    
GetClientModel(clientmodelnamesizeof(modelname));
            
    
//Find arraynumber by modelname
    //Zoey
    
if(StrContains(modelname"teenangst"false) != -1)
    {
        return 
0;
    }
    
//Francis
    
else if(StrContains(modelname"biker"false) != -1)
    {
        return 
1;
    }    
    
//Louis
    
else if(StrContains(modelname"manager"false) != -1)
    {
        return 
2;
    }    
    
//Bill
    
else if(StrContains(modelname"namvet"false) != -1)
    {
        return 
3;
    }
    else
    {
        return -
1;
    }
}

public 
OnClientDisconnect(client)
{
    if (
IsClientInGame(client))
    {
        
//Reset client settings
        
reset_client(client);
    }
}

reset_client(client)
{
    
//Hide glow from survivors and item that are far away, strength glow of near items
    
ClientCommand(client"cl_glow_survivor_r 0.3");
    
ClientCommand(client"cl_glow_survivor_g 0.4");
    
ClientCommand(client"cl_glow_survivor_b 1.0");
    
ClientCommand(client"cl_glow_survivor_hurt_r 1.0");
    
ClientCommand(client"cl_glow_survivor_hurt_g 0.4");
    
ClientCommand(client"cl_glow_survivor_hurt_b 0.0");
    
ClientCommand(client"cl_glow_survivor_vomit_r 1.0");
    
ClientCommand(client"cl_glow_survivor_vomit_g 0.4");
    
ClientCommand(client"cl_glow_survivor_vomit_b 0.0");
    
ClientCommand(client"cl_glow_item_r 0.7");
    
ClientCommand(client"cl_glow_item_g 0.7");
    
ClientCommand(client"cl_glow_item_b 1.0");
    
ClientCommand(client"cl_glow_item_far_r 0.3");
    
ClientCommand(client"cl_glow_item_far_g 0.4");
    
ClientCommand(client"cl_glow_item_far_b 1.0");
    
ClientCommand(client"cl_glow_ability_r 1.0");
    
ClientCommand(client"cl_glow_ability_g 0.0");
    
ClientCommand(client"cl_glow_ability_b 0.0");
    
    
//Unhide crosshair
    
ClientCommand(client"crosshair 1");

__________________
DieTeetasse is offline