Mann56 Posted June 13, 2016 Share Posted June 13, 2016 Hello guys, I was making a group system where i encountered this error. Whenever i open the gui, it shows for everybody even on my pressing the bound key... I am not able to figure out the reason of this thing. Here's da code SERVER function checkIfMember(thePlayer) local inGroup = dbPoll(dbQuery(connection,"SELECT Name FROM Members WHERE Name = ?",getAccountName(getPlayerAccount(thePlayer))),-1) if #inGroup > 0 then if state == false then state = true triggerClientEvent("showTheGui",thePlayer,thePlayer,state) else state = false triggerClientEvent("showTheGui",thePlayer,thePlayer,state) end end end addEvent("memberCheck",true) addEventHandler("memberCheck",root,checkIfMember) function bindPanelKey() bindKey(source,panelOpenKey,"up",checkIfMember) end addEventHandler("onPlayerLogin",root,bindPanelKey) CLIENT function triggerGui(player,state) guiSetVisible(mainWindow,state) showCursor(state) state = false end addEvent("showTheGui",true) addEventHandler("showTheGui",root,triggerGui) Hope someone can help me in this... ( I hope this extract of the code is enough, if not please inform me, i'll give the gui part) Mann. Link to comment
Bean666 Posted June 13, 2016 Share Posted June 13, 2016 try not tested. function triggerGui(player,state) if (player == localPlayer ) then guiSetVisible(mainWindow,state) showCursor(state) state = false end addEvent("showTheGui",true) addEventHandler("showTheGui",resourceRoot,triggerGui) Link to comment
Mann56 Posted June 13, 2016 Author Share Posted June 13, 2016 It works now, thank you very much... Link to comment
KariiiM Posted June 13, 2016 Share Posted June 13, 2016 try not tested. function triggerGui(player,state) if (player == localPlayer ) then guiSetVisible(mainWindow,state) showCursor(state) state = false end addEvent("showTheGui",true) addEventHandler("showTheGui",resourceRoot,triggerGui) Why you're checking if the player is a localPlayer ? it's just a waste of time and waste of memory the function triggerClientEvent has an argument named sendTo. @Mann56, you left this argument empty which that means: root ( everyone ) server side: function checkIfMember(thePlayer) local inGroup = dbPoll ( dbQuery ( connection, "SELECT Name FROM Members WHERE Name = ?", getAccountName ( getPlayerAccount ( thePlayer ) ) ), -1 ) if ( #inGroup > 0 ) then if ( not state ) then state = true triggerClientEvent ( thePlayer, "showTheGui", thePlayer, thePlayer, state ) else state = false triggerClientEvent ( thePlayer, "showTheGui", thePlayer, thePlayer, state ) end end end addEvent ( "memberCheck", true ) addEventHandler ( "memberCheck", root, checkIfMember ) Link to comment
KariiiM Posted June 13, 2016 Share Posted June 13, 2016 i see. Why you didn't inform him about that? Link to comment
Mann56 Posted June 14, 2016 Author Share Posted June 14, 2016 Why you're checking if the player is a localPlayer ? it's just a waste of time and waste of memory the function triggerClientEvent has an argument named sendTo. @Mann56, you left this argument empty which that means: root ( everyone ) server side: function checkIfMember(thePlayer) local inGroup = dbPoll ( dbQuery ( connection, "SELECT Name FROM Members WHERE Name = ?", getAccountName ( getPlayerAccount ( thePlayer ) ) ), -1 ) if ( #inGroup > 0 ) then if ( not state ) then state = true triggerClientEvent ( thePlayer, "showTheGui", thePlayer, thePlayer, state ) else state = false triggerClientEvent ( thePlayer, "showTheGui", thePlayer, thePlayer, state ) end end end addEvent ( "memberCheck", true ) addEventHandler ( "memberCheck", root, checkIfMember ) Ah got it, thanks!! 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