KraZ Posted January 22, 2012 Share Posted January 22, 2012 can someone tell me what i have did wrong here and how i can fix it? (If you decide to fix it your self can you tell me what was wrong?) some things here was used from Xeno's login sys. thanks xeno. Client side: addEventHandler("onClientResourceStart",resourceRoot, function() login_window = guiCreateWindow(237,96,334,338,"KraZ'World Some RP: Login Screen",false) guiSetVisible(login_window, true) showCursor(true) guiSetInputEnabled (true) guiWindowSetMovable(login_window,false) guiWindowSetSizable(login_window,false) krazworld_image = guiCreateStaticImage(17,16,296,124,"images/KraZWorld.png",false,login_window) login_button = guiCreateButton(37,267,124,53,"Login",false,login_window) guiSetFont(login_button,"clear-normal") username_label = guiCreateLabel(16,171,101,20,"Username:",false,login_window) guiLabelSetColor(username_label,255,255,255) guiLabelSetVerticalAlign(username_label,"top") guiLabelSetHorizontalAlign(username_label,"left",false) password_label = guiCreateLabel(17,220,76,24,"Password:",false,login_window) guiLabelSetColor(password_label,255,255,255) guiLabelSetVerticalAlign(password_label,"top") guiLabelSetHorizontalAlign(password_label,"left",false) username_edit = guiCreateEdit(78,170,244,23,"",false,login_window) password_Edit = guiCreateEdit(78,217,244,23,"",false,login_window) register_button = guiCreateButton(173,267,124,53,"Register",false,login_window) guiSetFont(register_button,"clear-normal") register_window = guiCreateWindow(216,145,374,251,"Registration",false) guiWindowSetMovable(register_window,false) guiWindowSetSizable(register_window,false) dusername_label = guiCreateLabel(12,45,105,18,"Desired Username:",false,register_window) guiLabelSetColor(dusername_label,255,255,255) guiLabelSetVerticalAlign(dusername_label,"top") guiLabelSetHorizontalAlign(dusername_label,"left",false) dusername_edit = guiCreateEdit(119,44,244,23,"",false,register_window) dpassword_label = guiCreateLabel(11,104,113,18,"Desired Password:",false,register_window) guiLabelSetColor(dpassword_label,255,255,255) guiLabelSetVerticalAlign(dpassword_label,"top") guiLabelSetHorizontalAlign(dpassword_label,"left",false) dpassword_edit = guiCreateEdit(121,101,243,23,"",false,register_window) regististration_button = guiCreateButton(41,172,131,60,"Register!",false,register_window) cancel_button = guiCreateButton(199,171,131,60,"Cancel!",false,register_window) guiSkinShop = guiCreateWindow(0.37*sx,0.80*sy,0.3*sx,0.15*sy,"Choose a skin!",false) done = guiCreateButton(0.25,0.60,0.50,0.30,"Done",true,guiSkinShop) left = guiCreateButton(0.07,0.60,0.15,0.30,"<-",true,guiSkinShop) right = guiCreateButton(0.78,0.60,0.15,0.30,"->",true,guiSkinShop) guiWindowSetSizable(guiSkinShop,false) guiSetVisible(guiSkinShop, false) skinLabel = guiCreateLabel(0.05,0.30,0.90,0.17,"Skins can be bought once ingame",true,guiSkinShop) guiSetAlpha(skinLabel,1) guiLabelSetColor(skinLabel,255,255,255) guiCreateStaticImage( 0.0001, 0.49, 0.99, 0.02, "red.png", true, guiSkinShop ) guiCreateStaticImage( 0.0001, 0.25, 0.99, 0.02, "red.png", true, guiSkinShop ) guiLabelSetHorizontalAlign(skinLabel,"center",false) guiSetFont(skinLabel,"default-bold-small") end ) addEventHandler("onClientGUIClick",getRootElement(), function login() if source == login_button then local getUsernameField = guiGetText(Username_edit) local getPasswordField = guiGetText(Password_edit) if getUsernameField and getPasswordField then triggerServerEvent("loginFromClient", getLocalPlayer(), getUsernameField, getPasswordField) end end if source == registration_button then local getUsernameField1 = guiGetText(dusername_edit) local getPasswordField1 = guiGetText(dpassword_edit) if getUsernameField1 and getPasswordField1 then triggerServerEvent("registerFromClient", getLocalPlayer(), getUsernameField1, getPasswordField1) triggerServerEvent("loginFromClient", getLocalPlayer(), getUsernameField1, getPasswordField1) end end end function (buttons) if source == login_button then if guiGetVisible(login_window) == true then guiSetVisible(login_Window, false) showCursor(false) end end if source == register_button then if guiGetVisible(login_window) == true then guiSetVisible(login_window) == false else guiGetVisible(register_window) == false guiSetVisible(register_window) == true showCursor(true) end end if source == cancel_button then if guiGetVisible(register_window) == true then guiSetVisible(register_window) == false else guiGetVisible(login_window) == false guiSetVisible(login_window) == true showCursor(true) end end end function goRight(player) local newSkin = getElementModel (localPlayer) + 1 while not setElementModel (localPlayer,newSkin) do newSkin = newSkin + 1 end end function goLeft(player) local newSkin = getElementModel (localPlayer) - 1 while not setElementModel (localPlayer,newSkin) do newSkin = newSkin - 1 end end function doneButton(thePlayer) guiSetVisible(guiSkinShop,false) showCursor(false) triggerServerEvent("setCameraRegister", localPlayer) if source == registration_button then if guiGetVisible(register_window) == true guiSetVisible(register_window) == false else guiGetVisible(guiSkinShop) == false guiSetVisible(guiSkinShop) == true end end end end addEvent("onClientLoginHide",true) addEventHandler("onClientLoginHide",getRootElement(), function() showCursor(false) guiSetVisible(register_window, false) guiSetVisible(login_window, false) guiSetVisible(guiSkinShop) guiSetInputEnabled(false) end ) addEventHandler ( "onClientGUIClick",right,goRight, false ) addEventHandler ( "onClientGUIClick",done,doneButton, false ) addEventHandler ( "onClientGUIClick",left,goLeft, false ) server side: addEvent("loginFromClient",true) -- Adds the event to be triggered! addEventHandler("loginFromClient",getRootElement(), -- When the event is triggered, this function will also be triggered! function(user,pass) -- Received user and pass data! local account = getAccount ( user, pass ) if account then -- Checks if login returned true, or is accepted! local isLoginAccepted = logIn(source, account, pass) -- Adds a variable to login! if isLoginAccepted then outputChatBox("You have successfully logged into "..user.."'s account!",source, 0,255,0,true) -- Outputs a success message if the player logged in! triggerClientEvent ("onClientLoginHide", getRootElement()) end else outputChatBox(user.."'s account does not exist! Please register!",source, 200,20,0,true) -- Outputs a fail message! end end ) addEvent("registerFromClient",true) -- Adds the event to be triggered! addEventHandler("registerFromClient",getRootElement(), -- When the event is triggered, this function will also be triggered! function(user1,pass1) -- Received user and pass data from the register GUI! local account1 = getAccount ( user1, pass1 ) local isRegisterAccepted = addAccount(user1,pass1) -- Adds a variable to addAccount! if isRegisterAccepted then -- Checks if addAccount returned true, or is accepted! outputChatBox("You have successfully registered "..user1.."'s account!",source, 0,255,0,true) -- Outputs a success message if the player registered! else -- If it failed, the account is already registered! outputChatBox(user1.."'s account already exists!",source, 200,20,0,true) -- Outputs a fail message! end end ) Link to comment
Sparrow Posted January 22, 2012 Share Posted January 22, 2012 what are the errors so we can help you. Link to comment
KraZ Posted January 22, 2012 Author Share Posted January 22, 2012 its always stuff like "(" expected (to close ")" Line 69) shit like tha <--- not exactly that. Link to comment
Sparrow Posted January 22, 2012 Share Posted January 22, 2012 try this: -- client addEventHandler("onClientResourceStart",resourceRoot, function() login_window = guiCreateWindow(237,96,334,338,"KraZ'World Some RP: Login Screen",false) guiSetVisible(login_window, true) showCursor(true) guiSetInputEnabled (true) guiWindowSetMovable(login_window,false) guiWindowSetSizable(login_window,false) krazworld_image = guiCreateStaticImage(17,16,296,124,"images/KraZWorld.png",false,login_window) login_button = guiCreateButton(37,267,124,53,"Login",false,login_window) guiSetFont(login_button,"clear-normal") username_label = guiCreateLabel(16,171,101,20,"Username:",false,login_window) guiLabelSetColor(username_label,255,255,255) guiLabelSetVerticalAlign(username_label,"top") guiLabelSetHorizontalAlign(username_label,"left",false) password_label = guiCreateLabel(17,220,76,24,"Password:",false,login_window) guiLabelSetColor(password_label,255,255,255) guiLabelSetVerticalAlign(password_label,"top") guiLabelSetHorizontalAlign(password_label,"left",false) username_edit = guiCreateEdit(78,170,244,23,"",false,login_window) password_Edit = guiCreateEdit(78,217,244,23,"",false,login_window) register_button = guiCreateButton(173,267,124,53,"Register",false,login_window) guiSetFont(register_button,"clear-normal") register_window = guiCreateWindow(216,145,374,251,"Registration",false) guiWindowSetMovable(register_window,false) guiWindowSetSizable(register_window,false) dusername_label = guiCreateLabel(12,45,105,18,"Desired Username:",false,register_window) guiLabelSetColor(dusername_label,255,255,255) guiLabelSetVerticalAlign(dusername_label,"top") guiLabelSetHorizontalAlign(dusername_label,"left",false) dusername_edit = guiCreateEdit(119,44,244,23,"",false,register_window) dpassword_label = guiCreateLabel(11,104,113,18,"Desired Password:",false,register_window) guiLabelSetColor(dpassword_label,255,255,255) guiLabelSetVerticalAlign(dpassword_label,"top") guiLabelSetHorizontalAlign(dpassword_label,"left",false) dpassword_edit = guiCreateEdit(121,101,243,23,"",false,register_window) regististration_button = guiCreateButton(41,172,131,60,"Register!",false,register_window) cancel_button = guiCreateButton(199,171,131,60,"Cancel!",false,register_window) guiSkinShop = guiCreateWindow(0.37*sx,0.80*sy,0.3*sx,0.15*sy,"Choose a skin!",false) done = guiCreateButton(0.25,0.60,0.50,0.30,"Done",true,guiSkinShop) left = guiCreateButton(0.07,0.60,0.15,0.30,"<-",true,guiSkinShop) right = guiCreateButton(0.78,0.60,0.15,0.30,"->",true,guiSkinShop) guiWindowSetSizable(guiSkinShop,false) guiSetVisible(guiSkinShop, false) skinLabel = guiCreateLabel(0.05,0.30,0.90,0.17,"Skins can be bought once ingame",true,guiSkinShop) guiSetAlpha(skinLabel,1) guiLabelSetColor(skinLabel,255,255,255) guiCreateStaticImage( 0.0001, 0.49, 0.99, 0.02, "red.png", true, guiSkinShop ) guiCreateStaticImage( 0.0001, 0.25, 0.99, 0.02, "red.png", true, guiSkinShop ) guiLabelSetHorizontalAlign(skinLabel,"center",false) guiSetFont(skinLabel,"default-bold-small") end ) addEventHandler("onClientGUIClick",getRootElement(), function login() if source == login_button then local getUsernameField = guiGetText(Username_edit) local getPasswordField = guiGetText(Password_edit) if getUsernameField and getPasswordField then triggerServerEvent("loginFromClient", getLocalPlayer(), getUsernameField, getPasswordField) end end if source == registration_button then local getUsernameField1 = guiGetText(dusername_edit) local getPasswordField1 = guiGetText(dpassword_edit) if getUsernameField1 and getPasswordField1 then triggerServerEvent("registerFromClient", getLocalPlayer(), getUsernameField1, getPasswordField1) triggerServerEvent("loginFromClient", getLocalPlayer(), getUsernameField1, getPasswordField1) end end end function (buttons) if source == login_button then if guiGetVisible(login_window) == true then guiSetVisible(login_Window, false) showCursor(false) end end elseif source == register_button then if guiGetVisible(login_window) == true then guiSetVisible(login_window) == false else guiGetVisible(register_window) == false guiSetVisible(register_window) == true showCursor(true) end end if source == cancel_button then if guiGetVisible(register_window) == true then guiSetVisible(register_window) == false else guiGetVisible(login_window) == false guiSetVisible(login_window) == true showCursor(true) end end end function goRight(player) local newSkin = getElementModel (localPlayer) + 1 while not setElementModel (localPlayer,newSkin) do newSkin = newSkin + 1 end end function goLeft(player) local newSkin = getElementModel (localPlayer) - 1 while not setElementModel (localPlayer,newSkin) do newSkin = newSkin - 1 end end function doneButton(thePlayer) guiSetVisible(guiSkinShop,false) showCursor(false) triggerServerEvent("setCameraRegister", localPlayer) if source == registration_button then if guiGetVisible(register_window) == true guiSetVisible(register_window) == false else guiGetVisible(guiSkinShop) == false guiSetVisible(guiSkinShop) == true end end end end addEvent("onClientLoginHide",true) addEventHandler("onClientLoginHide",getRootElement(), function() showCursor(false) guiSetVisible(register_window, false) guiSetVisible(login_window, false) guiSetVisible(guiSkinShop) guiSetInputEnabled(false) end ) addEventHandler ( "onClientGUIClick",right,goRight, false ) addEventHandler ( "onClientGUIClick",done,doneButton, false ) addEventHandler ( "onClientGUIClick",left,goLeft, false ) 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