Ulysses Stuff > Releases
Utime Hour Changer Addon :) [2.18v]
Bite That Apple:
Updated addon to current system!
Stranger Danger:
Hey, great module I use it on my server with apromote, people get ranks depending on how long they have played with us. We also give a 4 hour boost to anyone who joins our forums and post an introduction to get more people on there. So I created a module called addtime which I copied a lot of what you had and modified it to, addtime adds the hours specified on top of what they had. This way I can add say 4 hours and they don't lose the 40 min they had into that hour. I hope this is okay and if your interested I can give it to you.
Bite That Apple:
--- Quote from: Stranger Danger on March 13, 2015, 11:23:41 AM ---Hey, great module I use it on my server with apromote, people get ranks depending on how long they have played with us. We also give a 4 hour boost to anyone who joins our forums and post an introduction to get more people on there. So I created a module called addtime which I copied a lot of what you had and modified it to, addtime adds the hours specified on top of what they had. This way I can add say 4 hours and they don't lose the 40 min they had into that hour. I hope this is okay and if your interested I can give it to you.
--- End quote ---
I'd like to see what you've done, maybe I can make it official with your credits on it.
Stranger Danger:
So a few things, for one I set it so it doesn't round the number so I can add .5 hours for a half an hour. This is for if someone does something extra or we sometimes do trivia for small amounts of time I can add say 15 minutes. If you could add something along the lines of !addtime name 15m for 15m that would be amazing. But feel free to add/modify/delete what ever you want, it basically yours.
Also could there be the potential to add time to a group of people? I am not sure how sql works for utime so wasn't sure if that was possible. But maybe a !addtime * or !addtime user.
Here is the code:
--- Code: ------------------------------------add time--------------------------------------
function ulx.addtime( 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
newtime = ply:GetUTimeTotalTime() + ammount
ply:SetUTime( newtime )
ply:SetUTimeStart( CurTime() )
//sql.Query( "UPDATE utime SET totaltime = " .. math.floor(newtime) .. " WHERE player = " .. plyID .. ";" )
updateAll()
table.insert( affected_plys, target_ply )
ulx.fancyLogAdmin( calling_ply, "#A added #s hours to #T", time, affected_plys )
end
local addtime = ulx.command( CATEGORY_NAME, "ulx addtime", ulx.addtime, "!addtime" )
addtime:addParam{ type=ULib.cmds.PlayerArg }
addtime:addParam{ type=ULib.cmds.NumArg, min=0, default=1, hint="Hours" }
addtime:defaultAccess( ULib.ACCESS_SUPERADMIN )
addtime:help( "Add hours to a players time - !addtime" )
--- End code ---
PotatoMan:
Why doesn't this work for me? Someone please help me. I want this because the Utime somehow stuffed up and reset the time:|
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version