Hello everyone!
I hope it’s correct thread for my topic.
I have an vision how my server should look like. I started from the easiest part which is map. I done my map how I want it to look like but now I have to do much harder step which is coding. I’m trying to add similiar command from Mayors to Dictator. But every time when I’m trying to do this I get errors.
Maybe somone would tell me what’s wrong with it?
Language.lua sample:
lockdown_started = "[L]The mayor has initiated a Lockdown, please return to your homes!", lockdown1_started = "[D]The dictator has initiated a Lockdown, please return to your homes!",
lockdown_ended = "The lockdown has ended",
Main.lua sample:
function GM:dLockdown(ply)
if not lstat and ply:Team() == TEAM_DICTATOR then
for k,v in pairs(player.GetAll()) do
v:ConCommand("play npc/overwatch/cityvoice/f_confirmcivilstatus_1_spkr.wav
")
end
lstat = true
GAMEMODE:PrintMessageAll(HUD_PRINTTALK , LANGUAGE.lockdown1_started)
RunConsoleCommand("DarkRP_dLockDown", 1)
GAMEMODE:NotifyAll(0, 3, LANGUAGE.lockdown1_started)
end
return ""
end
concommand.Add("rp_dlockdown", function(ply) GAMEMODE:dLockdown(ply) end)
AddChatCommand("/dlockdown", function(ply) GAMEMODE:dLockdown(ply) end)
Gamemode_funtions.lua sample
if ply:Team() == TEAM_MAYOR and tobool(GetConVarNumber("DarkRP_LockDown")) then -- Stop the lockdown
GAMEMODE:UnLockdown(ply)
end
if ply:Team() == TEAM_DICTATOR and tobool(GetConVarNumber("DarkRP_dLockDown")) then -- Stop the lockdown
GAMEMODE:UnLockdown(ply)
end
player.lua
function meta:NewData() if not IsValid(self) then return end
self.DarkRPUnInitialized = true
self:RestorePlayerData()
timer.Simple(5, function()
if not IsValid(self) then return end
if GetConVarNumber("DarkRP_dLockdown") == 1 then
RunConsoleCommand("DarkRP_dLockdown", 1) -- so new players who join know there's a lockdown
end
end)
hud.lua
local function dLockDown() local chbxX, chboxY = chat.GetChatBoxPos()
if util.tobool(GetConVarNumber("DarkRP_dLockDown")) then
local cin = (math.sin(CurTime()) + 1) / 2
local chatBoxSize = math.floor(ScrH() / 4)
draw.DrawText(LANGUAGE.lockdown1_started, "ScoreboardSubtitle", chbxX, chboxY + chatBoxSize, Color(cin * 255, 0, 255 - (cin * 255), 255), TEXT_ALIGN_RIGHT)
end
end
commands.lua
CreateConVar("DarkRP_LockDown", 0, {FCVAR_REPLICATED, FCVAR_SERVER_CAN_EXECUTE})
CreateConVar("DarkRP_dLockDown", 0, {FCVAR_REPLICATED, FCVAR_SERVER_CAN_EXECUTE})
I’m sorry that I’m presenting them like this, but I’m not sure if I’m allowed to upload files on this forum?
Please don’t ‘hate’ me I’m just new to LUA with my vision of server (I had Gmod server before, CSS,CSGO and MC)