Ulysses Stuff > Suggestions
Linking the two.
MrPresident:
Here is something I threw together... If UTime stores player time the way I THINK it does this will work... if not, it will take a bit of minor tweaking.. I sent Meg a message, but I think he is asleep.
Megiddo if you see this... Player:GetUTime()... will this return the current seconds the player has? If not, what will? :)
Copy this code into a file and name it promotions.lua and put it in your Garrysmod/lua/autorun folder on your server.
--- Code: ---if SERVER then
function UTimePromotions()
for k, v in pairs(player.GetAll()) do //This grabs a list of all the connected players and will step through them one at a time...
//Lets make sure they aren't in one of the protected groups
if v:IsUserGroup("admin") or v:IsUserGroup("superadmin") or v:IsUserGroup("confirmed minge") then
//Okay, they aren't in one of the protected groups, lets check their time...
else
local timecheck = v:GetUTime() //Returns the user's time in seconds (I hope)
--0/1/5/10/40 these are the times in hours you want to use.
--0/3600/18000/36000/144000 these are the same times in seconds.
--New User(default rank 0 hours)/Starter/Builder/Member/Pro
//Lets compare the users time to the set values to determine if the user should rank up or not.
//Starter Rank 3600 to 18000 seconds
if (timecheck >= 3600) and (timecheck < 18000) and !v:IsUserGroup("starter") then --Only returns true if they are within the time frame for this group and dont already have it.
game.ConsoleCommand("ulx adduser \"" ..v:GetName().. "\" starter\n")
end
//Builder Rank 18000 to 36000 seconds
if (timecheck >= 18000) and (timecheck < 36000) and !v:IsUserGroup("builder") then --Only returns true if they are within the time frame for this group and dont already have it.
game.ConsoleCommand("ulx adduser \"" ..v:GetName().. "\" builder\n")
end
//Member Rank 36000 to 144000 seconds
if (timecheck >= 36000) and (timecheck < 144000) and !v:IsUserGroup("member") then --Only returns true if they are within the time frame for this group and dont already have it.
game.ConsoleCommand("ulx adduser \"" ..v:GetName().. "\" member\n")
end
//Pro Rank 144000 and up seconds
if (timecheck >= 144000) and !v:IsUserGroup("pro") then --Only returns true if they are within the time frame for this group and dont already have it.
game.ConsoleCommand("ulx adduser \"" ..v:GetName().. "\" pro\n")
end
end
end
end
timer.Create( "UTime_AutoPromotions", 60, 0, UTimePromotions ) --Checks time every 60 seconds.
end
--- End code ---
blacksythe:
After looking at this code and trying it out, I am getting an error returned on line 22 its comparing a string to a number ie 18000. im assuming the same error will occur on the consecutive lines with this comparison. Would i be right in saying if i added quotation marks to the number would this fix it.
Megiddo:
--- Quote from: MrPresident on March 31, 2008, 12:14:22 AM ---Megiddo if you see this... Player:GetUTime()... will this return the current seconds the player has? If not, what will? :)
--- End quote ---
Don't remember, sorry. Might look into it tonight though.
* Megiddo adds it to his overflowing todo list.
spbogie:
Just took a look, ply:GetUTime() will return the time that was stored in the db when they joined. ply:GetUTimeStart() will return the game time at which they joined. So, to get their total time you need to do
--- Code: ---local totalTime = ply:GetUTime() + CurTime() - ply:GetUTimeStart()
--- End code ---
MrPresident:
Thanks spbogie. This should work then.
--- Code: ---if SERVER then
function UTimePromotions()
for k, v in pairs(player.GetAll()) do //This grabs a list of all the connected players and will step through them one at a time...
//Lets make sure they aren't in one of the protected groups
if v:IsUserGroup("admin") or v:IsUserGroup("superadmin") or v:IsUserGroup("confirmed minge") then
//Okay, they aren't in one of the protected groups, lets check their time...
else
local timecheck = v:GetUTime() + CurTime() - v:GetUTimeStart()
--0/1/5/10/40 these are the times in hours you want to use.
--0/3600/18000/36000/144000 these are the same times in seconds.
--New User(default rank 0 hours)/Starter/Builder/Member/Pro
//Lets compare the users time to the set values to determine if the user should rank up or not.
//Starter Rank 3600 to 18000 seconds
if (timecheck >= 3600) and (timecheck < 18000) and !v:IsUserGroup("starter") then --Only returns true if they are within the time frame for this group and dont already have it.
game.ConsoleCommand("ulx adduser \"" ..v:GetName().. "\" starter\n")
end
//Builder Rank 18000 to 36000 seconds
if (timecheck >= 18000) and (timecheck < 36000) and !v:IsUserGroup("builder") then --Only returns true if they are within the time frame for this group and dont already have it.
game.ConsoleCommand("ulx adduser \"" ..v:GetName().. "\" builder\n")
end
//Member Rank 36000 to 144000 seconds
if (timecheck >= 36000) and (timecheck < 144000) and !v:IsUserGroup("member") then --Only returns true if they are within the time frame for this group and dont already have it.
game.ConsoleCommand("ulx adduser \"" ..v:GetName().. "\" member\n")
end
//Pro Rank 144000 and up seconds
if (timecheck >= 144000) and !v:IsUserGroup("pro") then --Only returns true if they are within the time frame for this group and dont already have it.
game.ConsoleCommand("ulx adduser \"" ..v:GetName().. "\" pro\n")
end
end
end
end
timer.Create( "UTime_AutoPromotions", 60, 0, UTimePromotions ) --Checks time every 60 seconds.
end
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version