Custom ULX commands

Custom ULX commands
mail@pastecode.io avatar
unknown
lua
2 months ago
1.9 kB
3
Indexable
Never
-----------------------------------------------------
--  This File Holds UTIME Commands  	           --
--  Made By Apple Imported By Greg#7474 On Discord --
-----------------------------------------------------

local CATEGORY_NAME = "UTime"

function ulx.settime( calling_ply, target_ply, time )

local affected_plys = {}
function updatePlayer( ply )
sql.Query( "UPDATE utime SET totaltime = " .. math.floor( ply:GetUTimeTotalTime() ) .. " WHERE player = " .. ply:UniqueID() .. ";" )
end

function updateAll()
local players = player.GetAll()

for _, ply in ipairs( players ) do
if ply and ply:IsConnected() then
updatePlayer( ply )
end
end
end

local plyID = tostring(target_ply:UniqueID())
local ply = player.GetByUniqueID(plyID)
local ammount = tonumber(tostring(time))
ammount = ammount * 3600
ply:SetUTime( ammount )
ply:SetUTimeStart( CurTime() )

  sql.Query( "UPDATE utime SET totaltime = " ..  math.floor(ammount)  .. " WHERE player = " .. plyID .. ";" )
  updateAll()
table.insert( affected_plys, target_ply )
ulx.fancyLogAdmin( calling_ply, "#A set #T's hours to #s", affected_plys, time )
end

local settime = ulx.command( CATEGORY_NAME, "ulx settime", ulx.settime, {"!utimeset", "!setutime", "!sethours", "!settime"} )
settime:addParam{ type=ULib.cmds.PlayerArg }
settime:addParam{ type=ULib.cmds.NumArg, min=0, default=1, hint="Hours", ULib.cmds.round }
settime:defaultAccess( ULib.ACCESS_SUPERADMIN )
settime:help( "Change a player's hours. - !settime" )

function ulx.downtime( calling_ply, should_revoke )

	if not should_revoke then
		RunConsoleCommand("ulx", "tsaycolor", "[SERVER] It is now Downtime.", "green")
	else
		RunConsoleCommand("ulx", "tsaycolor", "[SERVER] It is no longer Downtime! Go RP.", "red")
	end
	
	if not should_revoke then
		RunConsoleCommand("ulx", "tellall", "It is now Downtime.")
	else
		RunConsoleCommand("ulx", "tellall", "It is no longer Downtime! Go RP.")
	end
	
end

Leave a Comment