Where do I place this code? I found it somewhere in the Developer Discussion place and I don't know where to put it.
[CODE]hook.Add("DatabaseInitialized", "DarkRP_PersistentJobs", function()
MySQLite.query([[
CREATE TABLE IF NOT EXISTS darkrp_persistentjobs(
uid BIGINT NOT NULL PRIMARY KEY,
job TINYINT UNSIGNED NOT NULL
);
]])
end)
local initialSpawn = GM.PlayerInitialSpawn
function GM:PlayerInitialSpawn(ply)
initialSpawn(self, ply)
MySQLite.query("SELECT job FROM darkrp_persistentjobs WHERE uid = " .. ply:UniqueID() .. ";", function(data)
if not IsValid(ply) then return end
local info = data and data[1] or {}
local teamIndex = info.job or self.DefaultTeam
ply:updateJob(team.GetName(teamIndex))
ply:SetTeam(teamIndex)
if not data then
MySQLite.query([[REPLACE INTO darkrp_persistentjobs VALUES(]] .. ply:UniqueID() .. [[, ]] .. teamIndex .. [[);]])
end
end)
end
hook.Add("OnPlayerChangedTeam", "DarkRP_PersistentJobs", function(ply, _, newTeam)
MySQLite.query([[UPDATE darkrp_persistentjobs SET job = ]] .. newTeam .. [[ WHERE uid = ]] .. ply:UniqueID())
end)[/CODE]
Basically its a perma job system. Do I place it in my gamemodes init.lua? Btw my gamemode is derived by derivedrp which is derived by DarkRP.
[QUOTE=Chal-k;50530539]Do I place it in my gamemodes init.lua?[/QUOTE]
Yes
Sorry, you need to Log In to post a reply to this thread.