I am trying to setup a staff on duty command "/staff" where it will set the player's job to "onduty" and store their previous job so when they do "/staff" again it will set them back to their previous job. (Please note I am new to lua, I have done python before but this is still new to me.)
local function StaffOnDuty( ply, text, team)
if string.sub(text, 1, 4) == "/staff" and function(ply) return ply:GetUserGroup() == "owner" or ply:GetUserGroup() == "manager" or ply:GetUserGroup() == "headadmin" or ply:GetUserGroup() == "superadmin" or ply:GetUserGroup() == "admin" or ply:GetUserGroup() == "moderator" or ply:GetUserGroup() == "tempmod" end and function(ply) return not ply:Team == "onduty" then
ply.SetNWString("Previous_job", ply:Team())
RunConsoleCommand("rp_onduty", ply)
else then
if function(ply) return ply:GetUserGroup() == "owner" or ply:GetUserGroup() == "manager" or ply:GetUserGroup() == "headadmin" or ply:GetUserGroup() == "superadmin" or ply:GetUserGroup() == "admin" or ply:GetUserGroup() == "moderator" or ply:GetUserGroup() == "tempmod" end
RunConsoleCommand("rp_" + ply:GetNWString( "Previous_Job", ), ply)
put it in code tags
make your staff play the server instead of flying around being "on duty"
local cachedJob = ""
local onDuty = false
function staffOnDuty(ply, text, _)
if (onDuty) then
RunConsoleCommand("say", "/job Head admin") -- whatever job name is
onDuty = false
else
RunConsoleCommand("say", "/job " .. cachedJob)
cachedJob = getDarkRPVar("job")
onDuty = true
end
end
cachedJob will be one value across the whole server, not a value of a player, so it will only be correct if one guy changes from staff and back, and no one else.
same with onDuty
job name will only set the title of the person's job, meaning they can be a cop with title "Head admin". i don't know if this is what you want but it's what youre doing
if the player is on duty, you "make them a head admin" but then say they're not onDuty
if the player is not on duty, you "make them their previous job", but then say they are onDuty
you use the cachedJob variable before it has a value, this will error in some way
getDarkRPVar('job") returns a table, not a string
RunConsoleCommand will only work on the client
getDarkRPVar is a function of Player. the way you are using it will error.
your function has three arguments, all of which are never used, two of which have no use, and one of which has no name
if this code is already on the client-side, ignore #1, #2, and #8
yeah it would be used clientside, onduty things should be swapped, oops wrote it fast, head admin could be replaced with w/e he wants I was basically writing pseudocode i.e me not filling out his checks for usergroup and w/e else, wasn't trying to spoonfeed him (even though I probably threw him off with the flipped onduty expressions unless he has 1% of an idea of what he's doing)
Sorry, you need to Log In to post a reply to this thread.