Jump to content

BiSolpos

Members
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

BiSolpos's Achievements

Newbie

Newbie (4/54)

0

Reputation

  1. Hello everyone, I need help with something, I'm creating a bar for car fuel The bar is fine in my resolution, but in some resolutions it is like the image below https://imgur.com/a/ZGD8NDT local screenX, screenY = guiGetScreenSize() function ScaleY(value) return value / (900 / screenY) end function Speedo() local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle then local fuel = tonumber(getElementData(vehicle, "fuel")) dxDrawImageSection(screenX - ScaleY(289), screenY - ScaleY(19), ScaleY(47), ScaleY(-(123*(fuel/100))), 0, 0, ScaleY(47), ScaleY(-(123*(fuel/100))),"fuel.png", 0, 0, 0, tocolor(2,153,0,255), false) end end addEventHandler("onClientRender", getRootElement(), Speedo)
  2. Hello Which one is better? Are they different? addEventHandler("onClientGUIClick", window, function (button, state) if button ~= "left" then return end if source == btnClose then closeMenu() elseif source == btnChange then local AmountKey = guiGetText(EditKey) if AmountKey == "" then return outputChatBox("error", 255, 25, 25, true) end if string.len(AmountKey) ~= 16 then return outputChatBox("error", 255, 25, 25, true) end closeMenu() outputChatBox("successful", 255,126,0, true) end end) addEventHandler("onClientGUIClick", window, function (button, state) if button ~= "left" then return end if source == btnClose then closeMenu() elseif source == btnChange then local AmountKey = guiGetText(EditKey) if AmountKey == "" then outputChatBox("error", 255, 25, 25, true) else if string.len(AmountKey) ~= 16 then outputChatBox("error", 255, 25, 25, true) else closeMenu() outputChatBox("successful", 255,126,0, true) end end end end) Thank you
  3. hi I have a problem Alpha does not work and the page changes without fadein & fadeout code local screenW, screenH = guiGetScreenSize() local sizeX, sizeY = (540 * 1), (540 * 1) local posX, posY = (screenW / 2) - (sizeX / 2), (screenH / 2) - (sizeY / 2) local font = dxCreateFont ("Images/font.ttf", 15) local PageId = 1 local Alpha = 255 function isMouseWithinRangeOf (posX, posY, sizeX, sizeY) if isCursorShowing() == false then return false end local cx,cy = getCursorPosition() cx,cy = cx * screenW, cy * screenH if cx >= posX and cx <= posX + sizeX and cy >= posY and cy <= posY + sizeY then return true,cx,cy else return false end end function ShowLoginPanel() addEventHandler("onClientRender", getRootElement(), RenderLoginPanel) addEventHandler("onClientRender", getRootElement(), RenderButtons) showCursor (true) showChat (false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), ShowLoginPanel) EditBoxLogin = { {x = posX * 1.226, y = posY * 1.8, w = 300, h = 60, borderColor = tocolor(171, 171, 171, Alpha), textlog = "", name = "Username"}, {x = posX * 1.226, y = posY * 2.2, w = 300, h = 60, borderColor = tocolor(171, 171, 171, Alpha), textlog = "", hide = true, name = "Password"}, } EditBoxRegister = { {x = posX * 1.226, y = posY * 1.4, w = 300, h = 60, borderColor = tocolor(171, 171, 171, Alpha), textreg = "", name = "UsernameReg"}, {x = posX * 1.226, y = posY * 1.8, w = 300, h = 60, borderColor = tocolor(171, 171, 171, Alpha), textreg = "", hide = true, name = "PasswordReg"}, } ButtonLogin = { {x = posX * 1.188, y = posY * 3, w = 160, h = 50, borderColor = tocolor(255, 167, 0, Alpha), back = "Images/login.png", text = "Log In", func = "pressLogin"}, {x = posX * 1.528, y = posY * 3, w = 160, h = 50, borderColor = tocolor(255, 167, 0, Alpha), back = "Images/register.png", text = "Register", func = "pressRegisterBut"}, } ButtonRegister = { {x = posX * 1.188, y = posY * 3.2, w = 160, h = 50, borderColor = tocolor(255, 167, 0, Alpha), back = "Images/login.png", text = "Back", func = "pressBack"}, {x = posX * 1.528, y = posY * 3.2, w = 160, h = 50, borderColor = tocolor(255, 167, 0, Alpha), back = "Images/register.png", text = "Register", func = "pressRegister"}, } function RenderLoginPanel() if PageId == 1 then for i, eboxlog in ipairs(EditBoxLogin) do dxDrawImage (eboxlog.x, eboxlog.y, eboxlog.w, eboxlog.h,"Images/editbox.png",0,0,0, eboxlog.borderColor) if isMouseWithinRangeOf(eboxlog.x, eboxlog.y, eboxlog.w, eboxlog.h) then eboxlog.borderColor = tocolor(132, 0, 255) else eboxlog.borderColor = tocolor(171, 171, 171) end if eboxClickI == i then eboxlog.borderColor = tocolor(132, 0, 255) end if eboxlog.textlog then eboxlog.textlog = table.concat(textlog[i],"") if eboxlog.hide == true then dxDrawText (string.rep("•",#textlog[i],""), eboxlog.x + 25, eboxlog.y, eboxlog.w, eboxlog.h + eboxlog.y, tocolor(255,255,255), screenW/1600, font, "left", "center") else dxDrawText (table.concat(textlog[i],""), eboxlog.x + 25, eboxlog.y, eboxlog.w, eboxlog.h + eboxlog.y, tocolor(255,255,255), screenW/1600, font, "left", "center") end end end elseif PageId == 2 then for i, eboxreg in ipairs(EditBoxRegister) do dxDrawImage (eboxreg.x, eboxreg.y, eboxreg.w, eboxreg.h,"Images/editbox.png",0,0,0, eboxreg.borderColor) if isMouseWithinRangeOf(eboxreg.x, eboxreg.y, eboxreg.w, eboxreg.h) then eboxreg.borderColor = tocolor(132, 0, 255) else eboxreg.borderColor = tocolor(171, 171, 171) end if eboxClickI == i then eboxreg.borderColor = tocolor(132, 0, 255) end if eboxreg.textreg then eboxreg.textreg = table.concat(textreg[i],"") if eboxreg.hide == true then dxDrawText (string.rep("•",#textreg[i],""), eboxreg.x + 25, eboxreg.y, eboxreg.w, eboxreg.h + eboxreg.y, tocolor(255,255,255), screenW/1600, font, "left", "center") else dxDrawText (table.concat(textreg[i],""), eboxreg.x + 25, eboxreg.y, eboxreg.w, eboxreg.h + eboxreg.y, tocolor(255,255,255), screenW/1600, font, "left", "center") end end end end end function RenderButtons() if PageId == 1 then for i, btnlog in ipairs(ButtonLogin) do if btnlog.back then dxDrawImage (btnlog.x, btnlog.y, btnlog.w, btnlog.h, btnlog.back) end if btnlog.text then dxDrawText (btnlog.text, btnlog.x, btnlog.y, btnlog.w + btnlog.x, btnlog.h + btnlog.y, tocolor(255,255,255), screenW/1600, font, "center", "center") end end elseif PageId == 2 then for i, btnreg in ipairs(ButtonRegister) do if btnreg.back then dxDrawImage (btnreg.x, btnreg.y, btnreg.w, btnreg.h, btnreg.back) end if btnreg.text then dxDrawText (btnreg.text, btnreg.x, btnreg.y, btnreg.w + btnreg.x, btnreg.h + btnreg.y, tocolor(255,255,255), screenW/1600, font, "center", "center") end end end end function onClick (button, state) if (button == "left" and state == "down") then eboxClickI = false return false end if PageId == 1 then for i, eboxlog in pairs(EditBoxLogin) do if isMouseWithinRangeOf(eboxlog.x, eboxlog.y, eboxlog.w, eboxlog.h) then eboxClickI = i return true end end for i, btnlog in pairs(ButtonLogin) do if isMouseWithinRangeOf(btnlog.x, btnlog.y, btnlog.w, btnlog.h) then if btnlog.func then loadstring("return "..btnlog.func.."()")() end end end elseif PageId == 2 then for i, eboxreg in pairs(EditBoxRegister) do if isMouseWithinRangeOf(eboxreg.x, eboxreg.y, eboxreg.w, eboxreg.h) then eboxClickI = i return true end end for i, btnreg in pairs(ButtonRegister) do if isMouseWithinRangeOf(btnreg.x, btnreg.y, btnreg.w, btnreg.h) then if btnreg.func then loadstring("return "..btnreg.func.."()")() end end end end end addEventHandler("onClientClick", getRootElement(), onClick) function pressRegisterBut() Alpha = 0 addEventHandler("onClientRender", getRootElement(), movePanelOut) end function pressBack() Alpha = 0 addEventHandler("onClientRender", getRootElement(), movePanelIn) end function movePanelOut() Alpha = math.min(Alpha + 5, 255) PageId = 2 if tonumber(Alpha) == 255 then removeEventHandler("onClientRender", getRootElement(), movePanelOut) end end function movePanelIn() Alpha = math.min(Alpha + 5, 255) PageId = 1 if tonumber(Alpha) == 255 then removeEventHandler("onClientRender", getRootElement(), movePanelIn) end end Thank you
  4. BiSolpos

    Error

    Hello I created a login page and I want to filter some words, but even when the filtered words are not in the edit box, server say 'Username is incorrect'. AllowedChars = { {"a"},{"b"},{"c"},{"d"},{"e"},{"f"},{"g"},{"h"},{"i"},{"j"},{"k"},{"l"}, {"m"},{"n"},{"o"},{"p"},{"q"},{"r"},{"s"},{"t"},{"u"},{"v"},{"w"},{"x"}, {"y"},{"z"},{"1"},{"2"},{"3"},{"4"},{"5"},{"6"},{"7"},{"8"},{"9"},{"0"}, {"@"},{"("},{")"},{"-"},{"_"},{"."},{"|"}, } function getCharacter(character) for I, V in ipairs(AllowedChars) do if string.lower(V[1]) == string.lower(character) then for i, ebox in ipairs(editbox) do if eboxClickI == i then table.insert(text[i], character) end end return end end end addEventHandler("onClientCharacter", getRootElement(), getCharacter) function pressLogin() for i, ebox in ipairs(editbox) do if ebox.name == "Username" then UserValue = ebox.text elseif ebox.name == "Password" then PassValue = ebox.text end end if (string.find(UserValue,'@')) or (string.find(UserValue,'.')) or (string.find(UserValue,'|')) or (string.find(UserValue,'_')) then outputChatBox("Username is incorrect", source, 255, 255, 255) else triggerServerEvent ("Login", getLocalPlayer(), getLocalPlayer(), UserValue, PassValue) end end
  5. Hello My code gives this error, what is the problem? Bad argument @ 'getPedOccupiedVehicle' [Expected ped at argument 1, got string 'Quit'] Bad argument @ 'getElementID' [Expected element at argument 1, got boolean] Code Server function ExitCar (thePlayer, seat, jacked) local theVehicle = getPedOccupiedVehicle (thePlayer) local vehid = getElementID (theVehicle) if vehid == "1" or vehid == "2" or vehid == "3" or vehid == "4" or vehid == "5" or vehid == "6" then if getElementData(thePlayer, "onMark") then if seat == 0 then destroyElement(getElementData(thePlayer, "onMark")) end end end end addEventHandler("onVehicleStartExit", getRootElement(), ExitCar) addEventHandler("onPlayerQuit", getRootElement(), ExitCar) Thank you
  6. @Patrick I looked but it did not work code html function login() { var UsernameValue = document.getElementById("UsernameInput").value; var PasswordValue = document.getElementById("PasswordInput").value; var CheckValue = document.getElementById("loginSave").checked; mta.triggerEvent("Login", UsernameValue, PasswordValue, CheckValue); } code lua client function Login(UsernameValue, PasswordValue, CheckValue) username = tostring(UsernameValue) password = tostring(PasswordValue) UsernameValue = nil PasswordValue = nil CheckValue = nil triggerServerEvent("attemptLogin", getRootElement(), getLocalPlayer(), username, password, CheckValue ) end addEvent("Login", true) addEventHandler("Login", root, Login) code lua server function login(client, username, password, checksave) if CheckValue == true then triggerClientEvent(client, "saveLoginToXML", client, username, password) else triggerClientEvent(client, "resetSaveXML", client, username, password) end end addEvent("attLogin", true) addEventHandler("attLogin", getRootElement(), login) code savelogintoxml function saveLoginToXML(username, password) local xml_save_log_File = xmlLoadFile("userdata.xml") if not xml_save_log_File then xml_save_log_File = xmlCreateFile("userdata.xml", "login") end if (username ~= "") then local usernameNode = xmlFindChild(xml_save_log_File, "username", 0) if not usernameNode then usernameNode = xmlCreateChild(xml_save_log_File, "username") end xmlNodeSetValue(usernameNode, username) end if (password ~= "") then local passwordNode = xmlFindChild(xml_save_log_File, "password", 0) if not passwordNode then passwordNode = xmlCreateChild(xml_save_log_File, "password") end xmlNodeSetValue(passwordNode, password) end xmlSaveFile(xml_save_log_File) xmlUnloadFile(xml_save_log_File) end addEvent("saveLoginToXML", true) addEventHandler("saveLoginToXML", getRootElement(), saveLoginToXML) Thank you
  7. Hello I have created a login page How can I receive the value of the HTML checkbox in Lua to store the name and password? Thank you
×
×
  • Create New...