Jump to content

Dimos7

Members
  • Posts

    1,546
  • Joined

  • Last visited

Everything posted by Dimos7

  1. We are here to help you with your code not make it
  2. https://wiki.multitheftauto.com/wiki/IsVehicleEmpty
  3. local connection = exports["mysql"]:getConnection() function loginHandler(username, password) if (client) and (client == source) then local account = getAccount(username) local hashedPass = getAccountData(account, "hashed_Password") dbQuery(function(queryHandler) local result, num_affected_row = dbPoll(queryHandler, 0) if account ~= nil and passwordVerify(password, hashedPass, function(isVaild) if not isVaild then exports["notification-system"]:sendClientMessage("ERROR :Password is invaild!", source, 255, 0, 0) end end) and num_affected_row > 1 then if (logIn(source, account, hashedPass) == true ) then triggerClientEvent(source, "hideLoginWindow", root) setElementData(source, "account:id", result.id) dbExec(connection, "UPDATE accounts SET lastlogin=? WHERE username=?", "NOW()", tostring(username)) exports["notification-system"]:sendClientMessage("INFO: You successfuly logged in!", source ,0, 255, 0) else exports["notification-system"]:sendClientMessage("ERROR: That account is already logged in!", source, 255, 0, 0) end else exports["notification-system"]:sendClientMessage("ERROR: Username or passwrod is invailed!", source, 255, 0, 0) end end, connection, "SELECT * FROM accounts WHERE username = ? AND password = ?", tostring(username), tostring(hashedPass)) end end function reigsterHandler(username, email, password) if (client) and (client == source) then local account = getAccount(username) dbQuery(function(queryHandler) local result, num_affected_row = dbPoll(queryHandler, 0) if account ~= nil and num_affected_row > 1 then exports["notification-system"]:sendClientMessage("ERROR: That username is already exist!", source, 255, 0, 0) else passwordHash(password, "bcrypt", {}, function(hashedPassword) local account = addAccount(username,hashedPassword) setAccountData(account, "hashed_Password", hashedPassword) local ip = getPlayerIP(source) local serial = getPlayerSerial(source) local r = getRealTime() local regDate = ("%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 (username, password ,email, ip, serial, registerdate) VALUES(?, ?, ?, ?, ?, ?)", tostring(username), tostring(hashedPassword), tostring(email), tostring(ip), tostring(serial), tostring(regDate)) triggerClientEvent(source, "hideRegisterWindow", root) exports["notification-system"]:sendClientMessage("INFO: You successfuly register!", source, 0, 255, 0) end) end end, ,connection, "SELECT username FROM accounts WHERE username =?",tostring(username)) end end addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, reigsterHandler) after change it a bit that appear unexpected symbol near , line 44
  4. Copy the code to script file you want and done
  5. outputChatBox fixVehicle https://wiki.multitheftauto.com/wiki/GetPlayerFromPartialName
  6. createWeapon dxCreateShader dxCreateTexture
  7. only with costum weapon yes shaders and image of the weapon you need and resource of bone attach as you need to make it fire when press fire etc amunation
  8. You will need shader file texture of gun when shoot when not etc
  9. createWeapon
  10. The problem is on login not register
  11. That not change something
  12. same local connection = exports["mysql"]:getConnection() function loginHandler(thePlayer, username, password) local account = getAccount(username) local hashedPassword = getAccountData(account, "hashedPassword") local query = dbQuery(connection, "SELECT * FROM accounts WHERE username =?and password =?", tostring(username), tostring(hashedPassword)) local result, num_affected_row = dbPoll(query, -1) if account ~= nil and passwordVerify(password, hashedPassword, function(isVaild) if not isVaild then exports["notification-system"]:sendClientMessage("ERROR :Password is invaild!", thePlayer, 255, 0, 0) end end) and num_affected_row > 1 then if (logIn(thePlayer, account, hashedPassword) == true ) then triggerClientEvent(thePlayer, "hideLoginWindow", root) setElementData(thePlayer, "account:id", result.id) dbExec(connection, "UPDATE accounts SET lastlogin=? WHERE username=?", "NOW()", tostring(username)) exports["notification-system"]:sendClientMessage("INFO: You successfuly logged in!", thePlayer ,0, 255, 0) else exports["notification-system"]:sendClientMessage("ERROR: That account is already logged in!", thePlayer, 255, 0, 0) end else exports["notification-system"]:sendClientMessage("ERROR: Username or passwrod is invailed!", thePlayer, 255, 0, 0) end end function reigsterHandler(thePlayer, username, email, password) local account = getAccount(username) local query = dbQuery(connection, "SELECT * FROM accounts WHERE username =?",tostring(username)) local result, num_affected_row = dbPoll(query, -1) if account ~= nil and num_affected_row > 1 then exports["notification-system"]:sendClientMessage("ERROR: That username is already exist!", thePlayer, 255, 0, 0) else passwordHash(password, "bcrypt", {}, function(hashedPassword) local account = addAccount(username,hashedPassword) setAccountData(account, "hashedPassword", hashedPassword) local ip = getPlayerIP(thePlayer) local serial = getPlayerSerial(thePlayer) local r = getRealTime() local regDate = ("%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 (username, password ,email, ip, serial, registerdate) VALUES(?, ?, ?, ?, ?, ?)", tostring(username), tostring(hashedPassword), tostring(email), tostring(ip), tostring(serial), tostring(regDate)) triggerClientEvent(thePlayer, "hideRegisterWindow", root) exports["notification-system"]:sendClientMessage("INFO: You successfuly register!", thePlayer, 0, 255, 0) end) end end addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, reigsterHandler)
  13. that is on register i change it but that has nothing to do with login
  14. local connection = exports["mysql"]:getConnection() function loginHandler(thePlayer, username, password) local account = getAccount(username) local hashedPassword = getAccountData(account, "hashedPassword") local query = dbQuery(connection, "SELECT * FROM accounts WHERE username and password =?", tostring(username), tostring(hashedPassword)) local result, num_affected_row = dbPoll(query, -1) if account ~= nil and passwordVerify(password, hashedPassword, function(isVaild) if not isVaild then exports["notification-system"]:sendClientMessage("ERROR :Password is invaild!", thePlayer, 255, 0, 0) end end) and num_affected_row > 1 then if (logIn(thePlayer, account, hashedPassword) == true ) then triggerClientEvent(thePlayer, "hideLoginWindow", root) setElementData(thePlayer, "account:id", result.id) dbExec(connection, "UPDATE accounts SET lastlogin=? WHERE username=?", "NOW()", tostring(username)) exports["notification-system"]:sendClientMessage("INFO: You successfuly logged in!", thePlayer ,0, 255, 0) else exports["notification-system"]:sendClientMessage("ERROR: That account is already logged in!", thePlayer, 255, 0, 0) end else exports["notification-system"]:sendClientMessage("ERROR: Username or passwrod is invailed!", thePlayer, 255, 0, 0) end end function reigsterHandler(thePlayer, username, email, password) local account = getAccount(username) local query = dbQuery(connection, "SELECT *FROM accounts WHERE username =?",tostring(username)) local result, num_affected_row = dbPoll(query, -1) if account ~= nil and num_affected_row > 1 then exports["notification-system"]:sendClientMessage("ERROR: That username is already exist!", thePlayer, 255, 0, 0) else passwordHash(password, "bcrypt", {}, function(hashedPassword) local account = addAccount(username,hashedPassword) setAccountData(account, "hashedPassword", hashedPassword) local ip = getPlayerIP(thePlayer) local serial = getPlayerSerial(thePlayer) local r = getRealTime() local regDate = ("%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 (username, password ,email, ip, serial, registerdate) VALUES(?, ?, ?, ?, ?, ?)", tostring(username), tostring(hashedPassword), tostring(email), tostring(ip), tostring(serial), tostring(regDate)) triggerClientEvent(thePlayer, "hideRegisterWindow", root) exports["notification-system"]:sendClientMessage("INFO: You successfuly register!", thePlayer, 0, 255, 0) end) end end addEvent("submitLogin", true) addEvent("submitRegister", true) addEventHandler("submitLogin", root, loginHandler) addEventHandler("submitRegister", root, reigsterHandler) local sw, sh = guiGetScreenSize() showChat(false) setPlayerHudComponentVisible("all", false) local GUIEditor = { window = {}, label = {}, edit = {}, memo = {}, checkbox = {}, button = {}, } function createLoginWindow() GUIEditor.window[1] = guiCreateWindow((sw-662)/2, (sh-285)/2, 662, 285, "Login", false) guiWindowSetSizable(GUIEditor.window[1], false) guiWindowSetMovable(GUIEditor.window[1], false) GUIEditor.label[1] = guiCreateLabel(20, 49, 84, 19, "Username:", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[1], "default-blod-small") GUIEditor.edit[1] = guiCreateEdit(94, 39, 156, 36, "", false, GUIEditor.window[1]) guiEditSetMaxLength(GUIEditor.edit[1], 20) GUIEditor.label[2] = guiCreateLabel(20, 95, 84, 19, "Password:", false, GUIEditor.window[1]) guiSetFont(GUIEditor.label[2], "default-blod-small") GUIEditor.edit[2] = guiCreateEdit(94, 85, 156, 36, "", false, GUIEditor.window[1]) guiEditSetMaxLength(GUIEditor.edit[2], 50) guiEditSetMasked(GUIEditor.edit[2], true) GUIEditor.button[1] = guiCreateButton(94, 185, 156, 36, "Login", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(94, 231, 156, 36, "Register", false, GUIEditor.window[1]) GUIEditor.checkbox[1] = guiCreateCheckBox(94, 136, 149, 15, "Rememeber information", false, false, GUIEditor.window[1]) GUIEditor.memo[1] = guiCreateMemo(296, 39, 351, 231, "Hey, you there!\n\nWelcome to the great experience of Countyside Roleplay.\n\nWe hope to enjoy your time here", false, GUIEditor.window[1]) guiMemoSetReadOnly(GUIEditor.memo[1], true) addEventHandler("onClientGUIClick", GUIEditor.button[1], onClientSubmitLogin, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], createRegisterWindow, false) addEventHandler("onClientGUIClick", GUIEditor.checkbox[1], onClientSumbitSaveInformaiton, false) end function createRegisterWindow() guiSetVisible(GUIEditor.window[1], false) GUIEditor.window[2] = guiCreateWindow((sw-311)/2, (sh-285)/2, 311, 285, "Registration", false) guiWindowSetMovable(GUIEditor.window[2], false) guiWindowSetSizable(GUIEditor.window[2], false) GUIEditor.label[3] = guiCreateLabel(20, 49, 84, 19, "Username:", false, GUIEditor.window[2]) guiSetFont(GUIEditor.label[3], "default-blod-small") GUIEditor.edit[3] = guiCreateEdit(94, 39, 156, 36, "", false, GUIEditor.window[2]) guiEditSetMaxLength(GUIEditor.edit[3], 20) GUIEditor.label[4] = guiCreateLabel(20, 95, 84, 19, "Email:", false, GUIEditor.window[2]) guiSetFont(GUIEditor.label[4], "default-blod-small") GUIEditor.edit[4] = guiCreateEdit(94, 85, 156, 36, "", false, GUIEditor.window[2]) guiEditSetMaxLength(GUIEditor.edit[4], 100) GUIEditor.label[5] = guiCreateLabel(20, 146, 84, 19, "Password:", false, GUIEditor.window[2]) guiSetFont(GUIEditor.label[5], "default-blod-small") GUIEditor.edit[5] = guiCreateEdit(94, 136, 156, 36, "", false, GUIEditor.window[2]) guiEditSetMaxLength(GUIEditor.edit[5], 50) guiEditSetMasked(GUIEditor.edit[5], true) GUIEditor.button[3] = guiCreateButton(94, 185, 156, 36, "Register", false, GUIEditor.window[2]) GUIEditor.button[4] = guiCreateButton(94, 231, 156, 36, "Back", false, GUIEditor.window[2]) addEventHandler("onClientGUIClick", GUIEditor.button[3], onClientSubmitRegister, false) addEventHandler("onClientGUIClick", GUIEditor.button[4], hideRegisterWindow, false) guiSetVisible(GUIEditor.window[2], true) end function reousceStart() createLoginWindow() if GUIEditor.window[1] ~= nil then guiSetVisible(GUIEditor.window[1], true) else exports["notification-system"]:sendClientMessage("ERROR: An ERROR has been occupied!", 255, 0, 0) end showCursor(true) guiSetInputEnabled(true) guiSetInputMode("no_binds") end local oldXmlFileName = "settings.xml" local migratedSettingsFile = "@migratedsettings.empty" local xmlFileName = "@settings.xml" function loadSavedData(parameter, default) if not fileExists(migratedSettingsFile) then if not fileExists(xmlFileName) and fileExists(oldXmlFileName) then fileRename(oldXmlFileName, xmlFileName) end fileClose(fileCreate(migratedSettingsFile)) end local xmlRoot = xmlLoadFile( xmlFileName ) if (xmlRoot) then local xmlNode = xmlFindChild(xmlRoot, parameter, 0) if (xmlNode) then return xmlNodeGetValue(xmlNode) end end return default or false end function appendSavedData(parameter, value) setElementData(getLocalPlayer(), parameter, value, false) local xmlFile = xmlLoadFile ( xmlFileName ) if not (xmlFile) then xmlFile = xmlCreateFile( xmlFileName, "login" ) end local xmlNode = xmlFindChild (xmlFile, parameter, 0) if not (xmlNode) then xmlNode = xmlCreateChild(xmlFile, parameter) end xmlNodeSetValue ( xmlNode, value ) xmlSaveFile(xmlFile) xmlUnloadFile(xmlFile) end function checkDetails() local username = guiGetText(GUIEditor.edit[1]) local password = guiGetText(GUIEditor.edit[2]) if guiCheckBoxGetSelected(GUIEditor.checkbox[1]) then appendSavedData("username", tostring(username)) appendSavedData("password", tostring(password)) else appendSavedData("username", "") appendSavedData("password", "") end end function onClientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(GUIEditor.edit[1]) local password = guiGetText(GUIEditor.edit[2]) if username ~= "" and password ~= "" then if username == "" then exports["notification-system"]:sendClientMessage("ERROR: You need enter username!" , 255, 0, 0) elseif password == "" then exports["notification-system"]:sendClientMessage("ERROR: You need enter a password!", 255, 0, 0) end triggerServerEvent("submitLogin", 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 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 if username == "" then exports["notification-system"]:sendClientMessage("ERROR: You need enter username!", 255, 0, 0) elseif email == "" then exports["notification-system"]:sendClientMessage("ERROR You need enter a email!", 255, 0, 0) elseif password == "" then exports["notification-system"]:sendClientMessage("ERROR: You need enter a password!", 255, 0, 0) end if string.len(username) < 3 then exports["notification-system"]:sendClientMessage("ERROR: Username is too short you need 3 characters long!" , 255, 0, 0) end if string.len(password) < 6 then exports["notification-system"]:sendClientMessage("ERROR: Password is too short you need 6 characters long!", 255, 0, 0) end if not string.find(email, "@") then exports["notification-system"]:sendClientMessage("ERROR: Invaild email!", 255, 0, 0) end triggerServerEvent("submitRegister", root , localPlayer, username, email, password) else exports["notification-system"]:sendClientMessage("ERROR You need enter username , email and password!", 255, 0, 0) end end end function onClientSumbitSaveInformaiton(button, state) if 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 hideLoginWindow() guiSetVisible(GUIEditor.window[1], false) showChat(true) setPlayerHudComponentVisible("all", true) guiSetInputEnabled(false) showCursor(false) end function hideRegisterWindow() createLoginWindow() guiSetVisible(GUIEditor.window[2], false) end addEvent("hideLoginWindow", true) addEvent("hideRegisterWindow", true) addEventHandler("hideLoginWindow", root, hideLoginWindow) addEventHandler("hideRegisterWindow", root, hideRegisterWindow) addEventHandler("onClientResourceStart", resourceRoot, reousceStart) i register a account for example with abc username 123456 passowrd and when try login say it incorrect why?
  15. i fix it that but not it in middle of screen as i wanted it idk why local sw, sh = guiGetScreenSize() local sx, sy = sw/1920, sh/1080 function sendClientMessage(message, r, g, b, colorCoded) if type(message) == "string" then if not colorCoded then r, g, b = tonumber (r) , tonumber(g) , tonumber(b) colorCoded = false else r, g, b = getColorFromString(message) colorCoded = true end notification = {message, r, g, b, colorCoded} setTimer(function() notification = nil end, 15000, 1) end end addEvent("sendClientMessage", true) addEventHandler("sendClientMessage", root, sendClientMessage) function renderNotifications() if notification then local notificationText = notification[1] local r, g, b = notification[2], notification[3], notification[4] local colorCoded = notification[5] dxDrawRectangle((sw/530)/2, sy*32, sx*530, sy*32, tocolor(0, 0, 0, 255)) dxDrawText(notificationText, (sw/530)/2, sy*44, sx*530, sy*44, tocolor(r, g, b, 255), sx*1.2, "default-blod", "center", "center", false, false, false, colorCoded, false) end end addEventHandler("onClientRender", root, renderNotifications)
  16. i do but you copy the code getPlayerFromPartialName because that function not exist without that code
  17. wired never had that error before are you sure you copy the code i send you?
  18. are you sure you type the correct name of the player and it not your name?
  19. function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function setWanted(thePlayer, cmd, target, amount) local targetPlayer = getPlayerFromPartialName(target) if targetPlayer ~= thePlayer then if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("admin")) then if amount < 0 or amount > 6 then outputChatBox("[Error]: wanted level must be from 0 to 6!", thePlayer, 255, 0, 0) else setPlayerWantedLevel(targetPlayer, amount) outputChatBox(targetPlayer.. "wanted level is now "..amount,thePlayer, 0, 255, 0) outputChatBox(getPlayerName(thePlayer).." has set your wanted level to "..amount, targetPlayer, 0, 255, 0) end else outputChatBox("#ff0000[Error]: #ffffffpermission denied", thePlayer, 255, 0, 0, true) end end end addCommandHandler("wanted", setWanted, false, false) if not work then you are not admin
  20. function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function setWanted(thePlayer, cmd, target, amount) local targetPlayer = getPlayerFromPartialName(target) if targetPlayer ~= thePlayer then if isPlayerOnGroup(thePlayer) then if amount < 0 or amount > 6 then outputChatBox("[Error]: wanted level must be from 0 to 6!", thePlayer, 255, 0, 0) else setPlayerWantedLevel(targetPlayer, amount) outputChatBox(targetPlayer.. "wanted level is now "..amount,thePlayer, 0, 255, 0) outputChatBox(getPlayerName(thePlayer).." has set your wanted level to "..amount, targetPlayer, 0, 255, 0) end else outputChatBox("#ff0000[Error]: #ffffffpermission denied", thePlayer, 255, 0, 0, true) end end end addCommandHandler("wanted", setWanted, false, false) try this
  21. local sw, sh = guiGetScreenSize() local sx, sy = sw/1920, sh/1080 local notificationBaseX, notificationBaseY = (sw/677)/2, 40 local notificationWidth, notificationHeight = 677, 40 local notificationMargin = 7 function sendClientMessage(message, r, g, b, colorCoded) if type(message) == "string" then if not colorCoded then r, g, b = tonumber (r) , tonumber(g) , tonumber(b) colorCoded = false else r, g, b = getColorFromString(message) colorCoded = true end setTimer(function() removeEventHandler("onClientRender", root, renderNotifications) end, 15000, 1) end end addEvent("sendClientMessage", true) addEventHandler("sendClientMessage", root, sendClientMessage) function renderNotifications() local notificationX, notificationY = notificationBaseX +notificationMargin , notificationBaseY+(notificationHeight +notificationMargin)*1 dxDrawRectangle(sx*notificationX, sy*notificationY, sx*notificationWidth, sy*notificationHeight, tocolor(0, 0, 0, 255)) dxDrawText(message, sx*notificationX, sy*notificationY, sx*notificationX+notificationWidth, sy*notificationY+notificationHeight, tocolor(r, g, b, 255), sx*1.2, "default-blod", "left", "top", false, false, false, colorCoded, false) end addEventHandler("onClientRender", root, renderNotifications) i did something like this but i can't take message because i take warning in drawText is nil i want to take the message from that function can you help me?
  22. i see i will try it thank for answer anyway
×
×
  • Create New...