/*
Copyleft 2007
Plugin thread: http://forums.alliedmods.net/showthread.php?t=16418
USURF
=====
Description
This mod is designed to assist in the running of a surf server. It
includes many features, such as surfing help, semiclip, checkpoints,
"BOOM" button removal and many more features.
Was previously known as "Surf Management / Tools"
Changelog:
March 4, 2007 - v5.0 - Renamed and fixed major bugs
March 13, 2007 - v5.1 - [FEATURE] Added timer
[FEATURE] Added bunnyhop
[FEATURE] Added team stack
[FEATURE] Added godmode
[BUG] Improved semiclip
[BUG] Fixed crashing on Linux servers
[BUG] Fixed crouching with checkpoints
[BUG] Fixed respawn to send people back
to their spawns rather than killing them
March 16, 2007 - v5.2 - [FEATURE] Cleaned up the /surfhelp MOTD display
[FEATURE] Added menu to /surfhelp
[BUG] Fixed surf help showing more than once
[BUG] Optimized surf help section
[BUG] Added new commands to /surfhelp display
[BUG] Removed some old semiclip code that was
causing problems only for people on the same team
[BUG] Fixed checkpoints and timers working on
non-surf maps
Credits:
XxAvalanchexX - Post about blocking knife hits
*/
#include
#include
#include
#include
#include
#define TIMER_TASK 23981293
#define TIMER_INTERVAL 1.0
new p_On
new p_AutoCvars
new p_Help
new p_HelpInterval
new p_Respawn
new p_RemoveDropped
new p_RemoveButton
new p_NoGuns
new p_SpawnDist
new p_Semiclip
new p_Cp
new p_CpDelay
new p_BunnyHop
new p_BunnyHopAutoJump
new p_Timer
new p_X
new p_Y
new p_R
new p_G
new p_B
new p_TeamStack
new p_Godmode
new bool:g_SurfMap
new Float:g_Origin[33][3]
new Float:g_Velocity[33][3]
new Float:g_Angles[33][3]
new Float:g_LastSave[33]
new g_Time[33]
new g_Timing[33]
new g_Timer[33]
new g_Menu[512]
new g_TimerMenu[] = "TimerMenu"
new g_TimerTask = TIMER_TASK
new Float:g_TimerInterval = TIMER_INTERVAL
new g_HudObject
new g_SemiclipThinkerClassname[] = "usurf_semiclip"
new g_SemiclipThinker
new g_Models[2][4] =
{
{_:CS_T_ARCTIC,_:CS_T_GUERILLA,_:CS_T_LEET,_:CS_T_TERROR},
{_:CS_CT_GIGN,_:CS_CT_GSG9,_:CS_CT_SAS,_:CS_CT_URBAN}
}
new g_SurfHelpMenu
public plugin_init()
{
new VERSION[] = "5.2"
register_plugin("uSurf",VERSION,"Hawk552")
register_cvar("usurf_version", VERSION, FCVAR_SERVER)
new NewVersion[10]
format(NewVersion,9,"usurf %s",VERSION)
register_cvar("surf_base_version",NewVersion,FCVAR_SERVER)
// Global Commands / Cvars
p_On = register_cvar("usurf_on","1")
//Auto Cvars
p_AutoCvars = register_cvar("usurf_autocvars","1")
// Before we do ANYTHING, let's see if it's a surf map or not.
CheckSurf()
if(get_pcvar_num(p_On))
set_task(5.0,"ExecCvars")
// Surf Help
register_clcmd("say /surfhelp","CmdSurfhelp")
register_clcmd("say /help","CmdSurfhelp")
p_Help = register_cvar("usurf_help","1")
p_HelpInterval = register_cvar("usurf_help_interval","60.0")
set_task(get_pcvar_float(p_HelpInterval),"ShowSurfHelp")
g_SurfHelpMenu = menu_create("Surf Help","SurfHelpHandle")
menu_additem(g_SurfHelpMenu,"Surfing Help")
menu_additem(g_SurfHelpMenu,"uSurf Commands")
menu_additem(g_SurfHelpMenu,"About uSurf")
// Checkpoints
register_clcmd("say /checkpoint","CmdCheckpoint")
register_clcmd("say /gocheck","CmdGoCheck")
p_Cp = register_cvar("usurf_checkpoint","1")
p_CpDelay = register_cvar("usurf_checkpoint_delay","20")
// extra stuff
p_RemoveDropped = register_cvar("usurf_remove_dropped","1")
p_RemoveButton = register_cvar("usurf_remove_button","1")
p_NoGuns = register_cvar("usurf_noguns","0")
p_SpawnDist = register_cvar("usurf_spawn_dist","500")
p_Semiclip = register_cvar("usurf_semiclip","0")
p_TeamStack = register_cvar("usurf_teamstack","0")
p_Godmode = register_cvar("usurf_godmode","1")
// bunny hopping
p_BunnyHop = register_cvar("usurf_bunnyhop","1")
p_BunnyHopAutoJump = register_cvar("usurf_bunnyhop_autojump","1")
// timer
p_Timer = register_cvar("usurf_timer","1")
p_X = register_cvar("usurf_timer_x","0.8")
p_Y = register_cvar("usurf_timer_y","-0.8")
p_R = register_cvar("usurf_timer_r","0")
p_G = register_cvar("usurf_timer_g","0")
p_B = register_cvar("usurf_timer_b","255")
register_clcmd("say /timer","CmdTimer")
register_menucmd(register_menuid(g_TimerMenu),1023,"TimerHandle")
register_menucmd(register_menuid("Team_Select",1),MENU_KEY_1|MENU_KEY_2|MENU_KEY_5|MENU_KEY_6,"TeamHandle")
register_clcmd("jointeam","TeamHandle")
g_HudObject = CreateHudSyncObj()
register_dictionary("time.txt")
register_forward(FM_SetModel,"ForwardSetModel")
register_forward(FM_PlayerPreThink,"ForwardPlayerPreThink")
register_forward(FM_Touch,"ForwardTouch")
register_forward(FM_Think,"ForwardThink")
register_forward(FM_TraceLine,"ForwardTraceLine",1)
register_forward(FM_TraceHull,"ForwardTraceHull",1)
CheckSurf()
CheckButton()
// Respawn
p_Respawn = register_cvar("usurf_respawn","1")
register_event("DeathMsg","EventDeathMsg","a")
register_clcmd("say /respawn","CmdRespawn")
set_task(1.0,"StandardTimer",_,_,_,"b")
new Ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
if(!Ent)
return
set_pev(Ent,pev_classname,g_SemiclipThinkerClassname)
new Float:Time
global_get(glb_time,Time)
set_pev(Ent,pev_nextthink,Time + 0.01)
dllfunc(DLLFunc_Spawn,Ent)
g_SemiclipThinker = Ent
}
public CheckSurf()
{
new MapName[32]
get_mapname(MapName,31)
if(containi(MapName,"surf") != -1 || containi(MapName,"wurf_") != -1 || equali(MapName,"tentical"))
g_SurfMap = true
return PLUGIN_CONTINUE
}
public ExecCvars()
{
if(get_pcvar_num(p_On) && get_pcvar_num(p_AutoCvars) && g_SurfMap)
{
new ConfigsDir[50],FileLocation[50]
get_configsdir(ConfigsDir,49)
format(FileLocation,49,"%s/surf.cfg",ConfigsDir)
// I'm not going to update this, because the old file
// natives are actually much easier to work with for
// this purpose.
if(file_exists(FileLocation))
server_cmd("exec ^"%s^"",FileLocation)
else
{
write_file(FileLocation,"sv_airaccelerate 100")
write_file(FileLocation,"mp_freezetime 0")
write_file(FileLocation,"amxx pause statsx.amxx")
write_file(FileLocation,"amxx pause miscstats.amxx")
write_file(FileLocation,"amxx pause stats_logging.amxx")
// people seem to be stupid to fucking RTFM, so I really have to disable this by default
write_file(FileLocation,"//humans_join_team ct // if you want all players on one team, use this")
write_file(FileLocation,"echo Executing surf map config.",2)
server_cmd("exec %s",FileLocation)
format(FileLocation,49,"%s/amxx.cfg",ConfigsDir)
if(file_exists(FileLocation))
{
write_file(FileLocation,"// AUTO WRITTEN BY USURF")
write_file(FileLocation,"^n^nhumans_join_team any")
write_file(FileLocation,"sv_airaccelerate 10")
}
}
}
}
public client_disconnect(id)
{
g_Origin[id][0] = 0.0
g_Timing[id] = 0
g_Time[id] = 0
g_Timer[id] = 0
g_LastSave[id] = 0.0
g_Origin[id] = Float:{0.0,0.0,0.0}
}
public TeamHandle(id,Item)
{
// to prevent memory corruption
new Key = Item
new Arg[2]
read_argv(0,Arg,1)
if(Arg[0] == 'j')
{
read_argv(1,Arg,1)
Key = str_to_num(Arg) - 1
}
new TeamStack = get_pcvar_num(p_TeamStack)
if(Key != 5 && Key != TeamStack - 1 && (TeamStack == _:CS_TEAM_T || TeamStack == _:CS_TEAM_CT))
{
client_print(id,print_center,"You must join the %s team.",TeamStack == 1 ? "Terrorist" : "Counter-Terrorist")
engclient_cmd(id,"chooseteam")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public CmdTimer(id)
{
if(!get_pcvar_num(p_Timer) || !get_pcvar_num(p_On) || !g_SurfMap)
return
new Len = format(g_Menu,sizeof g_Menu - 1,"uSurf Timer Menu^n^n1. %s Timer^n",g_Timer[id] ? "Disable" : "Enable")
if(g_Timer[id])
Len += format(g_Menu[Len],sizeof g_Menu - Len - 1,"2. %s Timing^n3. Reset Timer^n",g_Timing[id] ? "Stop" : "Begin")
format(g_Menu[Len],sizeof g_Menu - Len - 1,"^n0. Exit")
new Keys = g_Timer[id] ? MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_0 : MENU_KEY_1|MENU_KEY_0
show_menu(id,Keys,g_Menu,-1,g_TimerMenu)
}
public TimerHandle(id,Key)
{
switch(Key)
{
case 0 :
{
g_Timer[id] = !g_Timer[id]
if(!g_Timer[id])
ShowSyncHudMsg(id,g_HudObject,"")
}
case 1 :
{
g_Timing[id] = !g_Timing[id]
g_Timing[id] ? set_task(g_TimerInterval,"Timer",id + g_TimerTask) : remove_task(id + g_TimerTask)
}
case 2 :
g_Time[id] = 0
}
if(Key != 9)
CmdTimer(id)
}
public Timer(id)
{
g_Time[id - g_TimerTask] += floatround(g_TimerInterval)
set_task(g_TimerInterval,"Timer",id)
}
public CmdSurfhelp(id)
{
if(!get_pcvar_num(p_On) || !get_pcvar_num(p_Help) || !g_SurfMap)
return PLUGIN_CONTINUE
menu_display(id,g_SurfHelpMenu,0)
return PLUGIN_CONTINUE
}
public SurfHelpHandle(id,Menu,Key)
{
static MOTD[4096], Title[16],Pos
switch(Key)
{
case 0 :
{
copy(Title,15,"Surf Help")
Pos = format(MOTD,sizeof MOTD - 1,"Surf Discipline
")
Pos += format(MOTD[Pos],sizeof MOTD - 1 - Pos,"To surf, jump or walk onto one of the curved walls (hereby referted to as 'ramps'). Then simply hold strafe (Default are the A and D keys). This will cause you to glide along the walls, or "surf". ")
Pos += format(MOTD[Pos],sizeof MOTD - 1 - Pos,"While surfing, never press up, down, or crouch; pressing those will cause you to slide off the wall and fall, which, in most surf maps, will cause you to get sent back to your spawn. ")
Pos += format(MOTD[Pos],sizeof MOTD - 1 - Pos,"To change direction (in order to make it to the next ramp), press the button for the direction you wish to go before flying off of your current ramp. ")
Pos += format(MOTD[Pos],sizeof MOTD - 1 - Pos,"Surfing takes pratice, so don't be discouraged if you don't get it right the first time. ")
Pos += format(MOTD[Pos],sizeof MOTD - 1 - Pos,"
Powered by uSurf