TrickyTommy Posted November 7, 2017 Share Posted November 7, 2017 Hi. I have a problem, that whoever is online on my server, sees edit boxes, that should only appear to who clicked a button (i use localPlayer), and it simply just appears for the ones who already passed the login panel. Pieces of scripts: (Client and serverside) Client: function loginButton_Click() loginUsernameText = guiGetText (loginUsername) loginPasswordText = guiGetText (loginPassword) triggerServerEvent ("attemptLogin", localPlayer, localPlayer, loginUsernameText, loginPasswordText) end Server: function attemptLogin(element, accountname, password) local q = exports.db:sqlQuery ("SELECT * FROM users WHERE accountname = '"..accountname.."' AND password = '"..md5(password).."';") local result = dbPoll(q, -1) if #result > 0 then for k, v in ipairs(result) do triggerClientEvent ("outputAccountMessage", element, "Successful login!", "information") setElementData (element, "logged", true, true) triggerClientEvent ("destroyEdits", element) setElementData (element, "id", v['id'], true) setElementData (element, "admin", v['admin'], true) setElementData (element, "aduty", v['aduty'], true) setElementData (element, "anick", v['anick'], true) setElementData (element, "banned", v['banned'], true) setElementData (element, "accountname", v['accountname'], true) local q = exports.db:sqlQuery ("SELECT * FROM characters WHERE owner = '"..getElementData(element, "id").."';") local result = dbPoll(q, -1) if #result > 0 then for k, v in ipairs(result) do setElementData (element, "hud", true, true) setElementData (element, "characterChosen", true, true) spawnPlayer (element, tonumber(v['posX']), tonumber(v['posY']), tonumber(v['posZ'])) fadeCamera (element, true) setCameraTarget (element, element) showCursor (element, false) showChat (element, true) setPedArmor (element, v['armor']) setElementHealth (element, v['health']) setElementInterior (element, v['interior']) setElementDimension (element, v['dimension']) setElementData (element, "name", v['name'], true) setElementModel (element, v['skinID']) setElementData (element, "anick", v['anick'], true) setElementData (element, "aduty", v['aduty'], true) dbFree (q) end else setElementData (element, "characterChosen", false, true) triggerClientEvent ("characterCreationMenu", element, element, v['accountname']) end end else triggerClientEvent ("outputAccountMessage", element, "Login failure!", "error") end dbFree (q) end addEvent ("attemptLogin", true) addEventHandler ("attemptLogin", root, attemptLogin) I mean for example edit boxes will appear to every if localPlayer's account has no character that is owned by his account id. And at the call of "destroyEdits" the editBoxes will get destroyed for everyone who has visual on the login panel. What did i screw up? Link to comment
Moderators IIYAMA Posted November 7, 2017 Moderators Share Posted November 7, 2017 (edited) https://wiki.multitheftauto.com/wiki/TriggerClientEvent Syntax: bool triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] ) bool triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] ) You forgot to set the sendTo. Edited November 7, 2017 by IIYAMA 1 Link to comment
TrickyTommy Posted November 7, 2017 Author Share Posted November 7, 2017 3 minutes ago, IIYAMA said: https://wiki.multitheftauto.com/wiki/TriggerClientEvent Syntax: bool triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] ) bool triggerClientEvent ( [table/element sendTo=getRootElement()], string name, element sourceElement, [arguments...] ) You forgot to set the sendTo. So the correct way is this: ? triggerClientEvent (element, "characterCreationMenu", element, v['accountname']) 1 Link to comment
Moderators IIYAMA Posted November 7, 2017 Moderators Share Posted November 7, 2017 YUP 1 Link to comment
TrickyTommy Posted November 7, 2017 Author Share Posted November 7, 2017 ohh i see. i thought that triggerServerEvent's arg order is the same as triggerClientEvent's. 1 Link to comment
Moderators IIYAMA Posted November 7, 2017 Moderators Share Posted November 7, 2017 It is a common mistake (I am making sometimes the same mistake), but there is always wiki to find it. 1 Link to comment
TrickyTommy Posted November 7, 2017 Author Share Posted November 7, 2017 (edited) yeah, but this forum helped me more so far than any mta-sa wikipedia page. Edited November 7, 2017 by TrickyTommy 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