1LoL1 Posted March 7, 2014 Share Posted March 7, 2014 Please help me how to open AddUpdates? script = https://community.multitheftauto.com/index.php?p=resources&s=details&id=7942 Link to comment
MIKI785 Posted March 7, 2014 Share Posted March 7, 2014 What?? Hello everyone. This is a script that gives clients a GUI that shows your server updates when they type the command "/updates." Or what do you mean? Link to comment
WhoAmI Posted March 7, 2014 Share Posted March 7, 2014 To add an update, just do functions with addUpdate ( source, "07.04.2014", "a value of an update", "Author" ) But remember to export that function by using exports.resource_name:addUpdate ( source, "07.04.2014", "a value of an update", "Author" ) Link to comment
MIKI785 Posted March 7, 2014 Share Posted March 7, 2014 just call it using for example runcode Link to comment
WhoAmI Posted March 7, 2014 Share Posted March 7, 2014 Lol, I just wrote you. If you don't know LUA just start from beginning. Try to do simple commands/funcitons. Link to comment
1LoL1 Posted March 7, 2014 Author Share Posted March 7, 2014 so I write it how it should look and how do I enable the Add panel, please? .. -- Client ------------------------------------------ -- Server Updates -- ------------------------------------------ -- Developer: Braydon Davis (xXMADEXx) -- -- File: client.lua -- -- Copyright 2013 (C) RoS -- -- All rights reserved. -- ------------------------------------------ sec = {{{{{{},{},{},{}}}}}} -- ------------------------------------------ local sx, sy = guiGetScreenSize ( ) local currentList = { } -- Tables local main = {} local read = { } local add = { button = {}, edit = {} } local remove = { button = {} } -- View Panel main.window = guiCreateWindow( ( sx / 2 - 710 / 2 ), ( sy / 2 - 610 / 2 ), 710, 610, "Server Updates", false) guiWindowSetMovable ( main.window, false ) guiWindowSetSizable(main.window, false) guiSetVisible ( main.window, false ) main.grid = guiCreateGridList(9, 26, 691, 519, false, main.window) guiGridListSetSortingEnabled ( main.grid, false ) guiGridListAddColumn(main.grid, "Date", 0.18) guiGridListAddColumn(main.grid, "Update", 0.58) guiGridListAddColumn(main.grid, "Developer", 0.2) main.close = guiCreateButton(529, 555, 171, 40, "Close", false, main.window) main.readmore = guiCreateButton(353, 555, 171, 40, "Open in new a window", false, main.window) guiCreateLabel(11, 551, 236, 34, "Script by the Revolution of Scripting team.\n[url=http://revolution-scripts.com]http://revolution-scripts.com[/url]", false, main.window) -- Adding Panel add.window = guiCreateWindow( ( sx / 2 - 482 / 2 ), ( sy / 2 - 571 / 2 ), 482, 571, "Server Updates - Admin Manager", false) guiWindowSetSizable(add.window, false) guiSetVisible ( add.window, false ) guiCreateLabel(10, 32, 145, 15, "Date (MM/DD/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", false, add.window) add.button['remove'] = guiCreateButton(320, 508, 143, 44, ">> Remove Panel >>", false, add.window) -- Remove Panel remove.window = guiCreateWindow( ( sx / 2 - 552 / 2 ), ( sy / 2 - 533 / 2 ), 552, 533, "Server Updates/Admin Manager/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, "<< Back <<", 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) addEvent ( "Updates:onPanelChangeState", true ) addEventHandler ( "Updates:onPanelChangeState", root, function ( window, ag1 ) 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 guiSetVisible ( main.window, true ) showCursor ( true ) guiGridListClear ( main.grid ) 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 local row = guiGridListAddRow ( main.grid ) guiGridListSetItemText ( main.grid, row, 1, tostring ( v[1] ), false, false ) guiGridListSetItemText ( main.grid, row, 2, tostring (v[2] ), false, false ) guiGridListSetItemText ( main.grid, row, 3, tostring (v[3] ), false, false ) end currentList = updates else guiGridListSetItemText ( main.grid, guiGridListAddRow ( main.grid ), 2, "Failed to load updates", true, true ) end elseif ( window == 'manager' ) then if ( guiGetVisible ( remove.window ) ) then return end if ( guiGetVisible ( main.window ) ) then guiSetVisible ( main.window, false ) showCursor ( false ) end if ( guiGetVisible ( read.window ) ) then guiSetVisible ( read.window, false ) end guiSetVisible ( add.window, true ) showCursor ( true ) guiSetText ( add.edit['author'], getPlayerName ( localPlayer ) ) 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 ( { month, day, 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 ( main.grid ) if ( row ~= -1 and col ~= 0 ) then guiSetVisible ( read.window, true ) guiBringToFront ( read.window ) guiSetText ( read.date, "Date: "..guiGridListGetItemText ( main.grid, row, 1 ) ) guiSetText ( read.update, guiGridListGetItemText ( main.grid, row, 2 ) ) guiSetText ( read.author, "Developer: "..guiGridListGetItemText ( main.grid, 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 guiGridListClear ( main.grid ) guiSetVisible ( main.window, 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 ) -- Server ------------------------------------------ -- Server Updates -- ------------------------------------------ -- Developer: Braydon Davis (xXMADEXx) -- -- File: server.lua -- -- Copyright 2013 (C) RoS -- -- All rights reserved. -- ------------------------------------------ sec = {{{{{{},{},{},{}}}}}} -- ------------------------------------------ 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", "updates.sql" ) 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 ( "Sever Updates: "..saveMode.." has successfully connected.", false ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS Updates ( Date_ TEXT, Name TEXT, Developer TEXT, AddedBy TEXT )" ) else outputRoot ( "Sever Updates: "..saveMode.." has failed to connected.", true ) end end ) function getUpdates ( ) return dbPoll ( dbQuery ( dbc, "SELECT * FROM Updates LIMIT 70" ), -1 ) end addCommandHandler ( "updates", function ( p ) local updates = getUpdates ( ) triggerClientEvent ( p, 'Updates:onPanelChangeState', p, 'main', updates ) end ) 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 ) outputRoot ( "Server Updates: "..getPlayerName ( player ).." added an update.", false ) outputChatBox ( "A new update has been applied! Check /updates!!", root, 255, 0, 226 ) 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 -- Update Checker if ( get ( "*_AutoUpdateCheck" ) == 'true' ) then function checkForUpdate ( ) callRemote ( "https://community.multitheftauto.com/mta/resources.php", function ( data, d ) if d then local c_ver = tostring ( getResourceInfo ( getThisResource ( ), 'version' ) )..".0" if ( c_ver < d ) then outputChatBox ( "Server Updates: Resources is out dated. Please download the new version @" ) outputChatBox ( "https://community.multitheftauto.com/index.php?p=resources&s=details&id=7942!", root ) outputChatBox ( "Your Version: "..c_ver.." || Current: "..tostring ( d ) ) end end end, 'version', 'serverupdates' ) end checkForUpdate ( ) setTimer ( checkForUpdate, 600*1000, 0 ) -- check ever 10 mins end Link to comment
WhoAmI Posted March 7, 2014 Share Posted March 7, 2014 Just start resource and type /updates. Link to comment
1LoL1 Posted March 7, 2014 Author Share Posted March 7, 2014 Just start resource and type /updates. lol but that I joined as I turn on the update panel? Link to comment
MIKI785 Posted March 7, 2014 Share Posted March 7, 2014 Just read the damn description of the resource.. everything you need is in there. Link to comment
1LoL1 Posted March 7, 2014 Author Share Posted March 7, 2014 I don't understand. See the screen here https://community.multitheftauto.com/index.php?p=resources&s=details&id=7942 and how do I enable the Add Panel? Link to comment
1LoL1 Posted March 7, 2014 Author Share Posted March 7, 2014 Just read the damn description of the resource.. everything you need is in there. Maybe it is there but do not know where I have to add though that at least one update to my Client and Server make it go .. Link to comment
Castillo Posted March 7, 2014 Share Posted March 7, 2014 "/updatemanager". And please, try to be nice to the people that is trying to help you. Link to comment
1LoL1 Posted March 7, 2014 Author Share Posted March 7, 2014 "/updatemanager".And please, try to be nice to the people that is trying to help you. At least someone who understood Thank you very much.. But I'm just like him to explain what I mean .. Link to comment
WhoAmI Posted March 7, 2014 Share Posted March 7, 2014 You could've been nicer. Someone tries to help you and you are telling him to shut up. Think about yourself. World isn't only for you. Link to comment
1LoL1 Posted March 7, 2014 Author Share Posted March 7, 2014 Solidsnake14 well as the Panel does not give Add Update and nothing WhoAmI So sorry. Link to comment
Castillo Posted March 7, 2014 Share Posted March 7, 2014 Are you in the "Admin" or "Moderator" ACL group? Link to comment
1LoL1 Posted March 7, 2014 Author Share Posted March 7, 2014 Are you in the "Admin" or "Moderator" ACL group? Yes Link to comment
Castillo Posted March 7, 2014 Share Posted March 7, 2014 So, the command doesn't do anything at all? Link to comment
1LoL1 Posted March 7, 2014 Author Share Posted March 7, 2014 So, the command doesn't do anything at all? When I give /updatemanager and the Add Update so nothing Link to comment
Castillo Posted March 7, 2014 Share Posted March 7, 2014 But, the command does show the update manager GUI? 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