BoneAlone Posted January 30, 2019 Share Posted January 30, 2019 hello guys, i was trying to make gui open when player login but i fail i dont know how to make it can anyone help me? Spoiler Link to comment
DNL291 Posted January 30, 2019 Share Posted January 30, 2019 Where is your code? Show the code you're trying to do please. Link to comment
AncienT Posted January 30, 2019 Share Posted January 30, 2019 (edited) The code is empty, please paste again your code Edited January 30, 2019 by AncienT Link to comment
BoneAlone Posted January 30, 2019 Author Share Posted January 30, 2019 (edited) Spoiler saveMode = 'SQLite' host = 'N/A' username = '' password = '' databaseName = '' allowedACLS = {"console", "Admin","news",} 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.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 ( "Server Updates: "..saveMode.." has successfully connected.", false ) dbExec ( dbc, "CREATE TABLE IF NOT EXISTS updates ( Date_ TEXT, Name TEXT, Developer TEXT, AddedBy TEXT )" ) else outputRoot ( "Server Updates: "..saveMode.." has failed to connected.", true ) end end ) conn = dbConnect( "mysql", "dbname="..tostring(exports["SQL"]:getMySQLData()[3])..";host=127.0.0.1", tostring(exports["SQL"]:getMySQLData()[1]), tostring(exports["SQL"]:getMySQLData()[2]), "share=1" ) function getUpdates ( ) return dbPoll ( dbQuery ( dbc, "SELECT * FROM updates" ), -1 ) end addCommandHandler ( "news", function ( opengui ) local updates = getUpdates ( ) triggerClientEvent ( opengui, 'Updates:onPanelChangeState', opengui, 'main', updates ) end ) addEventHandler("onPlayerLogin", getRootElment, opengui ) function FreeGamingacc(source) local updates = getUpdates() if updates then triggerClientEvent(source, 'FreeGamingupdates.FreeGamingacc', source, updates) else local updates2 = dbPoll(dbQuery(dbc, "SELECT * FROM updates"), -1) triggerClientEvent(source, 'FreeGamingupdates.FreeGamingacc', source, updates2) end end addEvent("FreeGamingupdates.exprt", true) addEventHandler("FreeGamingupdates.exprt", root, FreeGamingacc) addCommandHandler ( "addupdate", 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 ) exports.FreeGamingMessages:sendClientMessage("Job: UPDATES INFO ADDED! /news TO SEE IT!","info", root,255, 0, 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,"FreeGaming","") three = string.gsub(three,"FreeGaming","") three = string.gsub(three,"FreeGaming","") str = "- "..v[2].." ("..three..")" updatesMemo = updatesMemo ..string.gsub(str,"/n","").."/n" end ---dbExec ( dbc, "DELETE FROM updates" ) ---dbExec ( dbc, "INSERT INTO updates ( Date_ TEXT, Name TEXT, Developer TEXT, AddedBy TEXT )", tostring(updatesMemo) ) 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 i was trying in line addCommandHandler ( "news", function ( opengui ) , and down but it wont work Edited January 30, 2019 by BoneAlone Link to comment
Moderators IIYAMA Posted January 30, 2019 Moderators Share Posted January 30, 2019 function openGUI ( player ) local updates = getUpdates ( ) triggerClientEvent ( player, 'Updates:onPanelChangeState', player, 'main', updates ) end addCommandHandler ( "news", function (player) openGUI(player) end) addEventHandler("onPlayerLogin", root, function () openGUI(source) end) Read the docs: https://wiki.multitheftauto.com/wiki/AddCommandHandler https://wiki.multitheftauto.com/wiki/OnPlayerLogin Keep in mind that players can login before they have loaded their scripts, unless the login command is blocked. (the panel will not open in that case) 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