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(hndl, value, false, false);
}
public change_convar_float(String:name[], Float:value)
{
new Handle:hndl = FindConVar(name);
SetConVarFloat(hndl, value, false, false);
}
public Action:OnClientCommand(client, args)
{
//PrintToChatAll("1");
//Bot?
if (!IsFakeClient(client))
{
new String:buffer[100];
GetCmdArgString(buffer, sizeof(buffer));
//PrintToChatAll(buffer);
if (StrContains(buffer, "crosshair") > -1 || StrContains(buffer, "cl_glow_") > -1)
{
//Run commands to overwrite cheat attemp
run_commands(client, false);
//PrintToChatAll("???");
}
}
}
public OnClientPutInServer(client)
{
//Bot?
if (!IsFakeClient(client))
{
//Running change commands on client
run_commands(client, true);
//Show welcome message
CreateTimer(5.0, Timer_WelcomeMessage, client);
}
}
public Action:Timer_WelcomeMessage(Handle:timer, any: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:timer, any:client)
{
new number = getmodel(client);
if (number > -1)
{
//Save position
GetClientAbsOrigin(client, startpos[number]);
CreateTimer(1.0, Timer_WaitForHUD, client, TIMER_REPEAT);
//Timer stop
return Plugin_Stop;
}
//Timer repeat
return Plugin_Continue;
}
public Action:Timer_WaitForHUD(Handle:timer, any:client)
{
//Position changed?
new number = getmodel(client);
new Float:pos[3];
GetClientAbsOrigin(client, pos);
if (GetVectorDistance(pos, startpos[number]) > 1.0)
{
//Hide parts of the hud
SetEntProp(client, Prop_Send, "m_iHideHUD", 64);
return Plugin_Stop;
}
return Plugin_Continue;
}
run_commands(client, bool: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 (hud) CreateTimer(1.0, Timer_WaitForModel, client, TIMER_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(client, modelname, sizeof(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");
}