• DarkRP Error
    0 replies, posted
Upon starting my server i get this error: ERROR: Gamemode: 'InitPostEntityFailed: DarkRP/gamemode/data.lua:46: bad argument #1 to 'pairs' <table expected, got nil> In the server i can't switch jobs or use any of the other / commands. I don't think my spawn menu works either... I have assmod, CSS realistic weapons, stacker, door, keypad, jihad bomb, keypad_cracker, C4, and Conna's Tools Pack. EDIT: Ok. The Assmod grammar plugin was making the chat commands not work. So i took it out. If anyone knows how to make it work with DarkRP then please share. I still can't open my spawn menu and the HUD doesn't show salary, job, or wallet. EDIT: I got rid of my data.lua error by deleting all the darkrp files then updating them. (svn). Sadly, my error still persists. The HUD doesn't show salary, job, or wallet. I can't open my spawn menu. EDIT: It seems assmod was causing the spawn menu problem. Idk how. Im going to reinstall the server again and see if it works. Here is my data.lua file: include("static_data.lua") DB.privcache = {} /*--------------------------------------------------------- Database initialize ---------------------------------------------------------*/ function DB.Init() sql.Begin() sql.Query("CREATE TABLE IF NOT EXISTS darkrp_settings('key' TEXT NOT NULL, 'value' INTEGER NOT NULL, PRIMARY KEY('key'));") sql.Query("CREATE TABLE IF NOT EXISTS darkrp_globals('key' TEXT NOT NULL, 'value' INTEGER NOT NULL, PRIMARY KEY('key'));") sql.Query("CREATE TABLE IF NOT EXISTS darkrp_tspawns('id' INTEGER NOT NULL, 'map' TEXT NOT NULL, 'team' INTEGER NOT NULL, 'x' NUMERIC NOT NULL, 'y' NUMERIC NOT NULL, 'z' NUMERIC NOT NULL, PRIMARY KEY('id'));") sql.Query("CREATE TABLE IF NOT EXISTS darkrp_privs('steam' TEXT NOT NULL, 'admin' INTEGER NOT NULL, 'mayor' INTEGER NOT NULL, 'cp' INTEGER NOT NULL, 'tool' INTEGER NOT NULL, 'phys' INTEGER NOT NULL, 'prop' INTEGER NOT NULL, PRIMARY KEY('steam'));") sql.Query("CREATE TABLE IF NOT EXISTS darkrp_salaries('steam' TEXT NOT NULL, 'salary' INTEGER NOT NULL, PRIMARY KEY('steam'));") sql.Query("CREATE TABLE IF NOT EXISTS darkrp_wallets('steam' TEXT NOT NULL, 'amount' INTEGER NOT NULL, PRIMARY KEY('steam'));") sql.Query("CREATE TABLE IF NOT EXISTS darkrp_jailpositions('map' TEXT NOT NULL, 'x' NUMERIC NOT NULL, 'y' NUMERIC NOT NULL, 'z' NUMERIC NOT NULL, 'lastused' NUMERIC NOT NULL, PRIMARY KEY('map', 'x', 'y', 'z'));") sql.Query("CREATE TABLE IF NOT EXISTS darkrp_rpnames('steam' TEXT NOT NULL, 'name' TEXT NOT NULL, PRIMARY KEY('steam'));") sql.Query("CREATE TABLE IF NOT EXISTS darkrp_zspawns('map' TEXT NOT NULL, 'x' NUMERIC NOT NULL, 'y' NUMERIC NOT NULL, 'z' NUMERIC NOT NULL);") sql.Query("CREATE TABLE IF NOT EXISTS darkrp_wiseguys('steam' TEXT NOT NULL, 'time' NUMERIC NOT NULL, PRIMARY KEY('steam'));") sql.Query("CREATE TABLE IF NOT EXISTS darkrp_disableddoors('map' TEXT NOT NULL, 'idx' INTEGER NOT NULL, 'title' TEXT NOT NULL, PRIMARY KEY('map', 'idx'));") sql.Query("CREATE TABLE IF NOT EXISTS darkrp_cpdoors('map' TEXT NOT NULL, 'idx' INTEGER NOT NULL, 'title' TEXT NOT NULL, PRIMARY KEY('map', 'idx'));") sql.Commit() DB.CreatePrivs() DB.CreateJailPos() DB.CreateSpawnPos() DB.CreateZombiePos() DB.SetUpNonOwnableDoors() DB.SetUpCPOwnableDoors() --Set default settings RefreshRPSettings() -- load user settings DB.RetrieveGlobals() DB.RetrieveSettings() end /*--------------------------------------------------------- The privileges ---------------------------------------------------------*/ function DB.CreatePrivs() sql.Begin() if reset_all_privileges_to_these_on_startup then sql.Query("DELETE FROM darkrp_privs;") end local already_inserted = {} for k, v in pairs(RPAdmins) do local admin = 0 local mayor = 0 local cp = 0 local tool = 0 local phys = 0 local prop = 0 for a, b in pairs(RPAdmins[k]) do if b == ADMIN then admin = 1 end if b == MAYOR then mayor = 1 end if b == CP then cp = 1 end if b == PTOOL then tool = 1 end if b == PHYS then phys = 1 end if b == PROP then prop = 1 end end if already_inserted[RPAdmins[k]] then sql.Query("UPDATE darkrp_privs SET admin = " .. admin .. ", mayor = " .. mayor .. ", cp = " .. cp .. ", tool = " .. tool .. ", phys = " .. phys .. ", prop = " .. prop .. " WHERE steam = " .. sql.SQLStr(RPAdmins[k]) .. ";") else sql.Query("INSERT INTO darkrp_privs VALUES(" .. sql.SQLStr(k) .. ", " .. admin .. ", " .. mayor .. ", " .. cp .. ", " .. tool .. ", " .. phys .. ", " .. prop .. ");") already_inserted[RPAdmins[k]] = true end end sql.Commit() end function DB.Priv2Text(priv) if priv == ADMIN then return "admin" elseif priv == MAYOR then return "mayor" elseif priv == CP then return "cp" elseif priv == PTOOL then return "tool" elseif priv == PHYS then return "phys" elseif priv == PROP then return "prop" else return nil end end function DB.HasPriv(ply, priv) local SteamID = ply:SteamID() if priv == ADMIN and (ply:EntIndex() == 0 or ply:IsAdmin()) then return true end local p = DB.Priv2Text(priv) if not p then return false end -- If there is a current cache of priveleges if DB.privcache[SteamID] and DB.privcache[SteamID][p] ~= nil then if DB.privcache[SteamID][p] == 1 then return true else return false end -- If there is no cache for this user else local result = tonumber(sql.QueryValue("SELECT " .. sql.SQLStr(p) .. " FROM darkrp_privs WHERE steam = " .. sql.SQLStr(ply:SteamID()) .. ";")) if not DB.privcache[SteamID] then DB.privcache[SteamID] = {} end if result == 1 then DB.privcache[SteamID][p] = 1 return true else DB.privcache[SteamID][p] = 0 return false end end end function DB.GrantPriv(ply, priv) local steamID = ply:SteamID() local p = DB.Priv2Text(priv) if not p then return false end if tonumber(sql.QueryValue("SELECT COUNT(*) FROM darkrp_privs WHERE steam = " .. sql.SQLStr(steamID) .. ";")) > 0 then sql.Query("UPDATE darkrp_privs SET " .. p .. " = 1 WHERE steam = " .. sql.SQLStr(steamID) .. ";") else sql.Begin() sql.Query("INSERT INTO darkrp_privs VALUES(" .. sql.SQLStr(steamID) .. ", 0, 0, 0, 0, 0, 0);") sql.Query("UPDATE darkrp_privs SET " .. sql.SQLStr(p) .. " = 1 WHERE steam = " .. sql.SQLStr(steamID) .. ";") sql.Commit() end -- privelege structure altered, fix the goddamn cache if DB.privcache[steamID] == nil then DB.privcache[steamID] = {} end ply:SetNWBool("Priv"..p, true) DB.privcache[steamID][p] = 1 return true end function DB.RevokePriv(ply, priv) local steamID = ply:SteamID() local p = DB.Priv2Text(priv) local val = tonumber(sql.QueryValue("SELECT COUNT(*) FROM darkrp_privs WHERE steam = " .. sql.SQLStr(steamID) .. ";")) if not p or val < 1 then return false end sql.Query("UPDATE darkrp_privs SET " .. p .. " = 0 WHERE steam = " .. sql.SQLStr(steamID) .. ";") -- privelege structure altered, alter the cache if DB.privcache[steamID] == nil then DB.privcache[steamID] = {} end DB.privcache[steamID][p] = 0 if ply:GetNWBool("Priv"..p) then ply:SetNWBool("Priv"..p, false) end return true end /*--------------------------------------------------------- positions ---------------------------------------------------------*/ function DB.CreateSpawnPos() local map = string.lower(game.GetMap()) if not team_spawn_positions then return end for k, v in pairs(team_spawn_positions) do if v[1] == map then DB.StoreTeamSpawnPos(v[2], Vector(v[3], v[4], v[5])) end end end function DB.CreateZombiePos() if not zombie_spawn_positions then return end local map = string.lower(game.GetMap()) local once = false sql.Begin() for k, v in pairs(zombie_spawn_positions) do if map == string.lower(v[1]) then if not once then sql.Query("DELETE FROM darkrp_zspawns;") once = true end sql.Query("INSERT INTO darkrp_zspawns VALUES(" .. sql.SQLStr(map) .. ", " .. v[2] .. ", " .. v[3] .. ", " .. v[4] .. ");") end end sql.Commit() end fu
Sorry, you need to Log In to post a reply to this thread.