Kingin~~ Posted October 13, 2016 Share Posted October 13, 2016 (edited) So I made F1 with updates info tab with rules etc.. But the problem is that the GUI doesnt open with F1 bindkey idk whats the problem only opens with command Client side Spoiler local screenW, screenH = guiGetScreenSize() rule = guiCreateWindow((screenW - 799) / 2, (screenH - 604) / 2, 799, 604, "CIP Rules / Updates", false) guiWindowSetMovable(rule, false) guiWindowSetSizable(rule, false) guiSetAlpha(rule, 0.90) tabpanel = guiCreateTabPanel(9, 22, 780, 572, false, rule) tab1 = guiCreateTab("Help", tabpanel) grid = guiCreateGridList(12, 121, 374, 417, false, tab1) guiGridListSetSelectionMode(grid, 1) guiGridListSetSortingEnabled(grid, false) colum = guiGridListAddColumn(grid, "Question", 0.9) for index, val in pairs(griditem) do local row = guiGridListAddRow(grid) guiGridListSetItemText(grid, row, colum, val[1], false, false) end guiSetVisible(rule, false) tab2 = guiCreateTab("Updates", tabpanel) memo3 = guiCreateMemo(10, 10, 760, 528, "", false, tab2) guiMemoSetReadOnly(memo3, true) guiSetVisible( rule, false ) memo = guiCreateMemo(407, 131, 363, 407, "Click on a question on the right to see the answer here.", false, tab1) close1 = guiCreateTab("close", tabpanel) search = guiCreateEdit(9, 59, 285, 32, "", false, tab1) labelXl = guiCreateLabel(10, 22, 383, 37, "Enter key words like 'vehicle' to find answers:", false, tab1) guiSetFont(labelXl, "clear-normal") LabelXLL = guiCreateLabel(396, 34, 374, 91, " If your question isn't answered here, press 'Close',\n press 'J', make sure you're on the 'Support' channel,\n ask your question there and another player will respond.", false, tab1) guiSetFont(LabelXLL, "clear-normal") guiMemoSetReadOnly (memo, true) addEventHandler("onClientGUIClick", grid, clickedGridlist, false) addEventHandler("onClientGUIClick", ttt, function () guiSetVisible(rule, false) showCursor(false) end, false) addEventHandler("onClientGUIClick", tabpanel, changeTab, false) end ) function clickedGridlist() if (guiGridListGetSelectedItem(grid) == -1) then return end local row = guiGridListGetSelectedItem(source) local info = guiGridListGetItemText(grid, row, colum) for index, val in pairs(griditem) do if (info == val[1]) then guiSetText(memo, xmlNodeGetValue( xmlLoadFile( val[2] ) ) or "Error while loading file" ) end end end function changeTab() local selectedTab = guiGetSelectedTab(tabpanel) if (selectedTab == close1) then guiSetVisible(rule, false) showCursor(false) return true end lastSelectedTab = guiGetSelectedTab(tabpanel) end -- When a combo is selected addEventHandler ( "onClientGUIComboBoxAccepted", root, function ( theCombo ) if ( theCombo == combo ) then local theItem = guiComboBoxGetSelected ( theCombo ) local theLang = tostring ( guiComboBoxGetItemText ( theCombo , theItem ) ) if ( rulesToFile[theLang] ) then guiSetText( memo, xmlNodeGetValue( xmlLoadFile( rulesToFile[theLang] ) ) or "Error while loading file" ) end end end ) function showSupports() guiSetVisible(rule, false) showCursor(false) triggerEvent("showSupportChat", root) end addEventHandler("onClientGUIChanged", resourceRoot, function() local text = guiGetText(search) local sItems = { } for i, v in pairs(griditem) do if not (text == "" ) then if (string.find(string.upper(v[1]), string.upper(text), 1, true)) then table.insert(sItems, v[1]) end else table.insert(sItems, v[1]) end end guiGridListClear(grid) for i, v in pairs(sItems) do local row = guiGridListAddRow(grid) guiGridListSetItemText(grid, row, 1, v, false, false) end end) updatesMemo = "" currentDate = "" local sx, sy = guiGetScreenSize ( ) local screenW, screenH = guiGetScreenSize ( ) local currentList = { } row = 0 row2 = 0 -- Tables local main = {} local read = { } local add = { button = {}, edit = {} } local remove = { button = {} } -- View Panel main.window = guiCreateWindow((screenW - 587) / 2, (screenH - 447) / 2, 587, 447, "CIP Server Recent Updates", false) guiWindowSetMovable ( main.window, false ) guiWindowSetSizable(main.window, false) guiSetVisible ( main.window, false ) guiMemoSetReadOnly(memo3,true) main.close = guiCreateButton(0.3101, 0.9224, 0.3748, 0.0587, "Close", true, main.window) add.window = guiCreateWindow( ( sx / 2 - 482 / 2 ), ( sy / 2 - 571 / 2 ), 482, 571, "CIP Updates adden", false) guiWindowSetSizable(add.window, false) guiSetVisible ( add.window, false ) guiCreateLabel(10, 32, 145, 15, "Date (DD/MM/YYYY):", false, add.window) add.edit['date'] = guiCreateEdit(9, 53, 454, 28, "", false, add.window) guiCreateLabel(10, 103, 145, 15, "Update:", false, add.window) add.edit['update'] = guiCreateMemo(13, 125, 450, 294, "", false, add.window) guiCreateLabel(10, 449, 145, 15, "Author:", false, add.window) add.edit['author'] = guiCreateEdit(9, 468, 454, 28, "", false, add.window) add.button['add'] = guiCreateButton(12, 508, 143, 44, "Add Update", false, add.window) add.button['cancel'] = guiCreateButton(165, 508, 143, 44, "Cancel/close", false, add.window) add.button['remove'] = guiCreateButton(320, 508, 143, 44, "Remove a update", false, add.window) -- Remove Panel remove.window = guiCreateWindow( ( sx / 2 - 552 / 2 ), ( sy / 2 - 533 / 2 ), 552, 533, "CIP Remove Update", false) guiWindowSetSizable(remove.window, false) guiSetVisible ( remove.window, false ) remove.grid = guiCreateGridList(10, 28, 532, 443, false, remove.window) guiGridListAddColumn(remove.grid, "Date", 0.18) guiGridListAddColumn(remove.grid, "Update", 0.58) guiGridListAddColumn(remove.grid, "Developer", 0.2) remove.button['remove'] = guiCreateButton(376, 481, 166, 36, "Remove", false, remove.window) guiSetProperty(remove.button['remove'], "NormalTextColour", "FFFF0000") remove.button['back'] = guiCreateButton(10, 481, 166, 36, "Add a update", false, remove.window) -- Read More read.window = guiCreateWindow( ( sx / 2 - 407 / 2 ), ( sy / 2 - 397 / 2 ), 407, 397, "Read More", false) guiWindowSetSizable(read.window, false) guiSetVisible ( read.window, false ) guiSetAlpha ( read.window, 1 ) guiWindowSetMovable ( read.window, false ) read.date = guiCreateLabel(9, 35, 275, 25, "Date: Loading..", false, read.window) read.author = guiCreateLabel(9, 70, 388, 25, "Developer: Loading...", false, read.window) guiCreateLabel(9, 105, 388, 25, "Update:", false, read.window) read.update = guiCreateMemo(9, 127, 388, 253, "Loading..", false, read.window) guiMemoSetReadOnly(read.update, true) read.close = guiCreateButton(294, 25, 103, 35, "Exit", false, read.window) days = {"1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st"} months = {"January","February","March","April","May","June","July","August","September","October","November","December"} function CIPaccountsExport(ag1) updatesMemo = "" if (type(ag1) == 'table') then currentList = { } local updates = { } for index, variable in ipairs(ag1) do local lol = updates updates = { } table.insert(updates, {variable['Date_'], variable['Name'], variable['Developer']}) for i, v in ipairs(lol) do table.insert(updates, v) end end for i,v in ipairs(updates) do d, m, y = string.match(v[1], "(%d+)/(%d+)/(%d+)") performdate = getdayofweek(d,m,y).." "..days[tonumber(d)].." "..months[tonumber(m)].." "..y if currentDate ~= v[1] then currentDate = v[1] if row2 == 0 then updatesMemo = updatesMemo.. "".. performdate.."\n" else updatesMemo = updatesMemo.. "\n".. performdate.."\n" end end three = string.gsub(v[3],"%[","") three = string.gsub(three,"%]","") three = string.gsub(three,"CIP","") three = string.gsub(three,"CIP","") str = "- "..v[2].." ("..three..")" updatesMemo = updatesMemo ..string.gsub(str,"\n","").."\n" row2 = row2 + 1 triggerEvent("CIPaccounts.GetUpdates", source, updatesMemo) end currentList = updates end end addEvent("CIPupdates.CIPacc", true) addEventHandler("CIPupdates.CIPacc", root, CIPaccountsExport) addEvent ( "Updates:onPanelChangeState", true ) addEventHandler ( "Updates:onPanelChangeState", root, function ( window, ag1 ) guiSetText(memo3,"") guiSetInputMode("no_binds_when_editing") updatesMemo = "" if ( window == 'main' ) then if ( guiGetVisible ( add.window ) ) then guiSetVisible ( add.window, false ) showCursor ( false ) end if ( guiGetVisible ( remove.window ) ) then guiSetVisible ( remove.window, false ) showCursor ( false ) end guiSetSelectedTab(tabpanel, tab2) guiSetVisible ( rule, true ) showCursor ( true ) if ( type ( ag1 ) == 'table' ) then currentList = { } -- Reverse the loop -- local updates = { } for index, variable in ipairs ( ag1 ) do local lol = updates updates = { } table.insert ( updates, { variable['Date_'], variable['Name'], variable['Developer'] } ) for i, v in ipairs ( lol ) do table.insert ( updates, v ) end end for i,v in ipairs ( updates ) do d, m, y = string.match(v[1], "(%d+)/(%d+)/(%d+)") performdate = getdayofweek(d,m,y).." "..days[tonumber(d)].." "..months[tonumber(m)].." "..y if currentDate ~= v[1] then currentDate = v[1] if row == 0 then updatesMemo = updatesMemo.. "".. performdate.."\n" else updatesMemo = updatesMemo.. "\n".. performdate.."\n" end end three = string.gsub(v[3],"%[","") three = string.gsub(three,"%]","") three = string.gsub(three,"CIP","") three = string.gsub(three,"CIP","") str = "- "..v[2].." ("..three..")" updatesMemo = updatesMemo ..string.gsub(str,"\n","").."\n" row = row + 1 guiSetText(memo3, updatesMemo) end currentList = updates else guiSetText ( memo3, "Failed to load updates" ) end elseif ( window == 'manager' ) then if ( guiGetVisible ( remove.window ) ) then return end if ( guiGetVisible ( rule ) ) then guiSetVisible ( rule, false ) showCursor ( false ) end if ( guiGetVisible ( read.window ) ) then guiSetVisible ( read.window, false ) end guiSetVisible ( add.window, true ) showCursor ( true ) local text = getElementData(localPlayer, "account") guiSetText ( add.edit['author'], getPlayerName(getLocalPlayer()) ) local time = getRealTime ( ) local day = time.monthday local month = time.month + 1 local year = time.year + 1900 if ( day < 10 ) then day = 0 .. day end if ( month < 10 ) then month = 0 .. month end guiSetText ( add.edit['date'], table.concat ( { day, month, year }, "/" ) ) guiSetInputMode ( "no_binds_when_editing" ) end end ) addEvent ( "Updates:onPanelChangeState1", true ) addEventHandler ( "Updates:onPanelChangeState1", root, function ( window, ag1 ) guiSetText(memo3,"") guiSetInputMode("no_binds_when_editing") updatesMemo = "" if ( window == 'main' ) then if ( guiGetVisible ( add.window ) ) then guiSetVisible ( add.window, false ) showCursor ( false ) end if ( guiGetVisible ( remove.window ) ) then guiSetVisible ( remove.window, false ) showCursor ( false ) end guiSetSelectedTab(tabpanel, tab1) guiSetVisible ( rule, true ) showCursor ( true ) if ( type ( ag1 ) == 'table' ) then currentList = { } -- Reverse the loop -- local updates = { } for index, variable in ipairs ( ag1 ) do local lol = updates updates = { } table.insert ( updates, { variable['Date_'], variable['Name'], variable['Developer'] } ) for i, v in ipairs ( lol ) do table.insert ( updates, v ) end end for i,v in ipairs ( updates ) do d, m, y = string.match(v[1], "(%d+)/(%d+)/(%d+)") performdate = getdayofweek(d,m,y).." "..days[tonumber(d)].." "..months[tonumber(m)].." "..y if currentDate ~= v[1] then currentDate = v[1] if row == 0 then updatesMemo = updatesMemo.. "".. performdate.."\n" else updatesMemo = updatesMemo.. "\n".. performdate.."\n" end end three = string.gsub(v[3],"%[","") three = string.gsub(three,"%]","") three = string.gsub(three,"CIP","") three = string.gsub(three,"CIP","") str = "- "..v[2].." ("..three..")" updatesMemo = updatesMemo ..string.gsub(str,"\n","").."\n" row = row + 1 guiSetText(memo3, updatesMemo) end currentList = updates else guiSetText ( memo3, "Failed to load updates" ) end elseif ( window == 'manager' ) then if ( guiGetVisible ( remove.window ) ) then return end if ( guiGetVisible ( rule ) ) then guiSetVisible ( rule, false ) showCursor ( false ) end if ( guiGetVisible ( read.window ) ) then guiSetVisible ( read.window, false ) end guiSetVisible ( add.window, true ) showCursor ( true ) local text = getElementData(localPlayer, "account") guiSetText ( add.edit['author'], getPlayerName(getLocalPlayer()) ) local time = getRealTime ( ) local day = time.monthday local month = time.month + 1 local year = time.year + 1900 if ( day < 10 ) then day = 0 .. day end if ( month < 10 ) then month = 0 .. month end guiSetText ( add.edit['date'], table.concat ( { day, month, year }, "/" ) ) guiSetInputMode ( "no_binds_when_editing" ) end end ) addEventHandler ( 'onClientGUIClick', root, function ( btn ) if ( btn == 'left' ) then -- Main Panel if ( source == main.readmore ) then local row, col = guiGridListGetSelectedItem ( memo3 ) if ( row ~= -1 and col ~= 0 ) then guiSetVisible ( read.window, true ) guiBringToFront ( read.window ) guiSetText ( read.date, "Date: "..guiGridListGetItemText ( memo3, row, 1 ) ) guiSetText ( read.update, guiGridListGetItemText ( memo3, row, 2 ) ) guiSetText ( read.author, "Developer: "..guiGridListGetItemText ( memo3, row, 3 ) ) else outputChatBox ( "Select an update.", 255, 255, 0 ) end elseif ( source == read.close ) then guiSetVisible ( read.window, false ) elseif ( source == main.close ) then guiSetText(memo3,"") row = 0 guiSetVisible ( rule, false ) showCursor ( false ) if ( guiGetVisible ( read.window ) ) then guiSetVisible ( read.window, false ) end -- Adding Panel elseif ( source == add.button['cancel'] ) then guiSetVisible ( add.window, false ) showCursor ( false ) elseif ( source == add.button['add'] ) then local date, update, author = guiGetText ( add.edit['date'] ), guiGetText ( add.edit['update'] ), guiGetText ( add.edit['author'] ) if ( date ~= '' and update ~= '' and author ~= '' ) then triggerServerEvent ( "Updates:onServerEvent", localPlayer, 'addUpdate', { date, update, author } ) else outputChatBox ( "You need to enter all of the information.", 255, 0, 0 ) end elseif ( source == add.button['remove'] ) then guiSetVisible ( add.window, false ) guiSetVisible ( remove.window, true ) guiGridListClear ( remove.grid ) if ( currentList and #currentList > 0 ) then for index, var in ipairs ( currentList ) do local row = guiGridListAddRow ( remove.grid ) guiGridListSetItemText ( remove.grid, row, 1, var[1], false, false ) guiGridListSetItemText ( remove.grid, row, 2, var[2], false, false ) guiGridListSetItemText ( remove.grid, row, 3, var[3], false, false ) end else guiGridListSetItemText ( remove.grid, guiGridListAddRow ( remove.grid ), 2, "Please use /updates, then come back to this panel.", true, true ) guiGridListSetItemColor ( remove.grid, 0, 2, 255, 0, 0 ) end -- remove panel elseif ( source == remove.button['back'] ) then guiSetVisible ( remove.window, false ) guiSetVisible ( add.window, true ) elseif ( source == remove.button['remove'] ) then local row, col = guiGridListGetSelectedItem ( remove.grid ) if ( row ~= -1 and col ~= 0 ) then local date = guiGridListGetItemText ( remove.grid, row, 1 ) local update = guiGridListGetItemText ( remove.grid, row, 2 ) local author = guiGridListGetItemText ( remove.grid, row, 3 ) for index, var in ipairs ( currentList ) do if ( var[1] == date and var[2] == update and var[3] == author ) then table.remove ( currentList, index ) break end end guiGridListClear ( remove.grid ) if ( #currentList > 0 ) then for index, var in ipairs ( currentList ) do local row = guiGridListAddRow ( remove.grid ) guiGridListSetItemText ( remove.grid, row, 1, var[1], false, false ) guiGridListSetItemText ( remove.grid, row, 2, var[2], false, false ) guiGridListSetItemText ( remove.grid, row, 3, var[3], false, false ) end else guiGridListSetItemText ( remove.grid, guiGridListAddRow ( remove.grid ), 2, "No updates found.", true, true ) end triggerServerEvent ( 'Updates:onServerEvent', localPlayer, 'removeUpdate', { date, update, author } ) end end end end ) function getdayofweek(dd, mm, yy) local days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } local mmx = mm if (mm == 1) then mmx = 13; yy = yy-1 end if (mm == 2) then mmx = 14; yy = yy-1 end local val8 = dd + (mmx*2) + math.floor(((mmx+1)*3)/5) + yy + math.floor(yy/4) - math.floor(yy/100) + math.floor(yy/400) + 2 local val9 = math.floor(val8/7) local dw = val8-(val9*7) if (dw == 0) then dw = 7 end return days[dw] end Server side: Spoiler days = {"1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st"} months = {"January","February","March","April","May","June","July","August","September","October","November","December"} function outputRoot ( msg, chatbox ) outputDebugString ( msg ) outputConsole ( msg ) outputServerLog ( msg ) if ( chatbox ) then outputChatBox ( msg ) end return true end -- Connect database. addEventHandler ( "onResourceStart", resourceRoot, function ( ) local saveMode_ = string.lower ( saveMode ) if ( saveMode_ == 'mysql' ) then dbc = dbConnect ( 'mysql', "host="..host..";dbname="..databaseName, username, password ) elseif ( saveMode_ == 'sqlite' ) then dbc = dbConnect ( "sqlite", "updatesDB.db" ) else return outputRoot ( "Server Updates: "..saveMode.." is an invalid saving method. Valid: MySQL | SQLite - Change in settings.lua." ) end -- Check Database if ( dbc ) then outputRoot ( "Server Updates: "..saveMode.." has successfully connected.", false ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS updates ( Date_ TEXT, Name TEXT, Developer TEXT, AddedBy TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS selling ( userid TEXT, item TEXT, amount TEXT, price TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS banking ( userid TEXT, balance TEXT, creditcard TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS banking_transactions ( userid TEXT, transaction TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS squad_bl ( squad_name TEXT, acc TEXT, byc TEXT, date TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS squad_log ( squad_name TEXT, action TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS group_bl ( group_name TEXT, acc TEXT, byc TEXT, date TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS group_bank ( group_name TEXT, balance INTEGER )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS group_log ( group_name TEXT, action TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS mapeditor ( id INTEGER, model TEXT, x INTEGER, y INTEGER, z INTEGER, rx INTEGER, ry INTEGER, rz INTEGER, dim INTEGER, interior INTEGER, descr TEXT, proj TEXT, edAcc TEXT, eType TEXT, cData TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS accounts ( id TEXT, cjskin TEXT, x INTEGER, y INTEGER, z INTEGER, interior INTEGER, dimension INTEGER, email TEXT, password TEXT, jobskin TEXT, username TEXT, serial INTEGER, skin INTEGER )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS weapons ( userid INTEGER, weapon TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS playerstats ( laser INTEGER, userid TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS punishlogs ( log TEXT, acc TEXT, id INTEGER, player TEXT, admin TEXT, type TEXT, reason TEXT, serial TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS staffList ( staff TEXT, acc TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS banking_transactions ( userid TEXT, transaction INTEGER )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS banking ( userid TEXT, balance INTEGER, creditcard INTEGER )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS events ( name TEXT, data TEXT )" ) else outputRoot ( "Server Updates: "..saveMode.." has failed to connected.", true ) end end ) dbc = dbConnect ( "sqlite", "updates.db" ) function getUpdates ( ) return dbPoll ( dbQuery ( dbc, "SELECT * FROM updates" ), -1 ) end addCommandHandler ( "updates", function ( p ) local updates = getUpdates ( ) triggerClientEvent ( p, 'Updates:onPanelChangeState', p, 'main', updates ) end ) addCommandHandler ( "rules", function ( p ) local updates = getUpdates ( ) triggerClientEvent ( p, 'Updates:onPanelChangeState1', p, 'main', updates ) end ) function CIPacc(source) local updates = getUpdates() if updates then triggerClientEvent(source, 'CIPupdates.CIPacc', source, updates) else local updates2 = dbPoll(dbQuery(dbc, "SELECT * FROM updates"), -1) triggerClientEvent(source, 'CIPupdates.CIPacc', source, updates2) end end addEvent("CIPupdates.exprt", true) addEventHandler("CIPupdates.exprt", root, CSCacc) addCommandHandler ( "updatemanager", function ( p ) local isAllowed = false; for _, acl in ipairs ( allowedACLS ) do if ( isPlayerInACL ( p, acl ) ) then isAllowed = true break end end if ( isAllowed ) then local updates = getUpdates ( ) triggerClientEvent ( p, 'Updates:onPanelChangeState', p, 'manager', updates ) end end ) function addUpdate ( player, date, update, author ) local accnt = getAccountName ( getPlayerAccount ( player ) ) dbExec ( dbc, "INSERT INTO updates ( Date_, Name, Developer, AddedBy ) VALUES ( ?, ?, ?, ? )", date, update, author, accnt ) exports.CIPtrivia:sendMessage("UPDATES INFO ADDED! /updates TO SEE IT!", root, 255, 150, 0) outputChatBox("Server Updates: ["..date.."]:"..update.."("..author..")", root, 255, 150, 0) end function removeUpdate ( player, date, update, author ) dbExec ( dbc, "DELETE FROM updates WHERE Date_=? AND Name=? AND Developer=?", date, update, author ) end addEvent ( "Updates:onServerEvent", true ) addEventHandler ( "Updates:onServerEvent", root, function ( callBack, args ) if ( callBack == 'addUpdate' ) then addUpdate ( source, unpack ( args ) ) elseif ( callBack == 'removeUpdate' ) then removeUpdate ( source, unpack ( args ) ) end end ) function isPlayerInACL ( player, acl ) local account = getPlayerAccount ( player ) if ( isGuestAccount ( account ) ) then return false end if ( isObjectInACLGroup ( "user."..getAccountName ( account ), aclGetGroup ( acl ) ) ) then return true else return false end end function checkupdates() ag1 = dbPoll ( dbQuery ( dbc, "SELECT * FROM updates" ), -1 ) updatesMemo = "" local updates = { } for index, variable in ipairs ( ag1 ) do local lol = updates updates = { } table.insert ( updates, { variable['Date_'], variable['Name'], variable['Developer'] } ) for i, v in ipairs ( lol ) do table.insert ( updates, v ) end end for i,v in ipairs ( updates ) do d, m, y = string.match(v[1], "(%d+)/(%d+)/(%d+)") performdate = tostring(getdayofweek(d,m,y).." "..days[tonumber(d)].." "..months[tonumber(m)].." "..y) if currentDate ~= v[1] then currentDate = v[1] updatesMemo = updatesMemo.. "/n".. performdate.."/n" end three = string.gsub(v[3],"%[","") three = string.gsub(three,"%]","") three = string.gsub(three,"CIP","") three = string.gsub(three,"CIP","") three = string.gsub(three,"CIP","") str = "- "..v[2].." ("..three..")" updatesMemo = updatesMemo ..string.gsub(str,"/n","").."/n" end end setTimer(checkupdates, 100, 0) function getdayofweek(dd, mm, yy) local days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } local mmx = mm if (mm == 1) then mmx = 13; yy = yy-1 end if (mm == 2) then mmx = 14; yy = yy-1 end local val8 = dd + (mmx*2) + math.floor(((mmx+1)*3)/5) + yy + math.floor(yy/4) - math.floor(yy/100) + math.floor(yy/400) + 2 local val9 = math.floor(val8/7) local dw = val8-(val9*7) if (dw == 0) then dw = 7 end return days[dw] end ik that the code is completely messed up but help me I want it to open with F1 I added bindkey but doesn't work.. I'm new in scripiting Edited October 13, 2016 by Kingin~~ Link to comment
iPrestege Posted October 13, 2016 Share Posted October 13, 2016 Can you please use the code editor to post code's also are you sure that you made this script? because i can't find a 'bindKey' Function so i don't know how do you expect the panel open when you press f1? Link to comment
Kingin~~ Posted October 13, 2016 Author Share Posted October 13, 2016 (edited) I ain't the one who made it my friend gave me the first panel with rules only and I added updates tab. I added bindkey under the commandhandler and tested it and doesn't work I removed it from the code. Client local screenW, screenH = guiGetScreenSize() rule = guiCreateWindow((screenW - 799) / 2, (screenH - 604) / 2, 799, 604, "CIP Rules / Updates", false) guiWindowSetMovable(rule, false) guiWindowSetSizable(rule, false) guiSetAlpha(rule, 0.90) tabpanel = guiCreateTabPanel(9, 22, 780, 572, false, rule) tab1 = guiCreateTab("Help", tabpanel) grid = guiCreateGridList(12, 121, 374, 417, false, tab1) guiGridListSetSelectionMode(grid, 1) guiGridListSetSortingEnabled(grid, false) colum = guiGridListAddColumn(grid, "Question", 0.9) for index, val in pairs(griditem) do local row = guiGridListAddRow(grid) guiGridListSetItemText(grid, row, colum, val[1], false, false) end guiSetVisible(rule, false) tab2 = guiCreateTab("Updates", tabpanel) memo3 = guiCreateMemo(10, 10, 760, 528, "", false, tab2) guiMemoSetReadOnly(memo3, true) guiSetVisible( rule, false ) memo = guiCreateMemo(407, 131, 363, 407, "Click on a question on the right to see the answer here.", false, tab1) close1 = guiCreateTab("close", tabpanel) search = guiCreateEdit(9, 59, 285, 32, "", false, tab1) labelXl = guiCreateLabel(10, 22, 383, 37, "Enter key words like 'vehicle' to find answers:", false, tab1) guiSetFont(labelXl, "clear-normal") LabelXLL = guiCreateLabel(396, 34, 374, 91, " If your question isn't answered here, press 'Close',\n press 'J', make sure you're on the 'Support' channel,\n ask your question there and another player will respond.", false, tab1) guiSetFont(LabelXLL, "clear-normal") guiMemoSetReadOnly (memo, true) addEventHandler("onClientGUIClick", grid, clickedGridlist, false) addEventHandler("onClientGUIClick", ttt, function () guiSetVisible(rule, false) showCursor(false) end, false) addEventHandler("onClientGUIClick", tabpanel, changeTab, false) end ) function clickedGridlist() if (guiGridListGetSelectedItem(grid) == -1) then return end local row = guiGridListGetSelectedItem(source) local info = guiGridListGetItemText(grid, row, colum) for index, val in pairs(griditem) do if (info == val[1]) then guiSetText(memo, xmlNodeGetValue( xmlLoadFile( val[2] ) ) or "Error while loading file" ) end end end function changeTab() local selectedTab = guiGetSelectedTab(tabpanel) if (selectedTab == close1) then guiSetVisible(rule, false) showCursor(false) return true end lastSelectedTab = guiGetSelectedTab(tabpanel) end -- When a combo is selected addEventHandler ( "onClientGUIComboBoxAccepted", root, function ( theCombo ) if ( theCombo == combo ) then local theItem = guiComboBoxGetSelected ( theCombo ) local theLang = tostring ( guiComboBoxGetItemText ( theCombo , theItem ) ) if ( rulesToFile[theLang] ) then guiSetText( memo, xmlNodeGetValue( xmlLoadFile( rulesToFile[theLang] ) ) or "Error while loading file" ) end end end ) function showSupports() guiSetVisible(rule, false) showCursor(false) triggerEvent("showSupportChat", root) end addEventHandler("onClientGUIChanged", resourceRoot, function() local text = guiGetText(search) local sItems = { } for i, v in pairs(griditem) do if not (text == "" ) then if (string.find(string.upper(v[1]), string.upper(text), 1, true)) then table.insert(sItems, v[1]) end else table.insert(sItems, v[1]) end end guiGridListClear(grid) for i, v in pairs(sItems) do local row = guiGridListAddRow(grid) guiGridListSetItemText(grid, row, 1, v, false, false) end end) updatesMemo = "" currentDate = "" local sx, sy = guiGetScreenSize ( ) local screenW, screenH = guiGetScreenSize ( ) local currentList = { } row = 0 row2 = 0 -- Tables local main = {} local read = { } local add = { button = {}, edit = {} } local remove = { button = {} } -- View Panel main.window = guiCreateWindow((screenW - 587) / 2, (screenH - 447) / 2, 587, 447, "CIP Server Recent Updates", false) guiWindowSetMovable ( main.window, false ) guiWindowSetSizable(main.window, false) guiSetVisible ( main.window, false ) guiMemoSetReadOnly(memo3,true) main.close = guiCreateButton(0.3101, 0.9224, 0.3748, 0.0587, "Close", true, main.window) add.window = guiCreateWindow( ( sx / 2 - 482 / 2 ), ( sy / 2 - 571 / 2 ), 482, 571, "CIP Updates adden", false) guiWindowSetSizable(add.window, false) guiSetVisible ( add.window, false ) guiCreateLabel(10, 32, 145, 15, "Date (DD/MM/YYYY):", false, add.window) add.edit['date'] = guiCreateEdit(9, 53, 454, 28, "", false, add.window) guiCreateLabel(10, 103, 145, 15, "Update:", false, add.window) add.edit['update'] = guiCreateMemo(13, 125, 450, 294, "", false, add.window) guiCreateLabel(10, 449, 145, 15, "Author:", false, add.window) add.edit['author'] = guiCreateEdit(9, 468, 454, 28, "", false, add.window) add.button['add'] = guiCreateButton(12, 508, 143, 44, "Add Update", false, add.window) add.button['cancel'] = guiCreateButton(165, 508, 143, 44, "Cancel/close", false, add.window) add.button['remove'] = guiCreateButton(320, 508, 143, 44, "Remove a update", false, add.window) -- Remove Panel remove.window = guiCreateWindow( ( sx / 2 - 552 / 2 ), ( sy / 2 - 533 / 2 ), 552, 533, "CIP Remove Update", false) guiWindowSetSizable(remove.window, false) guiSetVisible ( remove.window, false ) remove.grid = guiCreateGridList(10, 28, 532, 443, false, remove.window) guiGridListAddColumn(remove.grid, "Date", 0.18) guiGridListAddColumn(remove.grid, "Update", 0.58) guiGridListAddColumn(remove.grid, "Developer", 0.2) remove.button['remove'] = guiCreateButton(376, 481, 166, 36, "Remove", false, remove.window) guiSetProperty(remove.button['remove'], "NormalTextColour", "FFFF0000") remove.button['back'] = guiCreateButton(10, 481, 166, 36, "Add a update", false, remove.window) -- Read More read.window = guiCreateWindow( ( sx / 2 - 407 / 2 ), ( sy / 2 - 397 / 2 ), 407, 397, "Read More", false) guiWindowSetSizable(read.window, false) guiSetVisible ( read.window, false ) guiSetAlpha ( read.window, 1 ) guiWindowSetMovable ( read.window, false ) read.date = guiCreateLabel(9, 35, 275, 25, "Date: Loading..", false, read.window) read.author = guiCreateLabel(9, 70, 388, 25, "Developer: Loading...", false, read.window) guiCreateLabel(9, 105, 388, 25, "Update:", false, read.window) read.update = guiCreateMemo(9, 127, 388, 253, "Loading..", false, read.window) guiMemoSetReadOnly(read.update, true) read.close = guiCreateButton(294, 25, 103, 35, "Exit", false, read.window) days = {"1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st"} months = {"January","February","March","April","May","June","July","August","September","October","November","December"} function CIPaccountsExport(ag1) updatesMemo = "" if (type(ag1) == 'table') then currentList = { } local updates = { } for index, variable in ipairs(ag1) do local lol = updates updates = { } table.insert(updates, {variable['Date_'], variable['Name'], variable['Developer']}) for i, v in ipairs(lol) do table.insert(updates, v) end end for i,v in ipairs(updates) do d, m, y = string.match(v[1], "(%d+)/(%d+)/(%d+)") performdate = getdayofweek(d,m,y).." "..days[tonumber(d)].." "..months[tonumber(m)].." "..y if currentDate ~= v[1] then currentDate = v[1] if row2 == 0 then updatesMemo = updatesMemo.. "".. performdate.."\n" else updatesMemo = updatesMemo.. "\n".. performdate.."\n" end end three = string.gsub(v[3],"%[","") three = string.gsub(three,"%]","") three = string.gsub(three,"CIP","") three = string.gsub(three,"CIP","") str = "- "..v[2].." ("..three..")" updatesMemo = updatesMemo ..string.gsub(str,"\n","").."\n" row2 = row2 + 1 triggerEvent("CIPaccounts.GetUpdates", source, updatesMemo) end currentList = updates end end addEvent("CIPupdates.CIPacc", true) addEventHandler("CIPupdates.CIPacc", root, CIPaccountsExport) addEvent ( "Updates:onPanelChangeState", true ) addEventHandler ( "Updates:onPanelChangeState", root, function ( window, ag1 ) guiSetText(memo3,"") guiSetInputMode("no_binds_when_editing") updatesMemo = "" if ( window == 'main' ) then if ( guiGetVisible ( add.window ) ) then guiSetVisible ( add.window, false ) showCursor ( false ) end if ( guiGetVisible ( remove.window ) ) then guiSetVisible ( remove.window, false ) showCursor ( false ) end guiSetSelectedTab(tabpanel, tab2) guiSetVisible ( rule, true ) showCursor ( true ) if ( type ( ag1 ) == 'table' ) then currentList = { } -- Reverse the loop -- local updates = { } for index, variable in ipairs ( ag1 ) do local lol = updates updates = { } table.insert ( updates, { variable['Date_'], variable['Name'], variable['Developer'] } ) for i, v in ipairs ( lol ) do table.insert ( updates, v ) end end for i,v in ipairs ( updates ) do d, m, y = string.match(v[1], "(%d+)/(%d+)/(%d+)") performdate = getdayofweek(d,m,y).." "..days[tonumber(d)].." "..months[tonumber(m)].." "..y if currentDate ~= v[1] then currentDate = v[1] if row == 0 then updatesMemo = updatesMemo.. "".. performdate.."\n" else updatesMemo = updatesMemo.. "\n".. performdate.."\n" end end three = string.gsub(v[3],"%[","") three = string.gsub(three,"%]","") three = string.gsub(three,"CIP","") three = string.gsub(three,"CIP","") str = "- "..v[2].." ("..three..")" updatesMemo = updatesMemo ..string.gsub(str,"\n","").."\n" row = row + 1 guiSetText(memo3, updatesMemo) end currentList = updates else guiSetText ( memo3, "Failed to load updates" ) end elseif ( window == 'manager' ) then if ( guiGetVisible ( remove.window ) ) then return end if ( guiGetVisible ( rule ) ) then guiSetVisible ( rule, false ) showCursor ( false ) end if ( guiGetVisible ( read.window ) ) then guiSetVisible ( read.window, false ) end guiSetVisible ( add.window, true ) showCursor ( true ) local text = getElementData(localPlayer, "account") guiSetText ( add.edit['author'], getPlayerName(getLocalPlayer()) ) local time = getRealTime ( ) local day = time.monthday local month = time.month + 1 local year = time.year + 1900 if ( day < 10 ) then day = 0 .. day end if ( month < 10 ) then month = 0 .. month end guiSetText ( add.edit['date'], table.concat ( { day, month, year }, "/" ) ) guiSetInputMode ( "no_binds_when_editing" ) end end ) addEvent ( "Updates:onPanelChangeState1", true ) addEventHandler ( "Updates:onPanelChangeState1", root, function ( window, ag1 ) guiSetText(memo3,"") guiSetInputMode("no_binds_when_editing") updatesMemo = "" if ( window == 'main' ) then if ( guiGetVisible ( add.window ) ) then guiSetVisible ( add.window, false ) showCursor ( false ) end if ( guiGetVisible ( remove.window ) ) then guiSetVisible ( remove.window, false ) showCursor ( false ) end guiSetSelectedTab(tabpanel, tab1) guiSetVisible ( rule, true ) showCursor ( true ) if ( type ( ag1 ) == 'table' ) then currentList = { } -- Reverse the loop -- local updates = { } for index, variable in ipairs ( ag1 ) do local lol = updates updates = { } table.insert ( updates, { variable['Date_'], variable['Name'], variable['Developer'] } ) for i, v in ipairs ( lol ) do table.insert ( updates, v ) end end for i,v in ipairs ( updates ) do d, m, y = string.match(v[1], "(%d+)/(%d+)/(%d+)") performdate = getdayofweek(d,m,y).." "..days[tonumber(d)].." "..months[tonumber(m)].." "..y if currentDate ~= v[1] then currentDate = v[1] if row == 0 then updatesMemo = updatesMemo.. "".. performdate.."\n" else updatesMemo = updatesMemo.. "\n".. performdate.."\n" end end three = string.gsub(v[3],"%[","") three = string.gsub(three,"%]","") three = string.gsub(three,"CIP","") three = string.gsub(three,"CIP","") str = "- "..v[2].." ("..three..")" updatesMemo = updatesMemo ..string.gsub(str,"\n","").."\n" row = row + 1 guiSetText(memo3, updatesMemo) end currentList = updates else guiSetText ( memo3, "Failed to load updates" ) end elseif ( window == 'manager' ) then if ( guiGetVisible ( remove.window ) ) then return end if ( guiGetVisible ( rule ) ) then guiSetVisible ( rule, false ) showCursor ( false ) end if ( guiGetVisible ( read.window ) ) then guiSetVisible ( read.window, false ) end guiSetVisible ( add.window, true ) showCursor ( true ) local text = getElementData(localPlayer, "account") guiSetText ( add.edit['author'], getPlayerName(getLocalPlayer()) ) local time = getRealTime ( ) local day = time.monthday local month = time.month + 1 local year = time.year + 1900 if ( day < 10 ) then day = 0 .. day end if ( month < 10 ) then month = 0 .. month end guiSetText ( add.edit['date'], table.concat ( { day, month, year }, "/" ) ) guiSetInputMode ( "no_binds_when_editing" ) end end ) addEventHandler ( 'onClientGUIClick', root, function ( btn ) if ( btn == 'left' ) then -- Main Panel if ( source == main.readmore ) then local row, col = guiGridListGetSelectedItem ( memo3 ) if ( row ~= -1 and col ~= 0 ) then guiSetVisible ( read.window, true ) guiBringToFront ( read.window ) guiSetText ( read.date, "Date: "..guiGridListGetItemText ( memo3, row, 1 ) ) guiSetText ( read.update, guiGridListGetItemText ( memo3, row, 2 ) ) guiSetText ( read.author, "Developer: "..guiGridListGetItemText ( memo3, row, 3 ) ) else outputChatBox ( "Select an update.", 255, 255, 0 ) end elseif ( source == read.close ) then guiSetVisible ( read.window, false ) elseif ( source == main.close ) then guiSetText(memo3,"") row = 0 guiSetVisible ( rule, false ) showCursor ( false ) if ( guiGetVisible ( read.window ) ) then guiSetVisible ( read.window, false ) end -- Adding Panel elseif ( source == add.button['cancel'] ) then guiSetVisible ( add.window, false ) showCursor ( false ) elseif ( source == add.button['add'] ) then local date, update, author = guiGetText ( add.edit['date'] ), guiGetText ( add.edit['update'] ), guiGetText ( add.edit['author'] ) if ( date ~= '' and update ~= '' and author ~= '' ) then triggerServerEvent ( "Updates:onServerEvent", localPlayer, 'addUpdate', { date, update, author } ) else outputChatBox ( "You need to enter all of the information.", 255, 0, 0 ) end elseif ( source == add.button['remove'] ) then guiSetVisible ( add.window, false ) guiSetVisible ( remove.window, true ) guiGridListClear ( remove.grid ) if ( currentList and #currentList > 0 ) then for index, var in ipairs ( currentList ) do local row = guiGridListAddRow ( remove.grid ) guiGridListSetItemText ( remove.grid, row, 1, var[1], false, false ) guiGridListSetItemText ( remove.grid, row, 2, var[2], false, false ) guiGridListSetItemText ( remove.grid, row, 3, var[3], false, false ) end else guiGridListSetItemText ( remove.grid, guiGridListAddRow ( remove.grid ), 2, "Please use /updates, then come back to this panel.", true, true ) guiGridListSetItemColor ( remove.grid, 0, 2, 255, 0, 0 ) end -- remove panel elseif ( source == remove.button['back'] ) then guiSetVisible ( remove.window, false ) guiSetVisible ( add.window, true ) elseif ( source == remove.button['remove'] ) then local row, col = guiGridListGetSelectedItem ( remove.grid ) if ( row ~= -1 and col ~= 0 ) then local date = guiGridListGetItemText ( remove.grid, row, 1 ) local update = guiGridListGetItemText ( remove.grid, row, 2 ) local author = guiGridListGetItemText ( remove.grid, row, 3 ) for index, var in ipairs ( currentList ) do if ( var[1] == date and var[2] == update and var[3] == author ) then table.remove ( currentList, index ) break end end guiGridListClear ( remove.grid ) if ( #currentList > 0 ) then for index, var in ipairs ( currentList ) do local row = guiGridListAddRow ( remove.grid ) guiGridListSetItemText ( remove.grid, row, 1, var[1], false, false ) guiGridListSetItemText ( remove.grid, row, 2, var[2], false, false ) guiGridListSetItemText ( remove.grid, row, 3, var[3], false, false ) end else guiGridListSetItemText ( remove.grid, guiGridListAddRow ( remove.grid ), 2, "No updates found.", true, true ) end triggerServerEvent ( 'Updates:onServerEvent', localPlayer, 'removeUpdate', { date, update, author } ) end end end end ) function getdayofweek(dd, mm, yy) local days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } local mmx = mm if (mm == 1) then mmx = 13; yy = yy-1 end if (mm == 2) then mmx = 14; yy = yy-1 end local val8 = dd + (mmx*2) + math.floor(((mmx+1)*3)/5) + yy + math.floor(yy/4) - math.floor(yy/100) + math.floor(yy/400) + 2 local val9 = math.floor(val8/7) local dw = val8-(val9*7) if (dw == 0) then dw = 7 end return days[dw] end Server days = {"1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th","11th","12th","13th","14th","15th","16th","17th","18th","19th","20th","21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th","31st"} months = {"January","February","March","April","May","June","July","August","September","October","November","December"} function outputRoot ( msg, chatbox ) outputDebugString ( msg ) outputConsole ( msg ) outputServerLog ( msg ) if ( chatbox ) then outputChatBox ( msg ) end return true end -- Connect database. addEventHandler ( "onResourceStart", resourceRoot, function ( ) local saveMode_ = string.lower ( saveMode ) if ( saveMode_ == 'mysql' ) then dbc = dbConnect ( 'mysql', "host="..host..";dbname="..databaseName, username, password ) elseif ( saveMode_ == 'sqlite' ) then dbc = dbConnect ( "sqlite", "updatesDB.db" ) else return outputRoot ( "Server Updates: "..saveMode.." is an invalid saving method. Valid: MySQL | SQLite - Change in settings.lua." ) end -- Check Database if ( dbc ) then outputRoot ( "Server Updates: "..saveMode.." has successfully connected.", false ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS updates ( Date_ TEXT, Name TEXT, Developer TEXT, AddedBy TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS selling ( userid TEXT, item TEXT, amount TEXT, price TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS banking ( userid TEXT, balance TEXT, creditcard TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS banking_transactions ( userid TEXT, transaction TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS squad_bl ( squad_name TEXT, acc TEXT, byc TEXT, date TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS squad_log ( squad_name TEXT, action TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS group_bl ( group_name TEXT, acc TEXT, byc TEXT, date TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS group_bank ( group_name TEXT, balance INTEGER )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS group_log ( group_name TEXT, action TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS mapeditor ( id INTEGER, model TEXT, x INTEGER, y INTEGER, z INTEGER, rx INTEGER, ry INTEGER, rz INTEGER, dim INTEGER, interior INTEGER, descr TEXT, proj TEXT, edAcc TEXT, eType TEXT, cData TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS accounts ( id TEXT, cjskin TEXT, x INTEGER, y INTEGER, z INTEGER, interior INTEGER, dimension INTEGER, email TEXT, password TEXT, jobskin TEXT, username TEXT, serial INTEGER, skin INTEGER )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS weapons ( userid INTEGER, weapon TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS playerstats ( laser INTEGER, userid TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS punishlogs ( log TEXT, acc TEXT, id INTEGER, player TEXT, admin TEXT, type TEXT, reason TEXT, serial TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS staffList ( staff TEXT, acc TEXT )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS banking_transactions ( userid TEXT, transaction INTEGER )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS banking ( userid TEXT, balance INTEGER, creditcard INTEGER )" ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS events ( name TEXT, data TEXT )" ) else outputRoot ( "Server Updates: "..saveMode.." has failed to connected.", true ) end end ) dbc = dbConnect ( "sqlite", "updates.db" ) function getUpdates ( ) return dbPoll ( dbQuery ( dbc, "SELECT * FROM updates" ), -1 ) end addCommandHandler ( "updates", function ( p ) local updates = getUpdates ( ) triggerClientEvent ( p, 'Updates:onPanelChangeState', p, 'main', updates ) end ) addCommandHandler ( "rules", function ( p ) local updates = getUpdates ( ) triggerClientEvent ( p, 'Updates:onPanelChangeState1', p, 'main', updates ) end ) function CIPacc(source) local updates = getUpdates() if updates then triggerClientEvent(source, 'CIPupdates.CIPacc', source, updates) else local updates2 = dbPoll(dbQuery(dbc, "SELECT * FROM updates"), -1) triggerClientEvent(source, 'CIPupdates.CIPacc', source, updates2) end end addEvent("CIPupdates.exprt", true) addEventHandler("CIPupdates.exprt", root, CSCacc) addCommandHandler ( "updatemanager", function ( p ) local isAllowed = false; for _, acl in ipairs ( allowedACLS ) do if ( isPlayerInACL ( p, acl ) ) then isAllowed = true break end end if ( isAllowed ) then local updates = getUpdates ( ) triggerClientEvent ( p, 'Updates:onPanelChangeState', p, 'manager', updates ) end end ) function addUpdate ( player, date, update, author ) local accnt = getAccountName ( getPlayerAccount ( player ) ) dbExec ( dbc, "INSERT INTO updates ( Date_, Name, Developer, AddedBy ) VALUES ( ?, ?, ?, ? )", date, update, author, accnt ) exports.CIPtrivia:sendMessage("UPDATES INFO ADDED! /updates TO SEE IT!", root, 255, 150, 0) outputChatBox("Server Updates: ["..date.."]:"..update.."("..author..")", root, 255, 150, 0) end function removeUpdate ( player, date, update, author ) dbExec ( dbc, "DELETE FROM updates WHERE Date_=? AND Name=? AND Developer=?", date, update, author ) end addEvent ( "Updates:onServerEvent", true ) addEventHandler ( "Updates:onServerEvent", root, function ( callBack, args ) if ( callBack == 'addUpdate' ) then addUpdate ( source, unpack ( args ) ) elseif ( callBack == 'removeUpdate' ) then removeUpdate ( source, unpack ( args ) ) end end ) function isPlayerInACL ( player, acl ) local account = getPlayerAccount ( player ) if ( isGuestAccount ( account ) ) then return false end if ( isObjectInACLGroup ( "user."..getAccountName ( account ), aclGetGroup ( acl ) ) ) then return true else return false end end function checkupdates() ag1 = dbPoll ( dbQuery ( dbc, "SELECT * FROM updates" ), -1 ) updatesMemo = "" local updates = { } for index, variable in ipairs ( ag1 ) do local lol = updates updates = { } table.insert ( updates, { variable['Date_'], variable['Name'], variable['Developer'] } ) for i, v in ipairs ( lol ) do table.insert ( updates, v ) end end for i,v in ipairs ( updates ) do d, m, y = string.match(v[1], "(%d+)/(%d+)/(%d+)") performdate = tostring(getdayofweek(d,m,y).." "..days[tonumber(d)].." "..months[tonumber(m)].." "..y) if currentDate ~= v[1] then currentDate = v[1] updatesMemo = updatesMemo.. "/n".. performdate.."/n" end three = string.gsub(v[3],"%[","") three = string.gsub(three,"%]","") three = string.gsub(three,"CIP","") three = string.gsub(three,"CIP","") three = string.gsub(three,"CIP","") str = "- "..v[2].." ("..three..")" updatesMemo = updatesMemo ..string.gsub(str,"/n","").."/n" end end setTimer(checkupdates, 100, 0) function getdayofweek(dd, mm, yy) local days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } local mmx = mm if (mm == 1) then mmx = 13; yy = yy-1 end if (mm == 2) then mmx = 14; yy = yy-1 end local val8 = dd + (mmx*2) + math.floor(((mmx+1)*3)/5) + yy + math.floor(yy/4) - math.floor(yy/100) + math.floor(yy/400) + 2 local val9 = math.floor(val8/7) local dw = val8-(val9*7) if (dw == 0) then dw = 7 end return days[dw] end Edited October 13, 2016 by Kingin~~ Link to comment
iPrestege Posted October 13, 2016 Share Posted October 13, 2016 line 35 and line 37 in client side what for is the 'end' and ')' this mistake will never start the client side file. Give us the errors in the debug so we can find the problem and if we can help you we will. 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now