opnaiC Posted July 11, 2016 Share Posted July 11, 2016 client function onRegisterKlick ( ) -- ready local username = guiGetText(GUIEditor.edit[3]) local passwort = guiGetText(GUIEditor.edit[4]) if username ~= "" and passwort ~= "" then if exports.dxgui:dxCheckBoxGetSelected ( checkboxM ) == true then checksaveM = true triggerServerEvent("register",getLocalPlayer(),getLocalPlayer(),username,passwort,checkSaveM) elseif exports.dxgui:dxCheckBoxGetSelected ( checkboxF ) == true then checksaveF = true triggerServerEvent("register",getLocalPlayer(),getLocalPlayer(),username,passwort,checkSaveF) else checksaveM = false checksaveF = false cancelEvent() end end end addEventHandler("onClientDXClick",GUIEditor.button[4],onRegisterKlick,false) function closeLoginPanelR ( ) exports.dxgui:dxSetVisible(GUIEditor.window[2],false) guiSetVisible(GUIEditor.edit[3],false) guiSetVisible(GUIEditor.edit[4],false) showChat(true) setPlayerHudComponentVisible( "radar", true ) end addEvent("closeLoginPanelR",true) addEventHandler("closeLoginPanelR",getRootElement(),closeLoginPanelR) server function register_func ( player, username, passwort, checksaveM, checksaveF) local acc = addAccount(username,passwort) if acc then if checksaveM == true then mann_func () elseif checksaveF == true then frau_func () else cancelEvent() end logIn(player,acc,passwort) triggerClientEvent(player,"closeLoginPanelR",player) else triggerClientEvent(player,"errorMsg2",player) end end addEvent("register",true) addEventHandler("register",getRootElement(),register_func) function mann_func () local playeraccount = getPlayerAccount (source) setAccountData (playeraccount, "gen", mann) setPedSkin (source, 78) end function frau_func () local playeraccount = getPlayerAccount (source) setAccountData (playeraccount, "gen", frau) setPedSkin (source, 77) end Something is wrong here it dont sets the skin and data Link to comment
Walid Posted July 11, 2016 Share Posted July 11, 2016 many things wrong you need to fix all of them by yourself. -- Client side function onRegisterKlick ( ) -- ready local username = guiGetText(GUIEditor.edit[3]) local passwort = guiGetText(GUIEditor.edit[4]) if username ~= "" and passwort ~= "" then if exports.dxgui:dxCheckBoxGetSelected ( checkboxM ) == true then checksaveM = true triggerServerEvent("register",getLocalPlayer(),getLocalPlayer(),username,passwort,checkSaveM) elseif exports.dxgui:dxCheckBoxGetSelected ( checkboxF ) == true then triggerServerEvent("register",getLocalPlayer(),getLocalPlayer(),username,passwort) else checksaveM = false checksaveF = false end end end addEventHandler("onClientDXClick",GUIEditor.button[4],onRegisterKlick,false) function closeLoginPanelR ( ) exports.dxgui:dxSetVisible(GUIEditor.window[2],false) guiSetVisible(GUIEditor.edit[3],false) guiSetVisible(GUIEditor.edit[4],false) showChat(true) setPlayerHudComponentVisible( "radar", true ) end addEvent("closeLoginPanelR",true) addEventHandler("closeLoginPanelR",getRootElement(),closeLoginPanelR) -- Server side function register_func (player, username, passwort, check) local acc = addAccount(username,passwort) if acc then if checksaveM then mann_func (player) else frau_func (player) end logIn(player,acc,passwort) triggerClientEvent(player,"closeLoginPanelR",player) else triggerClientEvent(player,"errorMsg2",player) end end addEvent("register",true) addEventHandler("register",getRootElement(),register_func) function mann_func (player) local playeraccount = getPlayerAccount (player) setAccountData (playeraccount, "gen", mann) setPedSkin (player, 78) end function frau_func () local playeraccount = getPlayerAccount (player) setAccountData (playeraccount, "gen", frau) setPedSkin (player, 77) end Link to comment
Captain Cody Posted July 11, 2016 Share Posted July 11, 2016 Server function register_func ( username, passwort, checksaveM, checksaveF) local acc = addAccount(username,passwort) if acc then if checksaveM == true then mann_func (client) elseif checksaveF == true then frau_func (client) else cancelEvent() end logIn(client,acc,passwort) triggerClientEvent(client,"closeLoginPanelR",client) else triggerClientEvent(client,"errorMsg2",client) end end addEvent("register",true) addEventHandler("register",getRootElement(),register_func) function mann_func (player) local playeraccount = getPlayerAccount (player) setAccountData (playeraccount, "gen", mann) setElementModel (player, 78) end function frau_func (player) local playeraccount = getPlayerAccount (player) setAccountData (playeraccount, "gen", frau) setElementModel (player, 77) end Client - function onRegisterKlick ( ) -- ready local username = guiGetText(GUIEditor.edit[3]) local passwort = guiGetText(GUIEditor.edit[4]) if username ~= "" and passwort ~= "" then if exports.dxgui:dxCheckBoxGetSelected ( checkboxM ) == true then checksaveM = true triggerServerEvent("register",getLocalPlayer(),username,passwort,checkSaveM) elseif exports.dxgui:dxCheckBoxGetSelected ( checkboxF ) == true then checksaveF = true triggerServerEvent("register",getLocalPlayer(),username,passwort,checkSaveF) else checksaveM = false checksaveF = false cancelEvent() end end end addEventHandler("onClientDXClick",GUIEditor.button[4],onRegisterKlick,false) function closeLoginPanelR ( ) exports.dxgui:dxSetVisible(GUIEditor.window[2],false) guiSetVisible(GUIEditor.edit[3],false) guiSetVisible(GUIEditor.edit[4],false) showChat(true) setPlayerHudComponentVisible( "radar", true ) end addEvent("closeLoginPanelR",true) addEventHandler("closeLoginPanelR",getRootElement(),closeLoginPanelR) When you trigger a server side event, the player who sent it is predefined as client and using source in different functions WILL NOT WORK unless source is defined in the previous function. Don't send the player through as an individual argument when triggering client events always use (Client) in the server side. Link to comment
Walid Posted July 11, 2016 Share Posted July 11, 2016 Don't send the player through as an individual argument when triggering client events always use (Client) in the server side. triggerServerEvent("EventName" , localPlayer)source is localPlayer client is localPlayer triggerServerEvent("EventName" , resourceRoot or root)source is resourceRoot or root client is localPlayer Link to comment
Captain Cody Posted July 11, 2016 Share Posted July 11, 2016 Oh it is? From what I've read before. Using the variable client is the most efficient and safest way of sending a player element between server and client. Link to comment
Walid Posted July 11, 2016 Share Posted July 11, 2016 Oh it is? From what I've read before. Using the variable client is the most efficient and safest way of sending a player element between server and client. As i mentioned above, you can use both of them. Link to comment
Captain Cody Posted July 11, 2016 Share Posted July 11, 2016 Any ways - Just noticed a few things that I skipped by accident client -- function onRegisterKlick ( ) -- ready local username = guiGetText(GUIEditor.edit[3]) local passwort = guiGetText(GUIEditor.edit[4]) if username ~= "" and passwort ~= "" then if exports.dxgui:dxCheckBoxGetSelected ( checkboxM ) == true then triggerServerEvent("register",resourceRoot,username,passwort,true,false) elseif exports.dxgui:dxCheckBoxGetSelected ( checkboxF ) == true then triggerServerEvent("register",resourceRoot,username,passwort,false,true) -- Resource root uses less resources else checksaveM = false checksaveF = false cancelEvent() end end end addEventHandler("onClientDXClick",GUIEditor.button[4],onRegisterKlick,false) function closeLoginPanelR ( ) exports.dxgui:dxSetVisible(GUIEditor.window[2],false) guiSetVisible(GUIEditor.edit[3],false) guiSetVisible(GUIEditor.edit[4],false) showChat(true) setPlayerHudComponentVisible( "radar", true ) end addEvent("closeLoginPanelR",true) addEventHandler("closeLoginPanelR",localPlayer,closeLoginPanelR) server -- function register_func ( username, passwort, checksaveM, checksaveF) local acc = addAccount(username,passwort) if acc then if checksaveM == true then mann_func (client) elseif checksaveF == true then frau_func (client) else cancelEvent() end logIn(client,acc,passwort) triggerClientEvent(client,"closeLoginPanelR",client) else triggerClientEvent(client,"errorMsg2",client) end end addEvent("register",true) addEventHandler("register",resourceRoot,register_func) function mann_func (player) local playeraccount = getPlayerAccount (player) setAccountData (playeraccount, "gen", mann) setElementModel (player, 78) end function frau_func (player) local playeraccount = getPlayerAccount (player) setAccountData (playeraccount, "gen", frau) setElementModel (player, 77) end 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