• Cron + table
    0 replies, posted
[lua] VIPList = {} 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") 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( "unvip_" .. v:SteamID(), conf, "unvip", v:SteamID() ) table.insert( VIPList, { VIPname = v:Name(), VIPSteamID = v:SteamID(), VIPTime = months, --VIPTimeLeft = } ) PrintMessage( HUD_PRINTTALK, ply:Name() .. " made player ".. v:Name() .. " a VIP for "..months.." months." ) break end end end end hook.Add ( "PlayerSay", "addVIP", addVIP ) [/lua] Hokay, so.. So many threads I have made for this, but it will go a long way when all my questions are answered. By the way, I appreciate all the replies and answers! :) Down to business. First of all, I hope I've done this correctly, if not, don't hesitate to correct! Anyways, I got this table that I want to insert so I can make a list of VIPs and shit. But the thing is, I need help finding out how long the cron has left... Anyone got any ideas? EDIT: Oh, and also I made a "DListView" and I want to make a new line for each VIP. I'm trying to add a line with the information "Name, SteamID, Amount of Months Issued, Time Left" for each VIP. How would I go about doing this? Use this: [lua] local DermaListView = vgui.Create("DListView") DermaListView:SetParent(DermaPanel) DermaListView:SetPos(25, 50) DermaListView:SetSize(450, 625) DermaListView:SetMultiSelect(false) DermaListView:AddColumn("Name") DermaListView:AddColumn("SteamID") DermaListView:AddColumn("Amount of Months") DermaListView:AddColumn("Time Left") [/lua]
Sorry, you need to Log In to post a reply to this thread.