DarkRP Dictator

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 :slight_smile: (I had Gmod server before, CSS,CSGO and MC)

What is the error ?

Ops sorry


[ERROR] gamemodes/darkrp/gamemode/server/gamemode_functions.lua:499: attempt to call method 'NewData' (a nil value)
  1. unknown - gamemodes/darkrp/gamemode/server/gamemode_functions.lua:499

[ERROR] gamemodes/darkrp/gamemode/shared/commands.lua:75: attempt to call method 'HasPriv' (a nil value)
  1. callback - gamemodes/darkrp/gamemode/shared/commands.lua:75
   2. unknown - gamemodes/darkrp/gamemode/server/chat.lua:138
    3. unknown - lua/includes/modules/concommand.lua:69

The 2nd error show up when I want to type rp_dlockdown / rp_lockdown …

commands.lua:75


        AddChatCommand("/"..CTeam.command, function(ply)            if ply:HasPriv("rp_"..CTeam.command) then
                ply:ChangeTeam(k, true)
                return ""
            end

chat.lua:138


function ConCommand(ply, _, args)    if not args[1] then for k,v in pairs(ChatCommands) do print(k) end return end


    local cmd = string.lower(args[1])
    local arg = table.concat(args, ' ', 2)
    local tbl = ChatCommands[cmd]
    local time = CurTime()


    if not tbl then return end


    ply.DrpCommandDelays = ply.DrpCommandDelays or {}


    if tbl.delay and ply.DrpCommandDelays[cmd] and ply.DrpCommandDelays[cmd] > time - tbl.delay then
        return
    end


    ply.DrpCommandDelays[cmd] = time


    tbl.callback(ply, arg)
end
concommand.Add("darkrp", ConCommand)

gamemode_funtions.lua:499


function GM:PlayerInitialSpawn(ply)	self.BaseClass:PlayerInitialSpawn(ply)
	DB.Log(ply:Nick().." ("..ply:SteamID()..") has joined the game", nil, Color(0, 130, 255))
	ply.bannedfrom = {}
	ply.DarkRPVars = ply.DarkRPVars or {}
	ply:NewData()
	ply.SID = ply:UserID()