[lua]
function addVIP( ply, saywhat )
local Sep = string.Explode( " ", command )
if Sep[1] == "!addvip" then
Sep[1] = "" local
if Sep[2] == "1month" then
elseif Sep[2] == "6month" then
elseif Sep[2] == "1year" then
end
Sep[2] = ""
Imp = string.Implode( " ", Imp )
end
for k,v inpairs( player.GetAll() ) do
if string.find(v:Name(),Imp) then
v:SetUserGroup( "VIP" )
PrintMessage( HUD_PRINTTALK, ply.." made player "..v:Name().." a VIP." )
end
end
end
hook.Add ( "PlayerSay", "addBan", addVIP )
require 'cron'
cron.RegisterJob( 'unvip', function( sid )
ply:SetUserGroup( "user" )
end )
local t = os.date( "*t" )
local confmonth = {
Minutes = t.min,
Hours = t.hour,
Days = t.day,
Months = (t.month%12 + 1)
}
cron.Add( "unvip_" .. v:SteamID().."_month", confmonth, "unvip", v:SteamID() )
[/lua]
So I have this, but how do I call the cron by it's id? What is the function or w.e I'm supposed to do. I know the ID will be "unvip_".. v:SteamID() .. "_month" but what do I do with the ID to start the clock so to say.
P.S. Yes, I had another thread leading to this question, which was left unanswered and now it's pages back so I decided to post another thread. I'm sorry if this isn't allowed, I'm new and I'm not really sure.
[QUOTE=InfernalCookie;28027844]So I have this, but how do I call the cron by it's id? What is the function or w.e I'm supposed to do. I know the ID will be "unvip_".. v:SteamID() .. "_month" but what do I do with the ID to start the clock so to say.
P.S. Yes, I had another thread leading to this question, which was left unanswered and now it's pages back so I decided to post another thread. I'm sorry if this isn't allowed, I'm new and I'm not really sure.[/QUOTE]
Calling cron.Add starts the timer, so you call in the command to make the player a VIP. Although, your method won't work because the usergroups in vanilla GMod aren't saved over sessions.
[QUOTE=raBBish;28028015]Calling cron.Add starts the timer, so you call in the command to make the player a VIP. Although, your method won't work because the usergroups in vanilla GMod aren't saved over sessions.[/QUOTE]
This will be in a TTT server using an admin mod that I'm unsure of because I'm just making it for him.
And if I call in the command to make a player a VIP how is that going to start the timer? Let me post the entire code I've so far.
[QUOTE=InfernalCookie;28028081]This will be in a TTT server using an admin mod that I'm unsure of because I'm just making it for him.[/QUOTE]
Depends on how the admin mod handles usergroups.
[QUOTE=InfernalCookie;28028081]And if I call in the command to make a player a VIP how is that going to start the timer? Let me post the entire code I've so far.[/QUOTE]
You add the cron.Add code inside the command.
Erm, I'm not sure how to edit my code to do this. I have it all in the PlayerSay hook... Mind helping me out?
EDIT:
Derp'ed again... I think I just saw a way... hold on. Okay, would this be right?
[lua]
cron.RegisterJob( 'unvip', function( sid )
v:SetUserGroup( "user" )
end )
local t = os.date( "*t" ) -- table of current date and time
local confmonth = {
Minutes = t.min, -- run at the same minute,
Hours = t.hour, -- same hour,
Days = t.day, -- and day
Months = (t.month%12 + 1) -- but add one to month
}
local conf6month = {
Minutes = t.min,
Hours = t.hour,
Days = t.day,
Months = (t.month%12 + 6)
}
local confyear = {
Minutes = t.min,
Hours = t.hour,
Days = t.day,
Months = (t.month%12 + 12)
}
function addVIP( ply, saywhat )
local Sep = string.Explode( " ", command )
if Sep[1] == "!addvip" then
Sep[1] = "" local
if Sep[2] == "1month" then
cron.Add( "unvip_" .. v:SteamID().."_month", confmonth, "unvip", v:SteamID() )
elseif Sep[2] == "6month" then
cron.Add( "unvip_" .. v:SteamID() .. "_6month", conf6month, "unvip", v:SteamID() )
elseif Sep[2] == "1year" then
cron.Add( "unvip_".. v:SteamID() .."_year", confyear, "unvip", v:SteamID() )
end
Sep[2] = ""
Imp = string.Implode( " ", Imp )
end
for k,v inpairs( player.GetAll() ) do
if string.find(v:Name(),Imp) then
v:SetUserGroup( "VIP" )
PrintMessage( HUD_PRINTTALK, ply.." made player "..v:Name().." a VIP." )
end
end
end
hook.Add ( "PlayerSay", "addBan", addVIP )
[/lua]
This should work for the cron part. I'll leave the usergroup stuff for you to figure out.
[lua]cron.RegisterJob( "unvip", function( sid )
--v:SetUserGroup( "user" )
end )
local function addVIP( ply, text )
local sep = string.Explode( " ", text )
if sep[1] == "!addvip" then
local months = tonumber( sep[2] )
if not months then return end -- invalid amount of months
local name = table.concat( sep, " ", 3 )
for k,v in pairs( player.GetAll() ) do
if v:Name():lower():find( name:lower() ) then
-- v:SetUserGroup( "VIP" )
local t = os.date( "*t" ) -- table of current date and time
local conf = {
Minutes = t.min,
Hours = t.hour,
Days = t.day,
Months = (t.month%12 + months)
}
cron.Add( "unvip_" .. v:SteamID(), conf, "unvip", v:SteamID() )
PrintMessage( HUD_PRINTTALK, ply:Name() .. " made player ".. v:Name() .. " a VIP." )
break -- if we only want one player to become VIP, break here
end
end
end
end
hook.Add ( "PlayerSay", "addVIP", addVIP )[/lua]
Holy shit, that is nothing close to what I had....
Sorry, you need to Log In to post a reply to this thread.