ZkillCatIV Posted September 11, 2016 Share Posted September 11, 2016 Im somewhat new in scripting, i was making a login panel and the login panel is working and i can login and register but the only problem i have is that when i get join and i'm on the login panel and somebody else joins and is on the panel and mess with it my panel also changes,it acts like the login panel was in the server instead of just the player that joins. to be honest i don't really understand the localPlayer and the root and the getRootElement() and all of that but i have a feeling that that is what is going wrong on my script please help me Link to comment
EstrategiaGTA Posted September 11, 2016 Share Posted September 11, 2016 (edited) How would we even try to help you with literally zero lines of your code? Also, please use a better topic title than "HELP"... Edited September 11, 2016 by EstrategiaGTA Link to comment
Dimos7 Posted September 11, 2016 Share Posted September 11, 2016 Post your full code here Link to comment
ZkillCatIV Posted September 11, 2016 Author Share Posted September 11, 2016 9 hours ago, ZkillCatIV said: Im somewhat new in scripting, i was making a login panel and the login panel is working and i can login and register but the only problem i have is that when i get join and i'm on the login panel and somebody else joins and is on the panel and mess with it my panel also changes,it acts like the login panel was in the server instead of just the player that joins. to be honest i don't really understand the localPlayer and the root and the getRootElement() and all of that but i have a feeling that that is what is going wrong on my script please help me client side ---------------------------------------- addEvent("accountFound",true) addEvent("accountNotFound",true) addEvent("clientResponse",true) function playerJoined () toggleAllControls(false) fadeCamera(false) joinImg = guiCreateStaticImage(0, 0, 1920, 1080, "login.png", false) loadingText = guiCreateLabel(801, 44, 336, 88, "LOADING ...", false,joinImg) guiLabelSetHorizontalAlign(loadingText, "center", false) guiLabelSetVerticalAlign(loadingText, "center") findingText = guiCreateLabel(801, 44, 336, 88, "FINDING ACCOUNT ...", false,joinImg) guiSetFont(findingText, "clear-normal") guiLabelSetHorizontalAlign(findingText, "center", false) guiLabelSetVerticalAlign(findingText, "center") guiSetVisible(findingText,false) local resource = getResourceFromName ( "login" ) local resourceState = getResourceState( resource ) if (resourceState == "running") then guiSetVisible(loadingText,false) guiSetVisible(findingText,true) triggerServerEvent("checkAccounts", localPlayer) end end function playerLogin () showCursor(true) destroyElement(findingText) foundText = guiCreateLabel(801, 44, 336, 88, "ACCOUNT FOUND ...", false,joinImg) guiLabelSetHorizontalAlign(foundText, "center", false) guiLabelSetVerticalAlign(foundText, "center") userNameTextL = guiCreateLabel(1591, 494, 235, 25, "PLEASE ENTER USERNAME", false, joinImg) userNameBoxL = guiCreateEdit(1553, 519, 309, 34, "", false, joinImg) passwordTextL = guiCreateLabel(1591, 639, 235, 25, "PLEASE ENTER PASSWORD", false, joinImg) passwordBoxL = guiCreateEdit(1553, 664, 309, 34, "", false, joinImg) enterButtonL = guiCreateButton(1637, 838, 160, 42, "LOGIN", false, joinImg) addEventHandler("onClientGUIClick",enterButtonL,login,false) end function login() triggerServerEvent("playerLogins",localPlayer,guiGetText(userNameBoxL),guiGetText(passwordBoxL)) guiSetEnabled(enterButtonL,false) setTimer(guiSetEnabled,3000,1,enterButtonL,true) end function playerRegister () showCursor(true) destroyElement(findingText) unfoundText = guiCreateLabel(801, 44, 336, 88, "ACCOUNT NOT FOUND ...", false,joinImg) guiLabelSetColor(unfoundText, 255, 67, 67) guiLabelSetHorizontalAlign(unfoundText, "center", false) guiLabelSetVerticalAlign(unfoundText, "center") passwordTextR = guiCreateLabel(1591, 494, 235, 25, "PLEASE ENTER PASSWORD", false, joinImg) passwordBoxR = guiCreateEdit(1553, 519, 309, 34, "", false, joinImg) userNameTextR = guiCreateLabel(1591, 359, 235, 25, "PLEASE ENTER USERNAME", false, joinImg) userNameBoxR = guiCreateEdit(1553, 384, 309, 34, "", false, joinImg) emailTextR = guiCreateLabel(1591, 639, 235, 25, "PLEASE ENTER EMAIL", false, joinImg) mailBoxR = guiCreateEdit(1553, 664, 309, 34, "", false, joinImg) emailTextsR = guiCreateLabel(1563, 708, 289, 59, " * email will be used as a password backup,\n also as a form of security and contact issues. please give your authentic and active email\n Thank you.", false, joinImg) enterButtonR = guiCreateButton(1637, 838, 160, 42, "", false, joinImg) addEventHandler("onClientGUIClick",enterButtonR,register,false) end function register() if #guiGetText(userNameBoxR) <= 4 then guiSetText(unfoundText,"THE USERNAME HAS TO HAVE AT LEAST FIVE LETTERS") return end if #guiGetText(passwordBoxR) <= 4 then guiSetText(unfoundText,"THE PASSWORD HAS TO HAVE AT LEAST FIVE LETTERS.") return end if #guiGetText(mailBoxR) <= 9 then guiSetText(unfoundText,"SET AN EMAIL ") return else triggerServerEvent("playerRegisters",localPlayer ,guiGetText(userNameBoxR),guiGetText(passwordBoxR),guiGetText(mailBoxR)) guiSetEnabled(enterButtonR,false) setTimer(guiSetEnabled,3000,1,enterButtonR,true) end end function loginError( number , errors ) if number == 1 or number == 2 then guiSetText(foundText,errors) elseif number == 4 then guiSetText(unfoundText,errors) elseif number == 3 then destroyElement(joinImg) showCursor(false) toggleAllControls(true) fadeCamera(true,5) end end addEventHandler("onClientResourceStart", getRootElement(), playerJoined) addEventHandler("accountFound", getRootElement(), playerLogin) addEventHandler("accountNotFound", getRootElement(), playerRegister) addEventHandler("clientResponse", getRootElement(), loginError) server side--------------------------------------------------------------- addEvent("checkAccounts",true) addEvent("playerLogins",true) addEvent("playerRegisters",true) function checkingAccounts() heSerial = getPlayerSerial(client) accounts = getAccountsBySerial(heSerial) if (#accounts ~= 0) then triggerClientEvent("accountFound",client) else triggerClientEvent("accountNotFound",client) end end function loginProcces (username , password ) if not getAccount(username) then triggerClientEvent(client,"clientResponse",client,1 , "INVALID USERNAME") return end if not getAccount(username,password) then triggerClientEvent(client,"clientResponse",client,2,"INVALID PASSWORD,") return end logIn(client,getAccount(username),password) triggerClientEvent(client,"clientResponse",client,3) end function registerProcces(username, password, email) if getAccount(username) then triggerClientEvent(client,"clientResponse",client,4,"THERE IS ANOTHER ACCOUNT WITH THIS NAME TRY SOMETHING NEW ") return end addAccount(username,password) logIn(client,getAccount(username),password) setAccountData (getAccount(username),heSerial,password) setAccountData (getAccount(username),email,username) triggerClientEvent(client,"clientResponse",client,3) end addEventHandler("checkAccounts",getRootElement(),checkingAccounts) addEventHandler("playerLogins",getRootElement(),loginProcces) addEventHandler("playerRegisters",getRootElement(),registerProcces) 5 hours ago, Dimos7 said: Post your full code here I quoted my full code to my post. by the way thank you for trying to help me 6 hours ago, EstrategiaGTA said: How would we even try to help you with literally zero lines of your code? Also, please use a better topic title than "HELP"... I quoted my full code to my post. by the way thank you for trying to help me and im also new posting things in forums next time i will put a better name Link to comment
Gravestone Posted September 11, 2016 Share Posted September 11, 2016 It's hard for me to read your code like this xd. Since you're new to the forums, you can post your code by clicking on the '<>' option in the taskbar and then select 'lua' and paste your code. Link to comment
Dimos7 Posted September 11, 2016 Share Posted September 11, 2016 2 hours ago, ZkillCatIV said: client side ---------------------------------------- addEvent("accountFound",true) addEvent("accountNotFound",true) addEvent("clientResponse",true) function playerJoined () toggleAllControls(false) fadeCamera(false) joinImg = guiCreateStaticImage(0, 0, 1920, 1080, "login.png", false) loadingText = guiCreateLabel(801, 44, 336, 88, "LOADING ...", false,joinImg) guiLabelSetHorizontalAlign(loadingText, "center", false) guiLabelSetVerticalAlign(loadingText, "center") findingText = guiCreateLabel(801, 44, 336, 88, "FINDING ACCOUNT ...", false,joinImg) guiSetFont(findingText, "clear-normal") guiLabelSetHorizontalAlign(findingText, "center", false) guiLabelSetVerticalAlign(findingText, "center") guiSetVisible(findingText,false) local resource = getResourceFromName ( "login" ) local resourceState = getResourceState( resource ) if (resourceState == "running") then guiSetVisible(loadingText,false) guiSetVisible(findingText,true) triggerServerEvent("checkAccounts", localPlayer) end end function playerLogin () showCursor(true) destroyElement(findingText) foundText = guiCreateLabel(801, 44, 336, 88, "ACCOUNT FOUND ...", false,joinImg) guiLabelSetHorizontalAlign(foundText, "center", false) guiLabelSetVerticalAlign(foundText, "center") userNameTextL = guiCreateLabel(1591, 494, 235, 25, "PLEASE ENTER USERNAME", false, joinImg) userNameBoxL = guiCreateEdit(1553, 519, 309, 34, "", false, joinImg) passwordTextL = guiCreateLabel(1591, 639, 235, 25, "PLEASE ENTER PASSWORD", false, joinImg) passwordBoxL = guiCreateEdit(1553, 664, 309, 34, "", false, joinImg) enterButtonL = guiCreateButton(1637, 838, 160, 42, "LOGIN", false, joinImg) addEventHandler("onClientGUIClick",enterButtonL,login,false) end function login() triggerServerEvent("playerLogins",localPlayer,guiGetText(userNameBoxL),guiGetText(passwordBoxL)) guiSetEnabled(enterButtonL,false) setTimer(guiSetEnabled,3000,1,enterButtonL,true) end function playerRegister () showCursor(true) destroyElement(findingText) unfoundText = guiCreateLabel(801, 44, 336, 88, "ACCOUNT NOT FOUND ...", false,joinImg) guiLabelSetColor(unfoundText, 255, 67, 67) guiLabelSetHorizontalAlign(unfoundText, "center", false) guiLabelSetVerticalAlign(unfoundText, "center") passwordTextR = guiCreateLabel(1591, 494, 235, 25, "PLEASE ENTER PASSWORD", false, joinImg) passwordBoxR = guiCreateEdit(1553, 519, 309, 34, "", false, joinImg) userNameTextR = guiCreateLabel(1591, 359, 235, 25, "PLEASE ENTER USERNAME", false, joinImg) userNameBoxR = guiCreateEdit(1553, 384, 309, 34, "", false, joinImg) emailTextR = guiCreateLabel(1591, 639, 235, 25, "PLEASE ENTER EMAIL", false, joinImg) mailBoxR = guiCreateEdit(1553, 664, 309, 34, "", false, joinImg) emailTextsR = guiCreateLabel(1563, 708, 289, 59, " * email will be used as a password backup,\n also as a form of security and contact issues. please give your authentic and active email\n Thank you.", false, joinImg) enterButtonR = guiCreateButton(1637, 838, 160, 42, "", false, joinImg) addEventHandler("onClientGUIClick",enterButtonR,register,false) end function register() if #guiGetText(userNameBoxR) <= 4 then guiSetText(unfoundText,"THE USERNAME HAS TO HAVE AT LEAST FIVE LETTERS") return end if #guiGetText(passwordBoxR) <= 4 then guiSetText(unfoundText,"THE PASSWORD HAS TO HAVE AT LEAST FIVE LETTERS.") return end if #guiGetText(mailBoxR) <= 9 then guiSetText(unfoundText,"SET AN EMAIL ") return else triggerServerEvent("playerRegisters",localPlayer ,guiGetText(userNameBoxR),guiGetText(passwordBoxR),guiGetText(mailBoxR)) guiSetEnabled(enterButtonR,false) setTimer(guiSetEnabled,3000,1,enterButtonR,true) end end function loginError( number , errors ) if number == 1 or number == 2 then guiSetText(foundText,errors) elseif number == 4 then guiSetText(unfoundText,errors) elseif number == 3 then destroyElement(joinImg) showCursor(false) toggleAllControls(true) fadeCamera(true,5) end end addEventHandler("onClientResourceStart", getRootElement(), playerJoined) addEventHandler("accountFound", getRootElement(), playerLogin) addEventHandler("accountNotFound", getRootElement(), playerRegister) addEventHandler("clientResponse", getRootElement(), loginError) server side--------------------------------------------------------------- addEvent("checkAccounts",true) addEvent("playerLogins",true) addEvent("playerRegisters",true) function checkingAccounts() heSerial = getPlayerSerial(client) accounts = getAccountsBySerial(heSerial) if (#accounts ~= 0) then triggerClientEvent("accountFound",client) else triggerClientEvent("accountNotFound",client) end end function loginProcces (username , password ) if not getAccount(username) then triggerClientEvent(client,"clientResponse",client,1 , "INVALID USERNAME") return end if not getAccount(username,password) then triggerClientEvent(client,"clientResponse",client,2,"INVALID PASSWORD,") return end logIn(client,getAccount(username),password) triggerClientEvent(client,"clientResponse",client,3) end function registerProcces(username, password, email) if getAccount(username) then triggerClientEvent(client,"clientResponse",client,4,"THERE IS ANOTHER ACCOUNT WITH THIS NAME TRY SOMETHING NEW ") return end addAccount(username,password) logIn(client,getAccount(username),password) setAccountData (getAccount(username),heSerial,password) setAccountData (getAccount(username),email,username) triggerClientEvent(client,"clientResponse",client,3) end addEventHandler("checkAccounts",getRootElement(),checkingAccounts) addEventHandler("playerLogins",getRootElement(),loginProcces) addEventHandler("playerRegisters",getRootElement(),registerProcces) Link to comment
ZkillCatIV Posted September 11, 2016 Author Share Posted September 11, 2016 9 minutes ago, Gravestone said: It's hard for me to read your code like this xd. Since you're new to the forums, you can post your code by clicking on the '<>' option in the taskbar and then select 'lua' and paste your code. addEvent("accountFound",true) addEvent("accountNotFound",true) addEvent("clientResponse",true) function playerJoined () toggleAllControls(false) fadeCamera(false) joinImg = guiCreateStaticImage(0, 0, 1920, 1080, "login.png", false) loadingText = guiCreateLabel(801, 44, 336, 88, "LOADING ...", false,joinImg) guiLabelSetHorizontalAlign(loadingText, "center", false) guiLabelSetVerticalAlign(loadingText, "center") findingText = guiCreateLabel(801, 44, 336, 88, "FINDING ACCOUNT ...", false,joinImg) guiSetFont(findingText, "clear-normal") guiLabelSetHorizontalAlign(findingText, "center", false) guiLabelSetVerticalAlign(findingText, "center") guiSetVisible(findingText,false) local resource = getResourceFromName ( "login" ) local resourceState = getResourceState( resource ) if (resourceState == "running") then guiSetVisible(loadingText,false) guiSetVisible(findingText,true) triggerServerEvent("checkAccounts", localPlayer) end end function playerLogin () showCursor(true) destroyElement(findingText) foundText = guiCreateLabel(801, 44, 336, 88, "ACCOUNT FOUND ...", false,joinImg) guiLabelSetHorizontalAlign(foundText, "center", false) guiLabelSetVerticalAlign(foundText, "center") userNameTextL = guiCreateLabel(1591, 494, 235, 25, "PLEASE ENTER USERNAME", false, joinImg) userNameBoxL = guiCreateEdit(1553, 519, 309, 34, "", false, joinImg) passwordTextL = guiCreateLabel(1591, 639, 235, 25, "PLEASE ENTER PASSWORD", false, joinImg) passwordBoxL = guiCreateEdit(1553, 664, 309, 34, "", false, joinImg) enterButtonL = guiCreateButton(1637, 838, 160, 42, "LOGIN", false, joinImg) addEventHandler("onClientGUIClick",enterButtonL,login,false) end function login() triggerServerEvent("playerLogins",localPlayer,guiGetText(userNameBoxL),guiGetText(passwordBoxL)) guiSetEnabled(enterButtonL,false) setTimer(guiSetEnabled,3000,1,enterButtonL,true) end function playerRegister () showCursor(true) destroyElement(findingText) unfoundText = guiCreateLabel(801, 44, 336, 88, "ACCOUNT NOT FOUND ...", false,joinImg) guiLabelSetColor(unfoundText, 255, 67, 67) guiLabelSetHorizontalAlign(unfoundText, "center", false) guiLabelSetVerticalAlign(unfoundText, "center") passwordTextR = guiCreateLabel(1591, 494, 235, 25, "PLEASE ENTER PASSWORD", false, joinImg) passwordBoxR = guiCreateEdit(1553, 519, 309, 34, "", false, joinImg) userNameTextR = guiCreateLabel(1591, 359, 235, 25, "PLEASE ENTER USERNAME", false, joinImg) userNameBoxR = guiCreateEdit(1553, 384, 309, 34, "", false, joinImg) emailTextR = guiCreateLabel(1591, 639, 235, 25, "PLEASE ENTER EMAIL", false, joinImg) mailBoxR = guiCreateEdit(1553, 664, 309, 34, "", false, joinImg) emailTextsR = guiCreateLabel(1563, 708, 289, 59, " * email will be used as a password backup,\n also as a form of security and contact issues. please give your authentic and active email\n Thank you.", false, joinImg) enterButtonR = guiCreateButton(1637, 838, 160, 42, "", false, joinImg) addEventHandler("onClientGUIClick",enterButtonR,register,false) end function register() if #guiGetText(userNameBoxR) <= 4 then guiSetText(unfoundText,"THE USERNAME HAS TO HAVE AT LEAST FIVE LETTERS") return end if #guiGetText(passwordBoxR) <= 4 then guiSetText(unfoundText,"THE PASSWORD HAS TO HAVE AT LEAST FIVE LETTERS.") return end if #guiGetText(mailBoxR) <= 9 then guiSetText(unfoundText,"SET AN EMAIL ") return else triggerServerEvent("playerRegisters",localPlayer ,guiGetText(userNameBoxR),guiGetText(passwordBoxR),guiGetText(mailBoxR)) guiSetEnabled(enterButtonR,false) setTimer(guiSetEnabled,3000,1,enterButtonR,true) end end function loginError( number , errors ) if number == 1 or number == 2 then guiSetText(foundText,errors) elseif number == 4 then guiSetText(unfoundText,errors) elseif number == 3 then destroyElement(joinImg) showCursor(false) toggleAllControls(true) fadeCamera(true,5) end end addEventHandler("onClientResourceStart", getRootElement(), playerJoined) addEventHandler("accountFound", getRootElement(), playerLogin) addEventHandler("accountNotFound", getRootElement(), playerRegister) addEventHandler("clientResponse", getRootElement(), loginError) that is the client side addEvent("checkAccounts",true) addEvent("playerLogins",true) addEvent("playerRegisters",true) function checkingAccounts() heSerial = getPlayerSerial(client) accounts = getAccountsBySerial(heSerial) if (#accounts ~= 0) then triggerClientEvent("accountFound",client) else triggerClientEvent("accountNotFound",client) end end function loginProcces (username , password ) if not getAccount(username) then triggerClientEvent(client,"clientResponse",client,1 , "INVALID USERNAME") return end if not getAccount(username,password) then triggerClientEvent(client,"clientResponse",client,2,"INVALID PASSWORD,") return end logIn(client,getAccount(username),password) triggerClientEvent(client,"clientResponse",client,3) end function registerProcces(username, password, email) if getAccount(username) then triggerClientEvent(client,"clientResponse",client,4,"THERE IS ANOTHER ACCOUNT WITH THIS NAME TRY SOMETHING NEW ") return end addAccount(username,password) logIn(client,getAccount(username),password) setAccountData (getAccount(username),heSerial,password) setAccountData (getAccount(username),email,username) triggerClientEvent(client,"clientResponse",client,3) end addEventHandler("checkAccounts",getRootElement(),checkingAccounts) addEventHandler("playerLogins",getRootElement(),loginProcces) addEventHandler("playerRegisters",getRootElement(),registerProcces) and this is the server side thank you so much for the help Link to comment
_DrXenon Posted September 11, 2016 Share Posted September 11, 2016 Let me get this straight; The login panel appears to everyone when it is supposed to appear to one guy? and the changes that are supposed to be changed for one guy is being changed for everyone? Link to comment
ZkillCatIV Posted September 11, 2016 Author Share Posted September 11, 2016 (edited) 36 minutes ago, SuperCroz said: Let me get this straight; The login panel appears to everyone when it is supposed to appear to one guy? and the changes that are supposed to be changed for one guy is being changed for everyone? well if a player is on the login panel and have not login account the in the panel will show a message that says "account not found" but if in the process another player joins and has already an account it shows a message saying "account found" but the message from the panel that says "account found " also show on the panel from the other player that says "account not found " if like the gui panel was on the server and not on the players. i think it has to do with to whom i am sending the panel but i am not sure i already tried replacing the getRootElement() to other variables and the panel only shows to the player that join but the changes affect the other players panels too. Edited September 11, 2016 by ZkillCatIV Link to comment
Dimos7 Posted September 11, 2016 Share Posted September 11, 2016 addEvent("checkAccounts",true) addEvent("playerLogins",true) addEvent("playerRegisters",true) function checkingAccounts(thePlayer) heSerial = getPlayerSerial(thePlayer) accounts = getAccountsBySerial(heSerial) if (#accounts ~= 0) then triggerClientEvent(thePlayer, "accountFound", root) else triggerClientEvent(thePlayer,"accountNotFound",root) end end function loginProcces (thePlayer,username , password ) if not getAccount(username) then triggerClientEvent(thePlayer,"clientResponse", root,1 , "INVALID USERNAME") return end if not getAccount(username,password) then triggerClientEvent(thePlayer,"clientResponse", root,2,"INVALID PASSWORD,") return end logIn(thePlayer,getAccount(username),password) triggerClientEvent(thePlayer,"clientResponse",root,3) end function registerProcces(thePlayer ,username, password, email) if getAccount(username) then triggerClientEvent(thePlayer,"clientResponse",root,4,"THERE IS ANOTHER ACCOUNT WITH THIS NAME TRY SOMETHING NEW ") return end addAccount(username,password) logIn(thePlayer,getAccount(username),password) setAccountData (getAccount(username),heSerial,password) setAccountData (getAccount(username),email,username) triggerClientEvent(thePlayer,"clientResponse",root,3) end addEventHandler("checkAccounts",getRootElement(),checkingAccounts) addEventHandler("playerLogins",getRootElement(),loginProcces) addEventHandler("playerRegisters",getRootElement(),registerProcces) try this 1 Link to comment
_DrXenon Posted September 11, 2016 Share Posted September 11, 2016 well fixing it would be by: triggerClientEvent("accountFound",client) -- triggerClientEvent has an optional argument, the first argument, this way; triggerClientEvent([sendTo,]"eventName,...) if you don't fill the first optional argument, it will automatically be filled with 'root' as it is the default value ( this means it will show to everyone ). Therefore, choose the first argument as 'client' in order to show the changes to the client that pressed the gui element or so. example: triggerClientEvent(source,"eventName",source) ^ in this case the source is the localPlayer only if you set it on the client side file as the source element when you trigger the server event, this means; triggerServerEvent("eventName",sourceElement) or just use; triggerClientEvent(client,"eventName",client). Note: triggerServerEvent doesn't have first optional argument, Iy is automatically sent to the localPlayer. I hope you understood and I hope I helped. 1 Link to comment
ZkillCatIV Posted September 12, 2016 Author Share Posted September 12, 2016 thank you so much dimos7 , the code worked perfectly i appreciate your time and your help. and also thank you so much SuperCorz for explaining the problem and the solution with great detail thank you guys so much for helping me it works perfect now. Link to comment
Dimos7 Posted September 12, 2016 Share Posted September 12, 2016 client is all players thePlayer or source is only the player join and np 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