Jump to content

Dimos7

Members
  • Posts

    1,546
  • Joined

  • Last visited

Everything posted by Dimos7

  1. you mean you want a vehicle destoryed insde of all the players?
  2. addEventHandler("onPlayerWasted", root, function() if isElement(vehicles99ui)and isPedDead(source) then destroyElement(vehicles99ui) vehicles99ui = nil end end)
  3. Try remove 2 line and see if work if not /debugscipt 3 and post the errors or warnings
  4. Vehicles99ui is a table Asus you have made it try to remove where you defind it as table
  5. if you want to edit it you can use onPlayerChat and cancel the event and make a costum team chat
  6. Try topic put localPlayer instead of l_5_0
  7. You can use the even onElementDataChange for that i think
  8. any error or warning in the /debugscript 3? also you have use the code the wiki has you need have it for that working because its a useful function
  9. You need put the marker inside the interior for show setElementInterior(rMarker,5)
  10. what the error or warning in /debugscript 3?
  11. yes because the getLocalPlayer is client side only function poliwasted() local team = getTeamFromName("Milicja") if isPlayerInTeam(source, team) then setElementModel(source, 281) setPedArmor(source, 100) setPlayerNametagColor(source, 0, 8, 255) giveWeapon(source, 3, 1000) end end addEventHandler("onPlayerWasted", root, poliwasted)
  12. Did you use the code for that dxDrawImage3D because it a useful function
  13. Dimos7

    Police system

    Well you need a make a team or whatever you want apply some animations and mods
  14. Dimos7

    Command

    any error or warnings in debug?
  15. First heat do you mean random ? random object I'd and second the objects is table you need a loop for that
  16. I want to make a tow system what function did i need?
  17. You need the event onClientRender for that
  18. local GUIEditor = { window = {}, label = {}, edit = {}, button = {}, checkbox = {}, } function createLoginWndow() backgroundL = guiCreateStaticImage(0, 0 , 3840, 2400, "587449097-ultra-hd-gaming-wallpapers.jpg", false) local screenW,screenH = guiGetScreenSize() local windowW,windowH = 480, 453 local left, top = (screenW-windowW)/2, (screenH-windowH)/2 GUIEditor.window[1] = guiCreateWindow(left, top, windowW, windowH, "Login", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(38, 65, 63, 18, "Username:", false, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[1], "left") guiLabelSetVerticalAlign(GUIEditor.label[1], "top") GUIEditor.edit[1] = guiCreateEdit(169, 65, 234, 39, "", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(38, 117, 63, 18, "Password:", false, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[2], "left") guiLabelSetVerticalAlign(GUIEditor.label[2], "top") GUIEditor.edit[2] = guiCreateEdit(169, 117, 234, 39, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.checkbox[1] = guiCreateCheckBox(38, 175, 100,15, "Remember me", false, false, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(169, 175, 119, 16, "Forget Password", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(201, 253, 119, 47, "Login", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(201, 327, 119, 47, "Register", false, GUIEditor.window[1]) addEventHandler("onClientGUIClick", GUIEditor.button[1], createForgetPasswordWindow) addEventHandler("onClientGUIClick", GUIEditor.button[2], onClientSubmitLogin) addEventHandler("onClientGUIClick", GUIEditor.button[3], createRegisterWindow) addEventHandler("onClientGUIClick", GUIEditor.checkbox[1], saveInfo) end function createRegisterWindow() backgroundR = guiCreateStaticImage(0, 0 , 3840, 2400, "587449097-ultra-hd-gaming-wallpapers.jpg", false) local screenW, screenH = guiGetScreenSize() local windowW, windowH = 480, 453 local left, top = (screenW-windowW)/2 , (screenH-windowH)/2 GUIEditor.window[2] = guiCreateWindow(left, top, windowW, windowH, "Registration", false) guiWindowSetMovable(GUIEditor.window[2], false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.label[3] = guiCreateLabel(38, 65, 63, 18, "Username:", false, GUIEditor.window[2]) guiLabelSetHorizontalAlign(GUIEditor.label[3], "left") guiLabelSetVerticalAlign(GUIEditor.label[3], "top") GUIEditor.edit[3] = guiCreateEdit(169, 65, 234, 39, "", false, GUIEditor.window[2]) GUIEditor.label[4] = guiCreateLabel(38, 117, 63, 18, "Email:", false, GUIEditor.window[2]) guiLabelSetHorizontalAlign(GUIEditor.label[4], "left") guiLabelSetVerticalAlign(GUIEditor.label[4], "top") GUIEditor.edit[4] = guiCreateEdit(169, 117, 234, 39, "", false, GUIEditor.window[2]) GUIEditor.label[5] = guiCreateLabel(38, 175, 63, 18, "Password:", false, GUIEditor.window[2]) guiLabelSetHorizontalAlign(GUIEditor.label[5], "left") guiLabelSetVerticalAlign(GUIEditor.label[5], "top") GUIEditor.edit[5] = guiCreateEdit(169, 175, 234, 39, "", false, GUIEditor.window[2]) guiEditSetMasked(GUIEditor.edit[5], true) GUIEditor.button[4] = guiCreateButton(201, 253, 119, 47, "Register", false, GUIEditor.window[2]) GUIEditor.button[5] = guiCreateButton(201, 327, 119, 47, "Back", false, GUIEditor.window[2]) guiSetVisible(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[2], true) addEventHandler("onClientGUIClick", GUIEditor.button[4], onClientSubmitRegister) addEventHandler("onClientGUIClick", GUIEditor.button[5], hideRegisterWindow) end function createPasswordWindow() local screenW, screenH = guiGetScreenSize() local windowW, windowH = 480, 453 local left, top = (screenW-windowW)/2, (screenH-windowH)/2 GUIEditor.window[3] = guiCreateWindow(left, top, windowW, windowH, "Change Password:", false) guiWindowSetMovable(GUIEditor.window[3], false) guiWindowSetSizable(GUIEditor.window[3], false) GUIEditor.label[6] = guiCreateLabel(38, 65, 63, 18, "Password:", false, GUIEditor.window[3]) guiLabelSetHorizontalAlign(GUIEditor.label[6], "left") guiLabelSetVerticalAlign(GUIEditor.label[6], "top") GUIEditor.edit[6] = guiCreateEdit(169, 65, 234, 39, "", false, GUIEditor.window[3]) guiEditSetMasked(GUIEditor.edit[6], true) GUIEditor.label[7] = guiCreateLabel(38, 117, 63, 18, "Repeat", false, GUIEditor.window[3]) guiLabelSetHorizontalAlign(GUIEditor.label[7], "left") guiLabelSetVerticalAlign(GUIEditor.label[7], "top") GUIEditor.edit[7] = guiCreateEdit(169, 117, 234, 39, "", false, GUIEditor.window[3]) guiEditSetMasked(GUIEditor.edit[7], true) GUIEditor.button[6] = guiCreateButton(201, 253, 119, 47, "Change", false, GUIEditor.window[3]) GUIEditor.button[7] = guiCreateButton(201, 327, 119, 47, "Cancel", false, GUIEditor.window[3]) addEventHandler("onClientGUIClick", GUIEditor.button[6], onClientSubmitChangepw) addEventHandler("onClientGUIClick", GUIEditor.button[7], hidePasswordWindow) end function createForgetPasswordWindow() backgroundF = guiCreateStaticImage(0, 0 , 3840, 2400, "587449097-ultra-hd-gaming-wallpapers.jpg", false) local screenW, screenH = guiGetScreenSize() local windowW, windowH = 480, 453 local left, top = (screenW-windowW)/2, (screenH-windowH)/2 GUIEditor.window[4] = guiCreateWindow(left, top, windowW, windowH, "Forget Password:", false) guiWindowSetMovable(GUIEditor.window[3], false) guiWindowSetSizable(GUIEditor.window[3], false) GUIEditor.label[8] = guiCreateLabel(38, 65, 63, 18, "Email:", false, GUIEditor.window[4]) guiLabelSetHorizontalAlign(GUIEditor.label[8], "left") guiLabelSetVerticalAlign(GUIEditor.label[8], "top") GUIEditor.edit[8] = guiCreateEdit(169, 65, 234, 39, "", false, GUIEditor.window[4]) GUIEditor.label[9] = guiCreateLabel(38, 117, 63, 18, "Password:", false, GUIEditor.window[4]) guiLabelSetHorizontalAlign(GUIEditor.label[9], "left") guiLabelSetVerticalAlign(GUIEditor.label[9], "top") GUIEditor.edit[9] = guiCreateEdit(169, 117, 234, 39, "", false, GUIEditor.window[4]) guiEditSetMasked(GUIEditor.edit[9], true) GUIEditor.label[10] = guiCreateLabel(38, 175, 63, 18, "Repeat:", false, GUIEditor.window[4]) guiLabelSetHorizontalAlign(GUIEditor.label[10], "left") guiLabelSetVerticalAlign(GUIEditor.label[10], "top") GUIEditor.edit[10] = guiCreateEdit(169, 175, 234, 39, "", false, GUIEditor.window[4]) guiEditSetMasked(GUIEditor.edit[10], true) GUIEditor.button[8] = guiCreateButton(201, 253, 119, 47, "Change", false, GUIEditor.window[4]) GUIEditor.button[9] = guiCreateButton(201, 327, 119, 47, "Back", false, GUIEditor.window[4]) guiSetVisible(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[4], true) addEventHandler("onClientGUIClick", GUIEditor.button[8], onClientSubmitNewpw) addEventHandler("onClientGUIClick", GUIEditor.button[9], hideForgetPasswordWindow) end function resourceStart() createLoginWndow() if not GUIEditor.window[1] ~= nil then guiSetVisible(GUIEditor.window[1], true) else exports["notification-system"]:sendClientMessage("ERROR: A error has been occuopied!", 255, 0, 0) end guiSetInputEnabled(true) guiSetInputMode("no_binds_when_editing") showCursor(true) end function checkDetails() local username = guiGetText(GUIEditor.edit[1]) local password = guiGetText(GUIEditor.edit[2]) if username ~= "" and password ~= "" then if guiCheckBoxGetSelected(GUIEditor.checkbox[1]) then appendSavedData("username", tostring(username)) appendSavedData("password", tostring(password)) else appendSavedData("username", "") appendSavedData("password", "") end else exports["notification-system"]:sendClientMessage("ERROR: You need put username and password!", 255, 0, 0) end end function Chnagepw() createPasswordWindow() guiSetVisible(GUIEditor.window[3], true) guiSetInputEnabled(true) guiSetInputMode("no_binds_when_editing") showCursor(true) end local xmlFileName = "accounts.xml" function appendSavedData(parameter, value) local xmlFile = xmlLoadFile(xmlFileName) if not xmlFile then xmlFile = xmlCreateFile(xmlFileName, "login") end xmlNode = xmlFindChild(xmlFile, parameter, 0) if not xmlNode then xmlNode = xmlCreateChild(xmlFile, parameter) end xmlNodeSetValue(xmlNode, value) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) end function loadSavedData(parameter, value) local xmlRoot = xmlLoadFile(xmlFileName) if (xmlRoot) then local xmlNode = xmlFindChild(xmlRoot, parameter, 0) if (xmlNode) then return xmlNodeGetValue(xmlNode) end end end function saveInfo(button, state) if source == GUIEditor.checkbox[1] and button == "left" and state == "up" then if guiCheckBoxGetSelected(GUIEditor.checkbox[1]) then guiCheckBoxSetSelected(GUIEditor.checkbox[1], true) guiSetText(GUIEditor.edit[1], tostring(loadSavedData("username", ""))) guiSetText(GUIEditor.edit[2], tostring(loadSavedData("password", ""))) else guiCheckBoxSetSelected(GUIEditor.checkbox[1], false) guiSetText(GUIEditor.edit[1], "") guiSetText(GUIEditor.edit[2], "") end end end function onClientSubmitLogin(button, state) if source == GUIEditor.button[2] and button == "left" and state == "up" then local username = guiGetText(GUIEditor.edit[1]) local password = guiGetText(GUIEditor.edit[2]) if username ~= "" and password ~= "" then triggerServerEvent("onSubmitLogin", root, localPlayer, username, password) else exports["notification-system"]:sendClientMessage("ERROR: You need enter username and password!", 255, 0, 0) end end end function onClientSubmitRegister(button, state) if source == GUIEditor.button[4] and button == "left" and state == "up" then local username = guiGetText(GUIEditor.edit[3]) local email = guiGetText(GUIEditor.edit[4]) local password = guiGetText(GUIEditor.edit[5]) if username ~= "" and email ~= "" and password ~= "" then triggerServerEvent("onSubmitRegister", root, localPlayer, username, email, password) else exports["notification-system"]:sendClientMessage("ERROR: You need username, email and password for register!", 255, 0, 0) end end end function onClientSubmitChangepw(button, state) if source == GUIEditor.button[6] and button == "left" and state == "up" then local password = guiGetText(GUIEditor.edit[6]) local rpassword = guiGetText(GUIEditor.edit[7]) if password ~= "" and rpassword ~= "" then triggerServerEvent("onSubmitChangepw", root, localPlayer, password, rpassword) else exports["notification-system"]:sendClientMessage("ERROR: You need password and repeat password!", 255, 0 , 0) end end end function onClientSubmitNewpw(button, state) if source == GUIEditor.button[8] and button == "left" and state == "up" then local email = guiGetText(GUIEditor.edit[8]) local password = guiGetText(GUIEditor.edit[9]) local rpassword = guiGetText(GUIEditor.edit[10]) if email ~= "" and password ~= "" and rpassword ~= "" then triggerServerEvent("onSubmitNewpw", root, localPlayer, email, password, rpassword) else exports["notification-system"]:sendClientMessage("ERROR: You need email, password and repeat password!", 255, 0 , 0) end end end function hidePasswordWindow() guiSetVisible(GUIEditor.window[3], false) guiSetInputEnabled(false) showCursor(false) end function hideForgetPasswordWindow() guiSetVisible(GUIEditor.window[4], false) guiSetVisible(backgroundF, false) resourceStart() end function hideLoginWindow() guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) guiSetVisible(backgroundL, false) end function hideRegisterWindow() guiSetVisible(GUIEditor.window[2], false) guiSetVisible(backgroundR, false) resourceStart() end addEvent("hideLoginWindow", true) addEvent("hidePasswordWindow", true) addEvent("hideRegisterWindow", true) addEvent("hideForgetPasswordWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) addEventHandler("hidePasswordWindow", root, hidePasswordWindow) addEventHandler("hideForgetPasswordWindow", root, hideForgetPasswordWindow) addEventHandler("hideRegisterWindow", root, hideRegisterWindow) addEventHandler("onClientResourceStart", resourceRoot, resourceStart) addCommandHandler("changepw", Chnagepw) function resourceStart() connection = dbConnect("mysql", "dbname=mtatest; host=127.0.0.1", "root", "9852174563") end addEventHandler("onResourceStart", resourceRoot, resourceStart) function passwordHandler(thePlayer, password, rpassword) local account = getPlayerAccount(thePlayer) local accountName = getAccountName(account) local query = dbQuery(connection, "SELECT *FROM accounts WHERE username=?",tostring(accountName)) local result, num_affected_rows = dbPoll(query, -1) if not isGuestAccount(account) and num_affected_rows > 1 then if password == rpassword then if string.len(password) >= 6 then local spassword = tostring(password) local safepassword = md5(spassword) setAccountPassword(account, password) triggerClientEvent(thePlayer, "hidePasswordWindow", root) dbExec(connection, "UPDATE accounts SET password='"..safepassword.."WHERE username='"..tostring(accountName).."'") outputChatBox("You succefull change your password!", thePlayer, 0, 255, 0) else outputChatBox("Your new password must be at least 6 characters long!", thePlayer, 255, 0, 0) end else outputChatBox("The password and repeat password are not the same!", thePlayer, 255, 0, 0) end else outputChatBox("You aren't logged in!.", thePlayer, 255, 0, 0) end end function forgetpasswordHandler(thePlayer, email, password, rpassword) local account = getPlayerAccount(getPlayerName(thePlayer)) local query = dbQuery(connection, "SELECT * FROM accounts WHERE email =?", tostring(email)) local result, num_affected_rows = dbPoll(query, -1) if num_affected_rows > 1 then if password == rpassword then if string.len(password) >= 6 then local spassword = tostring(password) local safepassword = md5(spassword) setAccountPassword(account, password) dbExec(connection, "UPDATE accounts SET password ='"..safepassword.." WHERE email ='"..tostring(email).."'") triggerClientEvent(thePlayer, "hideForgetPasswordWindow", root) exports["notification-system"]:sendClientMessage("INFO: You succefull change your password!", thePlayer, 0, 255, 0) else exports["notification-system"]:sendClientMessage("ERROR: Your new password must be at least 6 characters long!", thePlayer, 255, 0, 0) end else exports["notification-system"]:sendClientMessage("ERROR: Password and repeat password are not the same!", thePlayer, 255, 0, 0) end else exports["notification-system"]:sendClientMessage("ERROR: That email dosen't exist!", thePlayer, 255, 0, 0) end end function loginHandler(thePlayer, username, password) local account = getAccount(username, password) local safeusername = tostring(username) local spassword = tostring(password) local safepassword = md5(spassword) local query = dbQuery(connection, "SELECT * FROM accounts WHERE username='"..safeusername.."' and password='"..safepassword.."'") local result, num_affected_rows = dbPoll(query, -1) if account ~= nil and num_affected_rows > 1 then if logIn(thePlayer, account, password) == true then triggerClientEvent(thePlayer, "hideLoginWindow", root) exports["notification-system"]:sendClientMessage("INFO: You succefull logged in!", thePlayer, 0, 255, 0) dbExec(connection, "UPDATE account SET lastlogin= NOW()") else exports["notification-system"]:sendClientMessage("ERROR: Username or password are ivaild!", thePlayer, 255, 0, 0) end else exports["notification-system"]:sendClientMessage("ERROR: That account is already logged in!", thePlayer, 255, 0, 0) end end function registerHandler(thePlayer, username, email, password) local account = getAccount(username, password) local safeusername = tostring(username) local query = dbQuery(connection, "SELECT * FROM accounts WHERE username='"..safeusername.."'") local result, num_affected_rows= dbPoll(query, -1) if account ~= nil and num_affected_rows > 1 then exports["notification-system"]:sendClientMessage("ERROR: That account already exists!", thePlayer, 255, 0, 0) else if string.len(username) > 3 then if string.len(password) >= 6 then account = addAccount(username, password) local safeusername2 = tostring(username) local spassword = tostring(password) local safepassword = md5(spassword) local r = getRealTime() local playerIP = getPlayerIP(thePlayer) local playerSerial =getPlayerSerial(thePlayer) local playerName = getPlayerName(thePlayer) local timeString = ("%04d-%02d-%02d %02d:%02d:%02d"):format(r.year+1900, r.month+1, r.monthday, r.hour, r.minute, r.second) dbExec(connection, "INSERT INTO accounts SET username='"..safeusername2.."', password='"..safepassword.."', registerdate='"..tostring(timeString).."',ip='"..tostring(playerIP).."', serial='"..tostring(playerSerial).."',email='"..tostring(email).."', charactername='"..tostring(playerName).."'") exports["notification-system"]:sendClientMessage("INFO: You succefull register!", thePlayer, 0, 255, 0) triggerClientEvent(thePlayer, "hideRegisterWindow", root) else exports["notification-system"]:sendClientMessage("ERROR: Password must be at least 6 characters long!" , thePlayer, 255, 0, 0) end else exports["notification-system"]:sendClientMessage("ERROR: Usernamer is too short it must be more than 3 characters long!", thePlayer, 255, 0, 0) end end end addEvent("onSubmitChangepw", true) addEvent("onSubmitNewpw", true) addEvent("onSubmitLogin", true) addEvent("onSubmitRegister", true) addEventHandler("onSubmitChangepw", root, passwordHandler) addEventHandler("onSubmitNewpw", root, forgetpasswordHandler) addEventHandler("onSubmitLogin", root, loginHandler) addEventHandler("onSubmitRegister", root, registerHandler) c_login 185 and 186 bad argument #1 tostring(value expected)
  19. i don't understandi know how to sql i want first fix the problem i have with my background image and window not load
  20. local GUIEditor = { window = {}, label = {}, edit = {}, button = {}, checkbox = {}, } function createLoginWndow() local screenW,screenH = guiGetScreenSize() local windowW,windowH = 480, 453 local left, top = (screenW-windowW)/2, (screenH-windowH)/2 GUIEditor.window[1] = guiCreateWindow(left, top, windowW, windowH, "Login", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(38, 65, 63, 18, "Username:", false, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[1], "left") guiLabelSetVerticalAlign(GUIEditor.label[1], "top") GUIEditor.edit[1] = guiCreateEdit(169, 65, 234, 39, "", false, GUIEditor.window[1]) GUIEditor.label[2] = guiCreateLabel(38, 117, 63, 18, "Password:", false, GUIEditor.window[1]) guiLabelSetHorizontalAlign(GUIEditor.label[2], "left") guiLabelSetVerticalAlign(GUIEditor.label[2], "top") GUIEditor.edit[2] = guiCreateEdit(169, 117, 234, 39, "", false, GUIEditor.window[1]) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.checkbox[1] = guiCreateCheckBox(38, 175, 100,15, "Remember me", false, false, GUIEditor.window[1]) GUIEditor.button[1] = guiCreateButton(169, 175, 119, 16, "Forget Password", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(201, 253, 119, 47, "Login", false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(201, 327, 119, 47, "Register", false, GUIEditor.window[1]) addEventHandler("onClientGUIClick", GUIEditor.button[1], createForgetPasswordWindow) addEventHandler("onClientGUIClick", GUIEditor.button[2], onClientSubmitLogin) addEventHandler("onClientGUIClick", GUIEditor.button[3], createRegisterWindow) addEventHandler("onClientGUIClick", GUIEditor.checkbox[1], saveInfo) end function createRegisterWindow() local screenW, screenH = guiGetScreenSize() local windowW, windowH = 480, 453 local left, top = (screenW-windowW)/2 , (screenH-windowH)/2 GUIEditor.window[2] = guiCreateWindow(left, top, windowW, windowH, "Registration", false) guiWindowSetMovable(GUIEditor.window[2], false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.label[3] = guiCreateLabel(38, 65, 63, 18, "Username:", false, GUIEditor.window[2]) guiLabelSetHorizontalAlign(GUIEditor.label[3], "left") guiLabelSetVerticalAlign(GUIEditor.label[3], "top") GUIEditor.edit[3] = guiCreateEdit(169, 65, 234, 39, "", false, GUIEditor.window[2]) GUIEditor.label[4] = guiCreateLabel(38, 117, 63, 18, "Email:", false, GUIEditor.window[2]) guiLabelSetHorizontalAlign(GUIEditor.label[4], "left") guiLabelSetVerticalAlign(GUIEditor.label[4], "top") GUIEditor.edit[4] = guiCreateEdit(169, 117, 234, 39, "", false, GUIEditor.window[2]) GUIEditor.label[5] = guiCreateLabel(38, 175, 63, 18, "Password:", false, GUIEditor.window[2]) guiLabelSetHorizontalAlign(GUIEditor.label[5], "left") guiLabelSetVerticalAlign(GUIEditor.label[5], "top") GUIEditor.edit[5] = guiCreateEdit(169, 175, 234, 39, "", false, GUIEditor.window[2]) guiEditSetMasked(GUIEditor.edit[5], true) GUIEditor.button[4] = guiCreateButton(201, 253, 119, 47, "Register", false, GUIEditor.window[2]) GUIEditor.button[5] = guiCreateButton(201, 327, 119, 47, "Back", false, GUIEditor.window[2]) guiSetVisible(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[2], true) addEventHandler("onClientGUIClick", GUIEditor.button[4], onClientSubmitRegister) addEventHandler("onClientGUIClick", GUIEditor.button[5], resourceStart) end function createPasswordWindow() local screenW, screenH = guiGetScreenSize() local windowW, windowH = 480, 453 local left, top = (screenW-windowW)/2, (screenH-windowH)/2 GUIEditor.window[3] = guiCreateWindow(left, top, windowW, windowH, "Change Password:", false) guiWindowSetMovable(GUIEditor.window[3], false) guiWindowSetSizable(GUIEditor.window[3], false) GUIEditor.label[6] = guiCreateLabel(38, 65, 63, 18, "Password:", false, GUIEditor.window[3]) guiLabelSetHorizontalAlign(GUIEditor.label[6], "left") guiLabelSetVerticalAlign(GUIEditor.label[6], "top") GUIEditor.edit[6] = guiCreateEdit(169, 65, 234, 39, "", false, GUIEditor.window[3]) guiEditSetMasked(GUIEditor.edit[6], true) GUIEditor.label[7] = guiCreateLabel(38, 117, 63, 18, "Repeat", false, GUIEditor.window[3]) guiLabelSetHorizontalAlign(GUIEditor.label[7], "left") guiLabelSetVerticalAlign(GUIEditor.label[7], "top") GUIEditor.edit[7] = guiCreateEdit(169, 117, 234, 39, "", false, GUIEditor.window[3]) guiEditSetMasked(GUIEditor.edit[7], true) GUIEditor.button[6] = guiCreateButton(201, 253, 119, 47, "Change", false, GUIEditor.window[3]) GUIEditor.button[7] = guiCreateButton(201, 327, 119, 47, "Cancel", false, GUIEditor.window[3]) addEventHandler("onClientGUIClick", GUIEditor.button[6], onClientSubmitChangepw) addEventHandler("onClientGUIClick", GUIEditor.button[7], hidePasswordWindow) end function createForgetPasswordWindow() local screenW, screenH = guiGetScreenSize() local windowW, windowH = 480, 453 local left, top = (screenW-windowW)/2, (screenH-windowH)/2 GUIEditor.window[4] = guiCreateWindow(left, top, windowW, windowH, "Forget Password:", false) guiWindowSetMovable(GUIEditor.window[3], false) guiWindowSetSizable(GUIEditor.window[3], false) GUIEditor.label[8] = guiCreateLabel(38, 65, 63, 18, "Email:", false, GUIEditor.window[4]) guiLabelSetHorizontalAlign(GUIEditor.label[8], "left") guiLabelSetVerticalAlign(GUIEditor.label[8], "top") GUIEditor.edit[8] = guiCreateEdit(169, 65, 234, 39, "", false, GUIEditor.window[4]) GUIEditor.label[9] = guiCreateLabel(38, 117, 63, 18, "Password:", false, GUIEditor.window[4]) guiLabelSetHorizontalAlign(GUIEditor.label[9], "left") guiLabelSetVerticalAlign(GUIEditor.label[9], "top") GUIEditor.edit[9] = guiCreateEdit(169, 117, 234, 39, "", false, GUIEditor.window[4]) guiEditSetMasked(GUIEditor.edit[9], true) GUIEditor.label[10] = guiCreateLabel(38, 175, 63, 18, "Repeat:", false, GUIEditor.window[4]) guiLabelSetHorizontalAlign(GUIEditor.label[10], "left") guiLabelSetVerticalAlign(GUIEditor.label[10], "top") GUIEditor.edit[10] = guiCreateEdit(169, 175, 234, 39, "", false, GUIEditor.window[4]) guiEditSetMasked(GUIEditor.edit[10], true) GUIEditor.button[8] = guiCreateButton(201, 253, 119, 47, "Change", false, GUIEditor.window[4]) GUIEditor.button[9] = guiCreateButton(201, 327, 119, 47, "Back", false, GUIEditor.window[4]) guiSetVisible(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[4], true) addEventHandler("onClientGUIClick", GUIEditor.button[8], onClientSubmitNewpw) addEventHandler("onClientGUIClick", GUIEditor.button[9], resourceStart) end function resourceStart() createLoginWndow() if GUIEditor.window[1] ~= nil then guiSetVisible(GUIEditor.window[1], true) else outputChatBox("A error has been occuopied!", 255, 0, 0) end guiSetInputEnabled(true) guiSetInputMode("no_binds_when_editing") guiSetVisible(GUIEditor.window[2], false) guiSetVisible(GUIEditor.window[4], false) showCursor(true) background = guiCreateStaticImage(0, 0 , 3840, 2400, "587449097-ultra-hd-gaming-wallpapers.jpg", false) end function checkDetails() local username = guiGetText(GUIEditor.edit[1]) local password = guiGetText(GUIEditor.edit[2]) if username ~= "" and password ~= "" then if guiCheckBoxGetSelected(GUIEditor.checkbox[1]) then appendSavedData("username", tostring(username)) appendSavedData("password", tostring(password)) else appendSavedData("username", "") appendSavedData("password", "") end else outputChatBox("You need put username and password!", 255, 0, 0) end end function Chnagepw() createPasswordWindow() addEventHandler("onClientRender", localPlayer, createPasswordWindow) guiSetVisible(GUIEditor.window[3], true) guiSetInputEnabled(true) guiSetInputMode("no_binds_when_editing") showCursor(true) showChat(true) setPlayerHudComponentVisible("all", true) guiSetVisible(background, false) end local xmlFileName = "accounts.xml" function appendSavedData(parameter, value) local xmlFile = xmlLoadFile(xmlFileName) if not xmlFile then xmlFile = xmlCreateFile(xmlFileName, "login") end xmlNode = xmlFindChild(xmlFile, parameter, 0) if not xmlNode then xmlNode = xmlCreateChild(xmlFile, parameter) end xmlNodeSetValue(xmlNode, value) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) end function loadSavedData(parameter, value) local xmlRoot = xmlLoadFile(xmlFileName) if (xmlRoot) then local xmlNode = xmlFindChild(xmlRoot, parameter, 0) if (xmlNode) then return xmlNodeGetValue(xmlNode) end end end function saveInfo(button, state) if source == GUIEditor.checkbox[1] and button == "left" and state == "up" then if guiCheckBoxGetSelected(GUIEditor.checkbox[1]) then guiCheckBoxSetSelected(GUIEditor.checkbox[1], true) guiSetText(GUIEditor.edit[1], tostring(loadSavedData("username", ""))) guiSetText(GUIEditor.edit[2], tostring(loadSavedData("password", ""))) else guiCheckBoxSetSelected(GUIEditor.checkbox[1], false) guiSetText(GUIEditor.edit[1], "") guiSetText(GUIEditor.edit[2], "") end end end function onClientSubmitLogin(button, state) if source == GUIEditor.button[1] and button == "left" and state == "up" then local username = guiGetText(GUIEditor.edit[1]) local password = guiGetText(GUIEditor.edit[2]) if username ~= "" and password ~= "" then triggerServerEvent("onSubmitLogin", root, localPlayer, username, password) else outputChatBox("You need enter username and password!", 255, 0, 0) end end end function onClientSubmitRegister(button, state) if source == GUIEditor.button[4] and button == "left" and state == "up" then local username = guiGetText(GUIEditor.edit[3]) local email = guiGetText(GUIEditor.edit[4]) local password = guiGetText(GUIEditor.edit[5]) if username ~= "" and email ~= "" and password ~= "" then triggerServerEvent("onSubmitRegister", root, localPlayer, username, email, password) else outputChatBox("You need username, email and password for register!", 255, 0, 0) end end end function onClientSubmitChangepw(button, state) if source == GUIEditor.button[6] and button == "left" and state == "up" then local password = guiGetText(GUIEditor.edit[6]) local rpassword = guiGetText(GUIEditor.edit[7]) if password ~= "" and rpassword ~= "" then triggerServerEvent("onSubmitChangepw", root, localPlayer, password, rpassword) else outputChatBox("You need password and repeat password!", 255, 0 , 0) end end end function onClientSubmitNewpw(button, state) if source == GUIEditor.button[8] and button == "left" and state == "up" then local email = guiGetText(GUIEditor.edit[8]) local password = guiGetText(GUIEditor.edit[9]) local rpassword = guiGetText(GUIEditor.edit[10]) if email ~= "" and password ~= "" and rpassword ~= "" then triggerServerEvent("onSubmitNewpw", root, localPlayer, email, password, rpassword) else outputChatBox("You need email, password and repeat password!", 255, 0 , 0) end end end function hidePasswordWindow() removeEventHandler("onClientRender", localPlayer, createPasswordWindow) guiSetVisible(GUIEditor.window[3], false) guiSetInputEnabled(false) showCursor(false) end function hideForgetPasswordWindow() guiSetVisible(GUIEditor.window[4], false) resourceStart() end function hideLoginWindow() guiSetVisible(GUIEditor.window[1], false) showCursor(false) guiSetInputEnabled(false) guiSetVisible(background, false) end function hideRegisterWindow() guiSetVisible(GUIEditor.window[2], false) resourceStart() end addEvent("hideLoginWindow", true) addEvent("hidePasswordWindow", true) addEvent("hideRegisterWindow", true) addEvent("hideForgetPasswordWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) addEventHandler("hidePasswordWindow", root, hidePasswordWindow) addEventHandler("hideForgetPasswordWindow", root, hideForgetPasswordWindow) addEventHandler("hideRegisterWindow", root, hideRegisterWindow) addEventHandler("onClientResourceStart", resourceRoot, resourceStart) addCommandHandler("changepw", Chnagepw) function resourceStart() connection = dbConnect("mysql", "dbname=mtatest; host=127.0.0.1", "root", "9852174563") end addEventHandler("onResourceStart", resourceRoot, resourceStart) function passwordHandler(thePlayer, password, rpassword) local account = getPlayerAccount(thePlayer) local accountName = getAccountName(account) local query = dbQuery(connection, "SELECT *FROM accounts WHERE username=?",tostring(accountName)) local result = dbPoll(query, -1) if not isGuestAccount(account) and #result > 1 then if password == rpassword then if string.len(password) >= 6 then local spassword = tostring(password) local safepassword = md5(spassword) setAccountPassword(account, password) triggerClientEvent(thePlayer, "hidePasswordWindow", root) dbExec(connection, "UPDATE accounts SET password='"..safepassword.."WHERE username='"..tostring(accountName).."'") outputChatBox("You succefull change your password!", thePlayer, 0, 255, 0) else outputChatBox("Your new password must be at least 6 characters long!", thePlayer, 255, 0, 0) end else outputChatBox("The password and repeat password are not the same!", thePlayer, 255, 0, 0) end else outputChatBox("You aren't logged in!.", thePlayer, 255, 0, 0) end end function forgetpasswordHandler(thePlayer, email, password, rpassword) local account = getPlayerAccount(getPlayerName(thePlayer)) local query = dbQuery(connection, "SELECT * FROM accounts WHERE eamil =?", tostring(email)) local result = dbPoll(query, -1) if #result > 1 then if password == rpassword then if string.len(password) >= 6 then local spassword = tostring(password) local safepassword = md5(spassword) setAccountPassword(account, password) dbExec(connection, "UPDATE accounts SET password ='"..safepassword.." WHERE email ='"..tostring(email).."'") triggerClientEvent(thePlayer, "hideForgetPasswordWindow", root) outputChatBox("You succefull change your password!", thePlayer, 0, 255, 0) else outputChatBox("Your new password must be at least 6 characters long!", thePlayer, 255, 0, 0) end else outputChatBox("Password and repeat password are not the same!", thePlayer, 255, 0, 0) end else outputChatBox("ERROR: That email dosen't exist!", thePlayer, 255, 0, 0) end end function loginHandler(thePlayer, username, password) local account = getAccount(username, password) local safeusername = tostring(username) local spassword = tostring(password) local safepassword = md5(spassword) local query =dbQuery(connection, "SELECT * FROM accounts WHERE username='"..safeusername.."',password ='"..safepassword.."'") local result = dbPoll(query, -1) if account ~= nil and #result > 1 then if (logIn(thePlayer, account, password) == true) then triggerClientEvent(thePlayer, "hideLoginWindow", root) outputChatBox("INFO: You succefull logged in!", thePlayer, 0, 255, 0) dbExec(connection, "UPDATE account SET lastlogin= NOW()") else outputChatBox("Username or password are ivaild!", thePlayer, 255, 0, 0) end else outputChatBox("That account is already logged in!", thePlayer, 255, 0, 0) end end function registerHandler(thePlayer, username, email, password) local account = getAccount(username) local safeusername = tostring(username) local query = dbQuery(connection, "SELECT * FROM accounts WHERE username='"..safeusername.."'") local result = dbPoll(query, -1) if account ~= nil and #result > 1 then outputChatBox("That account already exists!", thePlayer, 255, 0, 0) else if string.len(username) > 3 then if string.len(password) >= 6 then account = addAccount(username, password) local safeusername2 = tostring(username) local spassword = tostring(password) local safepassword = md5(spassword) local r = getRealTime() local playerIP = getPlayerIP(thePlayer) local playerSerial =getPlayerSerial(thePlayer) local playerName = getPlayerName(thePlayer) local timeString = ("%04d-%02d-%02d %02d:%02d:%02d"):format(r.year+1900, r.month+1, r.monthday, r.hour, r.minute, r.second) dbExec(connection, "INSERT INTO accounts SET username='"..safeusername2.."', password='"..safepassword.."', registerdate='"..tostring(timeString).."'ip='"..tostring(playerIP).."', serial='"..tostring(playerSerial).."', email='"..tostring(email).."', charactersname='"..tostring(playerName).."'") outputChatBox("You succefull register!", thePlayer, 0, 255, 0) triggerClientEvent(thePlayer, "hideRegisterWindow", root) else outputChatBox("Password must be at least 6 characters long!" , thePlayer, 255, 0, 0) end else outputChatBox("Usernamer is too short it must be more than 3 characters long!", thePlayer, 255, 0, 0) end end end addEvent("onSubmitChangepw", true) addEvent("onSubmitNewpw", true) addEvent("onSubmitLogin", true) addEvent("onSubmitRegister", true) addEventHandler("onSubmitChangepw", root, passwordHandler) addEventHandler("onSubmitNewpw", root, forgetpasswordHandler) addEventHandler("onSubmitLogin", root, loginHandler) addEventHandler("onSubmitRegister", root, registerHandler) My first problem is i want that image be on background but the thing is the window its not showed and the other when i try register i have a warning about the email wrong syxtax mysql
×
×
  • Create New...