• cron a nil value?
    4 replies, posted
[lua\autorun\testing.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]
At line 3, you have, [lua]require 'cron'[/lua] which should be, [lua]require( 'cron' )[/lua]
[QUOTE=wakeboarderCWB;28145567]At line 3, you have, [lua]require 'cron'[/lua] which should be, [lua]require( 'cron' )[/lua][/QUOTE] That's not an issue. If there is only one argument to a function, and it is a string, you don't need to wrap it in parenthesis. There isn't a default cron module in the game, so that is probably the issue there. Assuming a custom module, make sure you have it installed correctly.
Well great.. The person that told me to use cron never told me that i had to install a custom module... I have no idea how to install and where to get it. EDIT: Dun Derp'ed; I didn't download the cron module that he had posted on my thread I asked about it in. Downloading and testing now.
-snip, nevermind-
Sorry, you need to Log In to post a reply to this thread.