Re: user_scripts on server manager [discussion]
Posted: Wed Oct 28, 2009 10:36 pm
by myers73
as you have probably noticed from all my questions im relatively new to LUA coding, How would you set up the user script por the points.lua?
Hidden/Spoiler:
[code]print("user_script_4: Entered")
--attempt to take control of (or listen to the calls of) the ScriptPostLoad function
if ScriptPostLoad then
print("user_script_4: Taking control of ScriptPostLoad()...")
--check for possible loading errors
if us1_ScriptPostLoad then
print("user_script_4: Warning: Someone else is using our us1_ScriptPostLoad variable!")
print("user_script_4: Exited")
return
end
--backup the current ScriptPostLoad function
us1_ScriptPostLoad = ScriptPostLoad
--this is our new ScriptPostLoad function
ScriptPostLoad = function()
print("user_script_4: ScriptPostLoad(): Entered")
--only do these changes when in SP
--if we wanted them done in MP too, we should check to make sure that we are the server's host: ScriptCB_GetAmHost()
if not ScriptCB_InMultiplayer() then
--if ScriptCB_GetAmHost() then
--build the FakeConsole list
ff_rebuildFakeConsoleList()
--do the FakeConsole commands we want to happen each time a new map starts (when ScriptPostLoad() is normally called)
--
--
--ff_DoCommand( "Lock Vehicles" ) --prevents everyone from entering vehicles (not good on space maps...)
--
--
--ff_DoCommand( "Remove Award Effects" ) --no more graphical hues or annoying sounds when you get awards
--
--
--ff_DoCommand( "cheats.nohud_on" )
--
--
--ff_healthRegen( 30, "humans" )
--
--
--set the max health to 240 for all added unit classes
--for i=1,table.getn(uf_classes) do
-- SetClassProperty(uf_classes, 'MaxHealth', 240)
--
if not __POINTS_LUA__ then
__POINTS_LUA__ = 1
--------------------------------------------------------------------------------
-- Format: { point_gain = number }, --// description
-- Notes: number should between [-128, 127]
-- If you need to ADD/REMOVE items, please ask programmer to change accordingly
-- enum PointStatT in PlayerStats.h
--------------------------------------------------------------------------------
Player_Stats_Points = {
{ point_gain = 10 }, --// PS_GLB_KILL_AI_PLAYER = 0,
{ point_gain = 2 }, --// PS_GLB_KILL_HUMAN_PLAYER,
{ point_gain = 1 }, --// PS_GLB_KILL_HUMAN_PLAYER_AI_OFF,
{ point_gain = -1 }, --// PS_GLB_KILL_SUICIDE,
{ point_gain = -2 }, --// PS_GLB_KILL_TEAMMATE,
--//
{ point_gain = 3 }, --// PS_GLB_VEHICLE_KILL_INFANTRY_VS_VEHICLE,
{ point_gain = 2 }, --// PS_GLB_VEHICLE_KILL_LIGHT_VS_HEAVY,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_LIGHT_VS_MEDIUM,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_HEAVY_VS_LIGHT,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_HEAVY_VS_MEDIUM,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_MEDIUM_VS_LIGHT,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_MEDIUM_VS_HEAVY,
{ point_gain = 10 }, --// PS_GLB_VEHICLE_KILL_ATAT,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_EMPTY,
--//
{ point_gain = 1 }, --// PS_GLB_HEAL,
{ point_gain = 1 }, --// PS_GLB_REPAIR,
--//
{ point_gain = 1 }, --// PS_GLB_SNIPER_ACCURACY,
{ point_gain = 1 }, --// PS_GLB_HEAVY_WEAPON_MULTI_KILL,
{ point_gain = 1 }, --// PS_GLB_RAMPAGE,
{ point_gain = 1 }, --// PS_GLB_HEAD_SHOT,
{ point_gain = 5 }, --// PS_GLB_KILL_HERO,
--//
--// // conquest
{ point_gain = 5 }, --// PS_CON_CAPTURE_CP,
{ point_gain = 2 }, --// PS_CON_ASSIST_CAPTURE_CP,
{ point_gain = 2 }, --// PS_CON_KILL_ENEMY_CAPTURING_CP,
{ point_gain = 2 }, --// PS_CON_DEFEND_CP,
{ point_gain = 1 }, --// PS_CON_KING_HILL,
--//
--// // capture the flag
{ point_gain = 1 }, --// PS_CAP_PICKUP_FLAG,
{ point_gain = 2 }, --// PS_CAP_DEFEND_FLAG,
{ point_gain = 10 }, --// PS_CAP_CAPTURE_FLAG,
{ point_gain = 2 }, --// PS_CAP_DEFEND_FLAG_CARRIER,
{ point_gain = 2 }, --// PS_CAP_KILL_ENEMY_FLAG_CARRIER,
{ point_gain = -12 }, --// PS_CAP_KILL_ALLY_FLAG_CARRIER,
--//
--// // assault
{ point_gain = 10 }, --// PS_Diet Dr. Pepper_DESTROY_ASSAULT_OBJ,
--//
--// // escort
{ point_gain = 2 }, --// PS_ESC_DEFEND,
--//
--// // defend
{ point_gain = 2 }, --// PS_DEF_DEFEND,
}
ScriptCB_SetPlayerStatsPoints( Player_Stats_Points )
Player_Stats_Points = nil
end --if not __POINTS_LUA__
--end
--clear the FakeConsole table to save memory
gConsoleCmdList = {}
end
--make sure to forward the method call to the real ScriptPostLoad, so the game can function normally
us1_ScriptPostLoad()
print("user_script_4: ScriptPostLoad(): Exited")
end
print("user_script_4: Have control of ScriptPostLoad()")
else
print("user_script_4: Warning: No ScriptPostLoad() to take over")
print("user_script_4: Exited")
return
end
print("user_script_4: Exited")[/code]
--attempt to take control of (or listen to the calls of) the ScriptPostLoad function
if ScriptPostLoad then
print("user_script_4: Taking control of ScriptPostLoad()...")
--check for possible loading errors
if us1_ScriptPostLoad then
print("user_script_4: Warning: Someone else is using our us1_ScriptPostLoad variable!")
print("user_script_4: Exited")
return
end
--backup the current ScriptPostLoad function
us1_ScriptPostLoad = ScriptPostLoad
--this is our new ScriptPostLoad function
ScriptPostLoad = function()
print("user_script_4: ScriptPostLoad(): Entered")
--only do these changes when in SP
--if we wanted them done in MP too, we should check to make sure that we are the server's host: ScriptCB_GetAmHost()
if not ScriptCB_InMultiplayer() then
--if ScriptCB_GetAmHost() then
--build the FakeConsole list
ff_rebuildFakeConsoleList()
--do the FakeConsole commands we want to happen each time a new map starts (when ScriptPostLoad() is normally called)
--
--
--ff_DoCommand( "Lock Vehicles" ) --prevents everyone from entering vehicles (not good on space maps...)
--
--
--ff_DoCommand( "Remove Award Effects" ) --no more graphical hues or annoying sounds when you get awards
--
--
--ff_DoCommand( "cheats.nohud_on" )
--
--
--ff_healthRegen( 30, "humans" )
--
--
--set the max health to 240 for all added unit classes
--for i=1,table.getn(uf_classes) do
-- SetClassProperty(uf_classes, 'MaxHealth', 240)
--
if not __POINTS_LUA__ then
__POINTS_LUA__ = 1
--------------------------------------------------------------------------------
-- Format: { point_gain = number }, --// description
-- Notes: number should between [-128, 127]
-- If you need to ADD/REMOVE items, please ask programmer to change accordingly
-- enum PointStatT in PlayerStats.h
--------------------------------------------------------------------------------
Player_Stats_Points = {
{ point_gain = 10 }, --// PS_GLB_KILL_AI_PLAYER = 0,
{ point_gain = 2 }, --// PS_GLB_KILL_HUMAN_PLAYER,
{ point_gain = 1 }, --// PS_GLB_KILL_HUMAN_PLAYER_AI_OFF,
{ point_gain = -1 }, --// PS_GLB_KILL_SUICIDE,
{ point_gain = -2 }, --// PS_GLB_KILL_TEAMMATE,
--//
{ point_gain = 3 }, --// PS_GLB_VEHICLE_KILL_INFANTRY_VS_VEHICLE,
{ point_gain = 2 }, --// PS_GLB_VEHICLE_KILL_LIGHT_VS_HEAVY,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_LIGHT_VS_MEDIUM,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_HEAVY_VS_LIGHT,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_HEAVY_VS_MEDIUM,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_MEDIUM_VS_LIGHT,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_MEDIUM_VS_HEAVY,
{ point_gain = 10 }, --// PS_GLB_VEHICLE_KILL_ATAT,
{ point_gain = 1 }, --// PS_GLB_VEHICLE_KILL_EMPTY,
--//
{ point_gain = 1 }, --// PS_GLB_HEAL,
{ point_gain = 1 }, --// PS_GLB_REPAIR,
--//
{ point_gain = 1 }, --// PS_GLB_SNIPER_ACCURACY,
{ point_gain = 1 }, --// PS_GLB_HEAVY_WEAPON_MULTI_KILL,
{ point_gain = 1 }, --// PS_GLB_RAMPAGE,
{ point_gain = 1 }, --// PS_GLB_HEAD_SHOT,
{ point_gain = 5 }, --// PS_GLB_KILL_HERO,
--//
--// // conquest
{ point_gain = 5 }, --// PS_CON_CAPTURE_CP,
{ point_gain = 2 }, --// PS_CON_ASSIST_CAPTURE_CP,
{ point_gain = 2 }, --// PS_CON_KILL_ENEMY_CAPTURING_CP,
{ point_gain = 2 }, --// PS_CON_DEFEND_CP,
{ point_gain = 1 }, --// PS_CON_KING_HILL,
--//
--// // capture the flag
{ point_gain = 1 }, --// PS_CAP_PICKUP_FLAG,
{ point_gain = 2 }, --// PS_CAP_DEFEND_FLAG,
{ point_gain = 10 }, --// PS_CAP_CAPTURE_FLAG,
{ point_gain = 2 }, --// PS_CAP_DEFEND_FLAG_CARRIER,
{ point_gain = 2 }, --// PS_CAP_KILL_ENEMY_FLAG_CARRIER,
{ point_gain = -12 }, --// PS_CAP_KILL_ALLY_FLAG_CARRIER,
--//
--// // assault
{ point_gain = 10 }, --// PS_Diet Dr. Pepper_DESTROY_ASSAULT_OBJ,
--//
--// // escort
{ point_gain = 2 }, --// PS_ESC_DEFEND,
--//
--// // defend
{ point_gain = 2 }, --// PS_DEF_DEFEND,
}
ScriptCB_SetPlayerStatsPoints( Player_Stats_Points )
Player_Stats_Points = nil
end --if not __POINTS_LUA__
--end
--clear the FakeConsole table to save memory
gConsoleCmdList = {}
end
--make sure to forward the method call to the real ScriptPostLoad, so the game can function normally
us1_ScriptPostLoad()
print("user_script_4: ScriptPostLoad(): Exited")
end
print("user_script_4: Have control of ScriptPostLoad()")
else
print("user_script_4: Warning: No ScriptPostLoad() to take over")
print("user_script_4: Exited")
return
end
print("user_script_4: Exited")[/code]