|
06-15-2013, 01:42 AM | #1 |
Wiki Standards Team
Wiki Team
Join Date: Mar 2007
Location: Geokill's closet
Class/Position: Sniper/Demoman Gametype: CTF Affiliations: :e0: Co-leader Posts Rated Helpful 6 Times
|
LUA server "plugins"
Is it possible to:
1. Make a lua file that affects all maps of a certain game mode, either by a specially recognized filename, a symbolic link, etc? 2. Make a plugin that does things based on number of players in the server, e.g. if number of player is >= X, do action Y. If number of players is < X, do action Z? |
|
06-15-2013, 05:41 AM | #2 |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
1. A few possibilities:
Code:
local numplayers = 0 for team_id = Team.kBlue, Team.kGreen do numplayers += GetTeam( team_id ):GetNumPlayers() end Code:
local numplayers = 0 for team_id = Team.kSpectator, Team.kGreen do numplayers += GetTeam( team_id ):GetNumPlayers() end Code:
local numplayers = 0 for team_id = Team.kUnassigned, Team.kGreen do numplayers += GetTeam( team_id ):GetNumPlayers() end
__________________
#FF.Pickup ¤ Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington Last edited by squeek.; 06-15-2013 at 05:43 AM. |
|
06-15-2013, 03:05 PM | #3 |
Wiki Standards Team
Wiki Team
Join Date: Mar 2007
Location: Geokill's closet
Class/Position: Sniper/Demoman Gametype: CTF Affiliations: :e0: Co-leader Posts Rated Helpful 6 Times
|
Next question: looking at the documentation for SetTeamClassLimit and SetSmartClassLimit, it says those must go in the startup() function. Is it possible to change class limits via the callback?
Edit: like a simple function that sets a server-side cvar. I see one that sets player cvar, but not one that sets server cvars. Last edited by Agent Buckshot Moose; 06-15-2013 at 03:10 PM. |
|
06-15-2013, 07:54 PM | #4 |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
Class limits can be changed anytime using those functions. The "must be in startup" thing is just for setting up the initial class limits.
To set a server cvar, you can use SetConvar( convar, value ) EDIT: Changing class limits won't immediately enforce those limits (it'll just make it so players wouldn't be able to choose/switch to that class afterwards). To enforce the limit immediately, you'd have to manually switch players playing the now-forbidden class(es) using ApplyToPlayer( player, { AT.kChangeClassSolder, AT.kRespawnPlayers } ) or something like that. This sort of thing is done in ff_ksour to disable scouts on Defense. EDIT#2: The ksour code: in player_spawn: Code:
-- wtf, scout or med on d? are you mental? if (player:GetClass() == Player.kScout or player:GetClass() == Player.kMedic) and (player:GetTeamId() == defenders) then local classt = "Scout" if player:GetClass() == Player.kMedic then classt = "Medic" end local id = player:GetId() AddSchedule("force_changemessage"..id, 2, schedulechangemessage, player, "No "..classt.."s on defense. Autoswitching to Soldier." ) AddSchedule("force_change"..id, 2.5, forcechange, player) end Code:
-- force a scout/med to switch to soli if they haven't function forcechange( player ) if (player:GetClass() == Player.kScout or player:GetClass() == Player.kMedic) and (player:GetTeamId() == defenders) then ApplyToPlayer( player, { AT.kChangeClassSoldier, AT.kRespawnPlayers } ) end end
__________________
#FF.Pickup ¤ Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington Last edited by squeek.; 06-15-2013 at 08:04 PM. |
|
06-15-2013, 08:08 PM | #5 |
Stuff Do-er
Lua Team
Wiki Team Fortress Forever Staff |
By the way, for this sort of thing, understanding and using the concepts in this thread: Altering functions without overwriting them is quite important.
If done right, it'll allow you to use the Lua on any map without breaking anything. If you overwrite an important function like startup, though, things could really break (or if you copy+paste a specific startup function then it'll only work for some maps). It's still not a perfect system, and the base includes should be restructured to allow for easier/more robust manipulating, but that hasn't happened yet.
__________________
#FF.Pickup ¤ Fortress-Forever pickups My Non-official Maps Released FF_DM_Squeek - FF_2Mesa3_Classic - FF_Siege_Classic Beta FF_Myth - FF_Redlight_Greenlight Sick of the people on the internet, always moanin'. They just moan. - Karl Pilkington Last edited by squeek.; 06-15-2013 at 08:08 PM. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|