[lua\autorun esting.lua:5] attempt to index global ‘cron’ (a nil value)
So I do all that work of getting the cron and shit to work… and now it won’t get cron. SWEET!
[lua]
VIPList = {}
require ‘cron’
cron.RegisterJob( “unvip”, function( sid )
v:SetUserGroup( “user” )
PrintMessage( HUD_PRINTTALK, v:Name()…"'s VIP has expired and revoked." )
end )
local function addVIP( ply, text )
local sep = string.Explode( " “, text )
if sep[1] == (”!ad" or “!add” or “!addv” or “!addvi”) then
draw.SimpleText( “!addvip <name> <# of months>”, “Trebuchet20”, 130, ScrH()*0.827, Color(0,0,0,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
end
if sep[1] == “!addvip” and ply:IsUserGroup( “owner” ) then
local months = tonumber( sep[3] )
if not months then return ply:PrintMessage( HUD_PRINTTALK, “Invalid amount of months.” ) end
local name = table.concat( sep, " ", 2 )
for k,v in pairs( player.GetAll() ) do
if v:Name():lower():find( name:lower() ) then
v:SetUserGroup( "VIP" )
local t = os.date( "*t" )
local conf = {
Minutes = t.min,
Hours = t.hour,
Days = t.day,
Months = (t.month%12 + months)
}
cron.Add( "vip_" .. v:SteamID(), conf, "unvip", v:SteamID() )
local newvip = {}
newvip[ "name" ] = v:GetName()
newvip[ "steamID" ] = v:SteamID()
newvip[ "months" ] = months
newvip[ "timeLeft" ] = ""
table.insert( VIPList, newvip )
PrintMessage( HUD_PRINTTALK, ply:Name() .. " made player ".. v:Name() .. " a VIP for "..months.." months." )
break
end
end
elseif sep[1] == "!vipmenu" and ply:IsUserGroup( "owner" ) then
RunConsoleCommand( "vip_menu" )
elseif sep[1] == "!removevip" and ply:IsUserGroup( "owner" ) then
local name = table.concat( sep, " ", 2 )
for k,v in pairs( player.GetAll() ) do
if v:Name():lower():find( name:lower() ) then
v:SetUserGroup( "user" )
PrintMessage( HUD_PRINTTALK, v:Name().."'s VIP has been revoked forcefully." )
end
end
end
end
hook.Add ( “PlayerSay”, “addVIP”, addVIP )
function VIPMenu()
local VIPMenu = vgui.Create( “DFrame” )
VIPMenu:SetPos( (ScrW()/2) - VIPMenu:GetWide(),(ScrH()/2) - VIPMenu:GetTall() )
VIPMenu:SetSize( 500, 700 )
VIPMenu:SetTitle( “V.I.P. Menu” )
VIPMenu:SetVisible( true )
VIPMenu:SetDraggable( true )
VIPMenu:ShowCloseButton( true )
VIPMenu:MakePopup()
local VIPListView = vgui.Create( "DListView", VIPMenu )
VIPListView:SetPos(25, 50)
VIPListView:SetSize(450, 625)
VIPListView:SetMultiSelect(false)
VIPListView:AddColumn( "Name" ) -- Add column
VIPListView:AddColumn( "SteamID" )
VIPListView:AddColumn( "Time Issued" )
VIPListView:AddColumn( "Time Left [ N/A ]" )
for k,v in pairs( VIPList ) do
VIPListView:AddLine( v.name, v.steamID, v.months, "Working on it. :(" )
end
local button = vgui.Create("DButton", VIPMenu)
button:SetTitle("Remove")
button:SetPos() -- Your pos
button:SetSize( 50, 20 ) -- Your size
button.DoClick = function(btn)
local id = VIPListView:GetSelectedLine() -- Getting the line id
for k,v in pairs( player.GetAll() ) do
if v:SteamID() == VIPList[id].steamID then
v:SetUserGroup( "user" )
end
PrintMessage( HUD_PRINTTALK, VIPList[id].name.."'s VIP has been revoked forcefully." )
cron.Remove( "vip_"..VIPList[id].steamID )
VIPListView:RemoveLine( id )
end
end
end
concommand.Add( “vip_menu”, VIPMenu )
[/lua]