Jump to content

Pedro001

Members
  • Posts

    53
  • Joined

  • Last visited

1 Follower

Recent Profile Visitors

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

Pedro001's Achievements

Snitch

Snitch (10/54)

1

Reputation

  1. I never asked for an entire resource in this forum, Everytime I posted something here was asking for help, never to ask someone to do something for me. The headline of the scripting section says "All Lua scripting topics related to Multi Theft Auto" Also, there is an "importante note" about posting something in the scripting section, which says. It must contain specific questions about either: the code you will include that is problematic or you are asking direct support for, or asking for help in finding the best approach to achieve something (which I did every single time) Just asked for help, not to someone do something for me, or to share a script. That is the only reason I always posted in this section, since the guide says, this section is indeed to ask for help. But I'm sorry @IIYAMA , it was not a question of unwillingness, I only did what I believed was right following the rules I read in this forum. And thank you @ShayF, for understanding what I did. I appreciate it.
  2. function loadOneVehicle(id) local queryHandle = dbQuery( connection, "SELECT * FROM vehicles WHERE id = " .. id ) local queryResult, rows = dbPoll ( queryHandle , -1 ) if rows > 0 then for k,row in pairs(queryResult) do loadedVehicle[id] = createVehicle(row.model, row.x, row.y, row.z, row.rx, row.ry, row.rz) if loadedVehicle[id] then local thex = tonumber(row.x) or 0 if thex < -4125 then setElementData(loadedVehicle[id], "parked", false) else setElementData(loadedVehicle[id], "parked", true) end setElementHealth(loadedVehicle[id], row.health) setVehicleColor ( loadedVehicle[id], row.r, row.g, row.b, row.r1, row.g1, row.b1 ) setVehicleHeadLightColor ( loadedVehicle[id], row.lightr, row.lightg, row.lightb ) setElementData(loadedVehicle[id], "dbid", row.id) setElementData(loadedVehicle[id], "veh.owner", row.owner) setElementData(loadedVehicle[id], "veh.modelid", row.model) setElementData(loadedVehicle[id], "veh.fuelData", row.fuel) setElementData(loadedVehicle[id], "veh.engine", 0) setElementData(loadedVehicle[id], "veh.lights", 0) setElementData(loadedVehicle[id], "veh.x", row.x) setElementData(loadedVehicle[id], "veh.y", row.y) setElementData(loadedVehicle[id], "veh.z", row.z) setElementData(loadedVehicle[id], "veh.rx", row.rx) setElementData(loadedVehicle[id], "veh.ry", row.ry) setElementData(loadedVehicle[id], "veh.rz", row.rz) setElementData(loadedVehicle[id], "veh.faction", row.faction) setElementData(loadedVehicle[id], "veh.airride", row.airride) setElementData(loadedVehicle[id], "tuning.neon", row.neon) setElementData(loadedVehicle[id], "customhorn", row.paintjob) local bulletProofTires = tostring(row.bulletProofTires) or false if bulletProofTires == "true" then setElementData(loadedVehicle[id], "tuning.bulletProofTires", true) else setElementData(loadedVehicle[id], "tuning.bulletProofTires", false) end vehicleModel = loadedVehicle[id] local steeringLock = row.steeringLock local driveType = tostring(row.driveType) or getVehicleHandling(vehicleModel)["steeringLock"] setVehicleHandling(loadedVehicle[id], "steeringLock", steeringLock, false) setVehicleHandling(loadedVehicle[id], "driveType", driveType, false) setElementData(loadedVehicle[id], "steeringLock", row.steeringLock) setElementData(loadedVehicle[id], "driveType", row.driveType) local lsdDoors = tostring(row.lsdDoor) or false local airRideOn = tostring(row.airRideOn) or false if airRideOn == "true" then setElementData(loadedVehicle[id], "tuning.airRide", true) else setElementData(loadedVehicle[id], "tuning.airRide", false) end if lsdDoors == "true" then setElementData(loadedVehicle[id], "tuning.lsdDoor", true) else setElementData(loadedVehicle[id], "tuning.lsdDoor", false) end function setVehicleHandlingFlags(vehicle, byte, value) if vehicle then local handlingFlags = string.format("%X", getVehicleHandling(vehicle)["handlingFlags"]) local reversedFlags = string.reverse(handlingFlags) .. string.rep("0", 8 - string.len(handlingFlags)) local currentByte, flags = 1, "" for values in string.gmatch(reversedFlags, ".") do if type(byte) == "table" then for _, v in ipairs(byte) do if currentByte == v then values = string.format("%X", tonumber(value)) end end else if currentByte == byte then values = string.format("%X", tonumber(value)) end end flags = flags .. values currentByte = currentByte + 1 end setVehicleHandling(vehicle, "handlingFlags", tonumber("0x" .. string.reverse(flags)), false) end end setVehicleHandlingFlags(loadedVehicle[id], 3, row.frontWheel) setVehicleHandlingFlags(loadedVehicle[id], 4, row.rearWheel) setElementData(loadedVehicle[id], "frontWheel", row.frontWheel) setElementData(loadedVehicle[id], "rearWheel", row.rearWheel) if row.handbrake == 1 then setElementFrozen(loadedVehicle[id], true) end setElementData(loadedVehicle[id], "handbrake", row.handbrake) setElementData(loadedVehicle[id], "veh.locked", row.locked) if row.locked == 1 then setVehicleLocked(loadedVehicle[id], true) end if row.numberPlate == 0 then plate = row.id elseif row.numberPlate > 0 then plate = row.numberPlate end setVehicleFuelTankExplodable(loadedVehicle[id], false) setVehiclePlateText(loadedVehicle[id], " BPH-".. plate) if (tonumber(row.health)<=400) then setElementData(loadedVehicle[id], "veh.engineCrash", 1) else setElementData(loadedVehicle[id], "veh.engineCrash", 0) end setElementInterior(loadedVehicle[id], row.interior) setElementData(loadedVehicle[id], "veh.int", row.interior) setElementDimension(loadedVehicle[id], row.dimension) setElementData(loadedVehicle[id], "veh.dim", row.dimension) setVehicleEngineState(loadedVehicle[id], false) setVehicleRespawnPosition(loadedVehicle[id], row.x, row.y, row.z, row.rx, row.ry, row.rz) local upgrades = fromJSON(row.upgrades) for slot, upgrade in ipairs(upgrades) do if upgrade and tonumber(upgrade) > 0 then setElementData(loadedVehicle[id], "veh.upgrade"..slot, upgrade) addVehicleUpgrade(loadedVehicle[id], upgrade) end end local panelState = fromJSON(row.upgrades) for panel, state in ipairs(panelState) do if state and tonumber(state) > 0 then setVehiclePanelState(loadedVehicle[id], panel, state) end end engine = row.engine turbo = row.turbo nitro = row.nitro tires = row.tires brakes = row.brakes weightreduction = row.weightreduction setElementData(loadedVehicle[id], "tuning.engine", row.engine) setElementData(loadedVehicle[id], "tuning.turbo", row.turbo) setElementData(loadedVehicle[id], "tuning.nitroLevel", row.nitro) setElementData(loadedVehicle[id], "tuning.tires", row.tires) setElementData(loadedVehicle[id], "tuning.brakes", row.brakes) setElementData(loadedVehicle[id], "tuning.weightreduction", row.weightreduction) dengineAcceleration = getVehicleHandling(vehicleModel)["engineAcceleration"] dmaxVelocity = getVehicleHandling(vehicleModel)["maxVelocity"] dengineInertia = getVehicleHandling(vehicleModel)["engineInertia"] dtractionMultiplier = getVehicleHandling(vehicleModel)["tractionMultiplier"] dtractionLoss = getVehicleHandling(vehicleModel)["tractionLoss"] dbrakeDeceleration = getVehicleHandling(vehicleModel)["brakeDeceleration"] dbrakeBias = getVehicleHandling(vehicleModel)["brakeBias"] dmass = getVehicleHandling(vehicleModel)["mass"] if engine == 1 then setVehicleHandling(loadedVehicle[id], "engineAcceleration", nil, false) setVehicleHandling(loadedVehicle[id], "maxVelocity", nil, false) elseif engine == 2 then setVehicleHandling(loadedVehicle[id], "engineAcceleration", dengineAcceleration + 2, false) setVehicleHandling(loadedVehicle[id], "maxVelocity", dmaxVelocity + 10, false) elseif engine == 3 then setVehicleHandling(loadedVehicle[id], "engineAcceleration", dengineAcceleration + 6, false) setVehicleHandling(loadedVehicle[id], "maxVelocity", dmaxVelocity + 20, false) elseif engine == 4 then setVehicleHandling(loadedVehicle[id], "engineAcceleration", dengineAcceleration + 8, false) setVehicleHandling(loadedVehicle[id], "maxVelocity", dmaxVelocity + 30, false) end if turbo == 1 then setVehicleHandling(loadedVehicle[id], "engineInertia", nil, false) elseif turbo == 2 then setVehicleHandling(loadedVehicle[id], "engineInertia", dengineInertia - 10, false) elseif turbo == 3 then setVehicleHandling(loadedVehicle[id], "engineInertia", dengineInertia - 20, false) elseif turbo == 4 then setVehicleHandling(loadedVehicle[id], "engineInertia", dengineInertia - 30, false) end if tires == 1 then setVehicleHandling(loadedVehicle[id], "tractionMultiplier", nil, false) setVehicleHandling(loadedVehicle[id], "tractionLoss", nil, false) elseif tires == 2 then setVehicleHandling(loadedVehicle[id], "tractionMultiplier", dtractionMultiplier + 0.05, false) setVehicleHandling(loadedVehicle[id], "tractionLoss", dtractionLoss + 0.02, false) elseif tires == 3 then setVehicleHandling(loadedVehicle[id], "tractionMultiplier", dtractionMultiplier + 0.1, false) setVehicleHandling(loadedVehicle[id], "tractionLoss", dtractionLoss + 0.03, false) elseif tires == 4 then setVehicleHandling(loadedVehicle[id], "tractionMultiplier", dtractionMultiplier + 0.15, false) setVehicleHandling(loadedVehicle[id], "tractionLoss", dtractionLoss + 0.04, false) end if brakes == 1 then setVehicleHandling(loadedVehicle[id], "brakeDeceleration", nil, false) setVehicleHandling(loadedVehicle[id], "brakeBias", nil, false) elseif brakes == 2 then setVehicleHandling(loadedVehicle[id], "brakeDeceleration", dbrakeDeceleration + 0.05, false) setVehicleHandling(loadedVehicle[id], "brakeBias", dbrakeBias + 0.1, false) elseif brakes == 3 then setVehicleHandling(loadedVehicle[id], "brakeDeceleration", dbrakeDeceleration + 0.1, false) setVehicleHandling(loadedVehicle[id], "brakeBias", dbrakeBias + 0.175, false) elseif brakes == 4 then setVehicleHandling(loadedVehicle[id], "brakeDeceleration", dbrakeDeceleration + 0.15, false) setVehicleHandling(loadedVehicle[id], "brakeBias", dbrakeBias + 0.25, false) end if weightreduction == 1 then setVehicleHandling(loadedVehicle[id], "mass", nil, false) elseif weightreduction == 2 then setVehicleHandling(loadedVehicle[id], "mass", dmass - 100, false) elseif weightreduction == 3 then setVehicleHandling(loadedVehicle[id], "mass", dmass - 200, false) elseif weightreduction == 4 then setVehicleHandling(loadedVehicle[id], "mass", dmass - 300, false) end exports.vz_handling:loadHandling(loadedVehicle[id]) end end end end function loadAllVehicle() setTimer(function() exports.vz_handling:loadHandlings() end, 5000, 1) dbQuery( function (queryHandler) local result, numAffectedRows, errorMsg = dbPoll(queryHandler, 0) if numAffectedRows > 0 then for k,row in pairs(result) do loadOneVehicle(row.id) end end end, connection, "SELECT * FROM vehicles" ) end addEventHandler("onResourceStart", resourceRoot, loadAllVehicle) Would someone please help me with this thing. Every time I start this script, all the cars spawn at the same time, I can't get to understand it. Please help me, I need it so bad!
  3. Yeah I found another way of doing it. Thank you anyway.
  4. Hi Guys. Could someone help me with this please! Basically, this login panel is linked to an sql database, but the problem is, when someone register in this panel, it is registered in the database but not to the mta. I don't know if I'm being clear. I see that the functions 'addAccount' and 'logIn' are missing. For example, even if the player logs in in this panel, he's shown as guest in the admin panel, thus I can't add a player in an acl for example. Help me Please! local connection = dbConnect("mysql",exports['ne_mysql']:getSQLData()) local key = "" addEvent("onCharacterLogin", false) addEvent("onClientCharacterRequest", true) addEventHandler("onClientCharacterRequest", getRootElement(), function(charname) playerSource = client local id = getElementData(client, "char.accountID") local qh = dbQuery(connection, "SELECT * FROM `players` WHERE `account` = ?", id) local row = dbPoll(qh, -1) if row then for k, row in ipairs (row) do local id = tonumber(row["id"]) local x = tonumber(row["x"]) local y = tonumber(row["y"]) local z = tonumber(row["z"]) local rot = tonumber(row["rot"]) local interior = tonumber(row["intID"]) local dimension = tonumber(row["dimID"]) local health = tonumber(row["health"]) local hunger = tonumber(row["hunger"]) local armor = tonumber(row["armor"]) local skin = tonumber(row["skin"]) local money = tonumber(row["money"]) local npoints = tonumber(row["npoints"]) local nsujo = tonumber(row["nsujo"]) local carlicense = tostring(row["drivinglicense"]) local bankmoney = tonumber(row["bankMoney"]) local playedMinutes = tonumber(row["playedMinutes"]) local lastLogin = tonumber(row["lastlogin"]) local gender = tonumber(row["gender"]) local age = tonumber(row["age"]) local weight = tonumber(row["weight"]) local height = tonumber(row["height"]) local adminnick = tostring(row["adminnick"]) local charname = tostring(row["charname"]) charname = string.gsub(tostring(charname), " ", "_") local walkingstyle = tonumber(row["walkingstyle"]) local jobID = tonumber(row["jobID"]) local jobName = tostring(row["jobName"]) local radiochannel = tonumber(row["radiochannel"]) local factionID = tonumber(row["factionID"]) local factionLeader = tonumber(row["factionLeader"]) local factionRank = tonumber(row["factionRank"]) local badgeNumber = tonumber(row["badgeNumber"]) local dutySkin = tonumber(row["dutySkin"]) local showHUD = tonumber(row["showHUD"]) local showOOC = tonumber(row["showOOC"]) local showRadar = tonumber(row["showRadar"]) local payTime = tonumber(row["payTime"]) local adminlevel = getElementData(playerSource, "char.adminlevel") local adminduty = getElementData(playerSource, "char.adminduty") setElementData(playerSource, "char.factionID", tonumber(factionID)) setElementData(playerSource, "char.factionLeader", tonumber(factionLeader)) setElementData(playerSource, "char.factionRank", tonumber(factionRank)) setElementData(playerSource, "char.badgeNumber", tonumber(badgeNumber)) setElementData(playerSource, "char.dutySkin", tonumber(dutySkin)) setElementData(playerSource, "age", tonumber(age)) setElementData(playerSource, "weight", tonumber(weight)) setElementData(playerSource, "height", tonumber(height)) setElementData(playerSource, "walkingstyle", tonumber(walkingstyle)) setElementData(playerSource, "char.jobID", tonumber(jobID)) setElementData(playerSource, "char.jobName", tostring(jobName)) if carlicense == "true" then setElementData(playerSource, "char.drivingLicense", true) else setElementData(playerSource, "char.drivingLicense", false) end setElementData(playerSource, "charname", tostring(charname)) setElementData(playerSource, "char.playedMinutes", tonumber(playedMinutes)) setElementData(playerSource, "char.lastLogin", tonumber(lastLogin)) setElementData(playerSource, "char.UID", tonumber(id)) setElementData(playerSource, "char.skin", tonumber(skin)) setElementData(playerSource, "char.adminlevel", tonumber(adminlevel)) setElementData(playerSource, "char.adminnick", adminnick) setElementData(playerSource, "char.bankMoney", tonumber(bankmoney)) setElementData(playerSource, "char.money",tonumber(money)) setElementData(playerSource, "char.diamante",tonumber(npoints)) setElementData(playerSource, "char.moneysujo",tonumber(nsujo)) setElementData(playerSource, "char.radio",tonumber(radiochannel)) setElementData(playerSource, "char.payTime",tonumber(payTime)) setElementData(playerSource, "gender", tonumber(gender)) setElementData(playerSource, "visibleName", tostring(charname)) setElementData(playerSource, "char.phoneNumber", tonumber(id)) setElementData(playerSource, "showHUD", tonumber(showHUD)) setElementData(playerSource, "showOOC", tonumber(showOOC)) setElementData(playerSource, "showRadar", tonumber(showRadar)) setPlayerName(playerSource, tostring(charname)) local name = string.gsub(tostring(charname), "_", " ") setPlayerNametagText(source, tostring(name)) setElementData(playerSource,"char.hunger",hunger) setElementData(playerSource, "dbid", getElementData(playerSource, "char.UID")) setElementData(playerSource, "char.health", tonumber(health)) setPedAnimation(playerSource, false) setElementHealth(playerSource, health) setPedArmor(playerSource, armor) setPedSkin(playerSource, skin) spawnPlayer(playerSource, x, y, z+2, rot, skin, interior, dimension) setPedWalkingStyle(client, walkingstyle) dbExec(connection,"UPDATE `players` SET `lastlogin`=NOW() WHERE `id`=?",id) toggleAllControls(playerSource, true, true, true) fadeCamera(playerSource, true) triggerEvent("onCharacterLogin", playerSource, charname) if getElementData(playerSource, "char.jailTime") > 0 then setElementDimension(playerSource, 60000 + getElementData(playerSource, "charID")) setElementInterior(playerSource, 6) setElementPosition(playerSource, 263.821807, 77.848365, 1001.0390625) setPedRotation(playerSource, 267.438446) setElementData(playerSource, "char.jailTime", getElementData(playerSource, "char.jailTime")) setElementData(playerSource, "char.jailReason", getElementData(playerSource, "char.jailReason")) setElementData(playerSource, "char.adminJail", true) outputChatBox("[Prisão]: Você está na cadeia, motivo: "..getElementData(playerSource, "char.jailReason")..".", playerSource, 124, 9, 9, true) outputChatBox("[Prisão]: Tempo: "..getElementData(playerSource, "char.jailTime")..".", playerSource, 124, 9, 9, true) exports.vz_bans:loginPlayerJailed() else setElementData(playerSource, "char.jailTime", 0) setElementData(playerSource, "char.jailReason", nil) setElementData(playerSource, "char.adminJail", false) end end else outputDebugString( "Conexão com o MySQL falhou!") end end ) addEvent("onPlayerLogin", false) addEvent("onClientLoginRequest", true) addEventHandler("onClientLoginRequest", getRootElement(), function(username, password) if (string.len(password)~=64) then password = string.reverse((key) .. (password)) end local lgnQuery = dbQuery(connection, "SELECT * FROM `users` WHERE `username`=? AND `password`=?", username, password ) playerSource = client local lgnResult = dbPoll ( lgnQuery, -1 ) if #lgnResult > 0 then for k, row in ipairs ( lgnResult ) do triggerEvent("onPlayerLogin", playerSource, username, password) local id = tonumber(row["id"]) local pass = tonumber(row["password"]) local found = false for key, v in ipairs(getElementsByType("player")) do local accid = tonumber(getElementData(v, "char.accountID")) if (accid) then if (accid==id) and (v~=playerSource) then found = true break end end end if not (found) then local admin = tonumber(row["admin"]) local adminduty = tonumber(row["adminduty"]) local adminjail = tonumber(row["adminjail"]) local adminJailTime = tonumber(row["adminjail_time"]) local adminJailBy = tostring(row["adminjail_by"]) local adminJailReason = row["adminjail_reason"] local banned = tonumber(row["banned"]) if tonumber(admin) == 0 then adminduty = 0 end setElementData(playerSource, "char.adminlevel", tonumber(admin)) local lasethp = tonumber(row["asethp"]) local lasetarmor = tonumber(row["asetarmor"]) local lasethunger = tonumber(row["asethunger"]) local lagoto = tonumber(row["agoto"]) local lagethere = tonumber(row["agethere"]) local lagivemoney = tonumber(row["agivemoney"]) local lasetmoney = tonumber(row["asetmoney"]) local lagiveitem = tonumber(row["agiveitem"]) local laadutyminute = tonumber(row["adutyminute"]) local lafuelveh = tonumber(row["afuelveh"]) local lafixveh = tonumber(row["afixveh"]) local lareply = tonumber(row["areply"]) local lapm = tonumber(row["apm"]) local lamakeveh = tonumber(row["amakeveh"]) local lajail = tonumber(row["ajail"]) local laban = tonumber(row["aban"]) if (banned==1) then kickPlayer(source,"Server Name","Sua conta está bloqueada") else setElementData(playerSource, "char.defaultUserName", username) setElementData(playerSource, "char.accountID", tonumber(id)) setElementData(playerSource, "char.adminduty", tonumber(adminduty)) setElementData(playerSource, "char.jailTime", adminJailTime) setElementData(playerSource, "char.jailReason", adminJailReason) setElementData(playerSource, "admin.sethp", lasethp) setElementData(playerSource, "admin.setarmor", lasetarmor) setElementData(playerSource, "admin.sethunger", lasethunger) setElementData(playerSource, "admin.goto", lagoto) setElementData(playerSource, "admin.gethere", lagethere) setElementData(playerSource, "admin.givemoney", lagivemoney) setElementData(playerSource, "admin.setmoney", lasetmoney) setElementData(playerSource, "admin.giveitem", lagiveitem) setElementData(playerSource, "admin.adutyminute", laadutyminute) setElementData(playerSource, "admin.fuelveh", lafuelveh) setElementData(playerSource, "admin.fixveh", lafixveh) setElementData(playerSource, "admin.reply", lareply) setElementData(playerSource, "admin.pm", lapm) setElementData(playerSource, "admin.makeveh", lamakeveh) setElementData(playerSource, "admin.jail", lajail) setElementData(playerSource, "admin.ban", laban) fadeCamera(playerSource, true) requestAccounts(playerSource, id) local ip = getPlayerIP(playerSource) local serial = getPlayerSerial(playerSource) dbExec(connection,"UPDATE `users` SET `ip`=?, serial=? WHERE `id`=?",ip,serial,id) end end end else exports.vz_info:showBoxS(playerSource, "Nome de usuário ou senha inválidos", "error") end end ) addEvent("onClientTryToCreateAccount", true) addEventHandler("onClientTryToCreateAccount", getRootElement(), function(username, password) local value = dbQuery(connection, "SELECT * FROM `users`") local result = dbPoll (value, -1 ) local serial = getPlayerSerial(source) password = string.reverse((key) .. (password)) if result then for _, row in ipairs ( result ) do if string.lower(row["username"]) == username then exports.vz_info:showBoxS(source, "Esse nome de usuário já existe", "error") return end if row["mtaserial"] == serial then exports.vz_info:showBoxS(source, "Você já tem uma conta", "error") return end end end exports.vz_info:showBoxS(source, "Registro bem sucedido!", "info") local data = dbExec(connection, "INSERT INTO users SET username = ?, password = ?, mtaserial = ?", username, password, serial) triggerClientEvent(source,"onRegisterFinish",source) end ) addEvent("OnClientTryToCreateCharacter", true) addEventHandler("OnClientTryToCreateCharacter", getRootElement(), function(charname, skins, age, sex) local value = dbQuery(connection, "SELECT `charname` FROM `players` WHERE `charname` = ?", tostring(charname)) local result = dbPoll (value, -1) local count = 0 local pw cname = nil if result then for _, row in ipairs ( result ) do cname = string.lower(row["charname"]) end if cname ~= nil then exports.vz_info:showBoxS(source, "O nome desse personagem já existe", "error") return end end dbFree(value) local accountID = getElementData(source, "char.accountID") data = dbExec( connection, "INSERT INTO `players` SET charname=?, account=?, intID=0, dimID=0, x=1481.06226, y=-1770.94824, z=18.79576, skin=0, age=?, gender=?", charname, accountID, age, sex) setPlayerName(source, charname) triggerClientEvent(source,"onSuccessLogin",source) requestAccounts(source, accountID) triggerClientEvent(source, "createCharacterLogin", source) end ) function requestAccounts(playerSource, id) local requestAcc = {} local query = dbQuery(connection, "SELECT id, charname,money, age, gender, skin, DATEDIFF(NOW(), lastlogin) FROM players WHERE account=?", id) local result = dbPoll(query, -1) if (#result>0) then for k, data in ipairs (result) do local i = 1 requestAcc[i] = {} requestAcc[i][0] = tonumber(data["id"]) requestAcc[i][1] = tostring(data["charname"]) requestAcc[i][2] = tonumber(data["skin"]) requestAcc[i][3] = tonumber(data["money"]) i = i + 1 end end triggerClientEvent(playerSource, "createCharacterLogin", playerSource, requestAcc, true, true) end addEvent("requestAccounts", true) addEventHandler("requestAccounts", getRootElement(), requestAccounts) function saveChar() if getElementData(source, "CharLoggedIn") then local x, y, z = getElementPosition(source) local rot = getPedRotation(source) local health = getElementHealth(source) local hunger = getElementData(source, "char.hunger") or 0 local age = getElementData(source, "age") local gender = getElementData(source, "gender") local armor = getPedArmor(source) local interior = getElementInterior(source) local dimension = getElementDimension(source) local charname = getElementData(source, "charname") local skin = getElementData(source, "char.skin") local playedMinutes = getElementData(source, "char.playedMinutes") local money = getElementData(source, "char.money") local npoints = getElementData(source,"char.diamante") local nsujo = getElementData(source,"char.moneysujo") local factionID = getElementData(source,"char.factionID") local factionLeader = getElementData(source,"char.factionLeader") local factionRank = getElementData(source,"char.factionRank") local badgeNumber = getElementData(source,"char.badgeNumber") local dutySkin = getElementData(source,"char.dutySkin") local bankMoney = getElementData(source, "char.bankMoney") local adminlevel = getElementData(source, "char.adminlevel") local jobID = getElementData(source, "char.jobID") local jobName = getElementData(source, "char.jobName") local radio = getElementData(source, "char.radio") local showHUD = getElementData(source, "showHUD") local showOOC = getElementData(source, "showOOC") local showRadar = getElementData(source, "showRadar") local drivingLicense = tostring(getElementData(source, "char.drivingLicense")) local jailTime = getElementData(source, "char.jailTime") local jailReason = getElementData(source, "char.jailReason") or "null" local adminJail = getElementData(source, "char.adminJail") local payTime = getElementData(source, "char.payTime") local asethp = getElementData(source, "admin.sethp") local asetarmor = getElementData(source, "admin.setarmor") local asethunger = getElementData(source, "admin.sethunger") local agoto = getElementData(source, "admin.goto") local agethere = getElementData(source, "admin.gethere") local agivemoney = getElementData(source, "admin.givemoney") local agiveitem = getElementData(source, "admin.giveitem") local asetmoney = getElementData(source, "admin.setmoney") local aadutyminute = getElementData(source, "admin.adutyminute") local afuelveh = getElementData(source, "admin.fuelveh") local afixveh = getElementData(source, "admin.fixveh") local areply = getElementData(source, "admin.reply") local apm = getElementData(source, "admin.pm") local amakeveh = getElementData(source, "admin.makeveh") local ajail = getElementData(source, "admin.jail") local aban = getElementData(source, "admin.ban") local update = dbExec(connection,"UPDATE players SET x=?, y=?, z=?, rot=?, health=?,hunger=?, armor=?, dimID=?, intID=?, money=?, npoints=?, nsujo=?, factionID=?, factionLeader=?, factionRank=?, badgeNumber=?, dutySkin=?, lastlogin=NOW(), playedMinutes=?, skin=?, charname=?, jobID=?, jobName=?, bankMoney=?, drivinglicense=?, radiochannel=?, showHUD=?, showOOC=?, showRadar=?, payTime=?, age=?, gender=? WHERE id=?",x,y,z,rot,health,hunger,armor,dimension,interior,money,npoints,nsujo,factionID,factionLeader,factionRank,badgeNumber,dutySkin,playedMinutes,skin,charname,jobID,jobName,bankMoney,drivingLicense,radio,showHUD,showOOC,showRadar,payTime,age,gender,getElementData(source, "char.UID")) local update2 = dbExec(connection,"UPDATE users SET lastlogin=NOW(), `admin`=?, adminjail_time=?, adminjail_reason=?, adminjail=? WHERE id = " .. getElementData(source,"char.accountID"),adminlevel, jailTime, jailReason, adminJail) local update3 = dbExec(connection,"UPDATE users SET asethp=?, asetarmor=?, asethunger=?, agoto=?, agethere=?, agivemoney=?, asetmoney=?, agiveitem=?, adutyminute=?, afuelveh=?, afixveh=?, areply=?, apm=?, amakeveh=? WHERE id = " .. getElementData(source,"char.accountID"), asethp, asetarmor, asethunger, agoto, agethere, agivemoney, asetmoney, agiveitem, aadutyminute, afuelveh, afixveh, areply, apm, amakeveh, ajail, aban) end end addEvent("saveChar", true) addEventHandler("saveChar",getRootElement(),saveChar) addEventHandler("onPlayerQuit", getRootElement(), saveChar) addCommandHandler("ban", function(playerSource,commandName,targetPlayer,ttime,...) if getElementData(playerSource, "char.adminlevel") >= 5 then -- Administrador acima do nivel *5 pode banir local ttime = tonumber ( ttime ) if targetPlayer and ttime then local targetPlayer, targetPlayerName = exports.vz_main:findPlayerByPartialNick(source, targetPlayer) if (getElementData(targetPlayer, "char.adminlevel") or 0) < getElementData(playerSource, "char.adminlevel") then local pSerialC = getPlayerSerial(targetPlayer) local duration = (ttime*60)*60 local reason = table.concat({...}, " ") local adminName = getElementData(playerSource,"char.adminnick") if ttime == 0 then dbExec(connection ,"INSERT INTO bans SET accountid=?, bannedBy=?, timeZone=?, playerSerial=?, reason = ?, playername=?",getElementData(targetPlayer, "char.accountID"), adminName ,23414590357, pSerialC, reason, targetPlayerName) else dbExec(connection ,"INSERT INTO bans SET accountid=?, bannedBy=?, timeZone=?, playerSerial=?, reason = ?, playername=?",getElementData(targetPlayer, "char.accountID"), adminName ,getRealTime()["timestamp"]+duration, pSerialC, reason, targetPlayerName) end if ttime == 0 then text = "Eterno" else text = ttime .. " hora" end dbExec(connection, "UPDATE users SET banned=1, banned_by=?, banned_reason=? WHERE id=?", adminName, reason, getElementData(targetPlayer, "char.accountID")) kickPlayer(targetPlayer, adminName, reason ) setElementData(playerSource, "admin.ban", getElementData(playerSource, "admin.ban") + 1) outputChatBox("#4169E1[Ban]: #ffffff" ..adminName .. " baniu o jogador " .. targetPlayerName .. "", root, 255, 255, 255, true) outputChatBox("#4169E1[Ban]: #ffffffHora do banimento: " .. text .. " - Motivo: #4169E1" .. reason .. "", root, 255, 255, 255, true) else outputChatBox("#ff0000[Error]: #ffffffVocê não pode banir um administrador superior a você", playerSource, 255, 255, 255, true) outputChatBox("#4169E1[Ban]: #ffffff"..getElementData(playerSource,"char.adminnick").." tentou banir um administrador do servidor", targetPlayer, 255, 255, 255, true) end else outputChatBox("#4169E1[Use]:#ffffff /" .. commandName .. " [ID] [hora (0 - eterno)] [motivo]", playerSource, 208, 101, 29, true) end end end ) addCommandHandler("offban", -- Administrador acima do nivel *5 pode banir jogadores offline function (thePlayer, commandName, targetPlayer, tttime, ...) if getElementData(thePlayer, "char.adminlevel") >= 5 then local tttime = tonumber(tttime) if not (targetPlayer) or not (tttime) or not (...) then outputChatBox("#4169E1[Use]: #ffffff/" .. commandName .. " [Nome Completo] [hora (0 - eterno)] [Motivo]", thePlayer , 255, 255, 255, true) else local targetPlayer = targetPlayer:gsub(" ", "_") local targetPlayerName = targetPlayer:gsub("_", " ") local adminName = getElementData(thePlayer,"char.adminnick") local reason = table.concat({...}, " ") local duration = (tttime*60)*60 if targetPlayer then if (getElementData(targetPlayer, "char.adminlevel") or 0) < getElementData(thePlayer, "char.adminlevel") then local qh = dbQuery(connection, "SELECT * FROM players WHERE charname='" .. targetPlayer .. "'") local result, num = dbPoll (qh, -1) if num == 0 then outputChatBox("#ff0000[Falha]: #ffffffEsse banimento não existe", thePlayer, 255, 255, 255, true) return end if result then for _, row in ipairs ( result ) do id = tonumber(row["id"]) accountid = tonumber(row["account"]) end if (accountid) then local qh2 = dbQuery(connection, "SELECT * FROM users WHERE id='" .. accountid .. "'") local result2 = dbPoll ( qh2, -1 ) if result2 then for _2, row2 in ipairs ( result2 ) do admin = tonumber(row2["admin"]) serial = row2["mtaserial"] ip = row2["ip"] end if (admin) > (getElementData(thePlayer, "char.adminlevel")) then outputChatBox("#ff0000[Falha]: #ffffffVocê não tem permissão", thePlayer, 255, 255, 255, true) return end if tttime == 0 then text = "Eterno" else text = tttime .. " Hora" end if tttime == 0 then dbExec(connection ,"INSERT INTO bans SET accountid=?, bannedBy=?, timeZone=?, playerSerial=?, reason = ?, playername=?", accountid, adminName ,23414590357, serial, reason, targetPlayer) else dbExec(connection ,"INSERT INTO bans SET accountid=?, bannedBy=?, timeZone=?, playerSerial=?, reason = ?, playername=?", accountid, adminName ,getRealTime()["timestamp"]+duration, serial, reason, targetPlayer) end setElementData(thePlayer, "admin.ban", getElementData(thePlayer, "admin.ban") + 1) dbExec(connection, "UPDATE users SET banned=1, banned_by=?, banned_reason=? WHERE id=?", adminName, reason, accountid) outputChatBox("#4169E1[BAN Offline]: #ffffff" ..adminName .. " baniu " .. targetPlayerName .. "", root, 255, 255, 255, true) outputChatBox("#4169E1[BAN Offline]: #ffffff" .. text .. " - Motivo: #4169E1" .. reason .. "", root, 255, 255, 255, true) end end else outputChatBox("#ff0000[Error]: #ffffffNenhum resultado encontrado", thePlayer, 255, 255, 255, true) end else outputChatBox("#ff0000[Error]: #ffffffVocê não pode banir um administrador superior a você", thePlayer, 124, 9, 9, true) outputChatBox("[BAN]:#ffffff "..adminName.." tentou banir um administrador do servidor", targetPlayer, 124, 9, 9, true) -- Quando um administrador tentar banir outro administrador, então aparece para todos administradores essa mensaguem end end end end end) addCommandHandler( "desbanir", function (playerSource, cmd, target, ...) if getElementData(playerSource, "char.adminlevel") >= 5 then local reason = table.concat ( { ... }, " " ) local acc local bannedNames = {} local bannedSerials = {} local bannedAccs = {} local bannedBy = {} if target and reason then local query = dbQuery ( connection, "SELECT * FROM `bans`" ) local result = dbPoll ( query, -1 ) if result then for k, rows in ipairs ( result ) do if string.find( rows["playername"]:lower(), target:lower() ) then table.insert ( bannedNames, rows["playername"] ) table.insert ( bannedSerials, rows["playerSerial"] ) table.insert ( bannedAccs, rows["accountid"] ) table.insert ( bannedBy, rows["bannedBy"] ) end end else outputChatBox("#ff0000[Error]: #ffffffNão foi possível encontrar uma punição no nome dado", playerSource, 255, 255, 255, true) end if #bannedNames > 1 then outputChatBox("#4169E1[SERVER NAME]: #ffffffTodas punições existentes do servidor", playerSource, 255, 255, 255, true) for k, bans in ipairs ( bannedNames ) do outputChatBox(bans, playerSource, 208, 101, 29, true) end bannedName = nil bannedSerial = nil bannedAccs = nil bannedBy = nil return end if #bannedNames == 0 then outputChatBox("#ff0000[Error]: #ffffffNenhuma punição encontrada", playerSource, 124, 9, 9, true) return end local exec = dbExec ( connection, "DELETE FROM bans WHERE playername = ?", bannedNames[1]) local exec = dbExec ( connection, "UPDATE `users` SET banned = 0 WHERE `id` = ?", bannedAccs[1]) outputChatBox("#4169E1[SERVER NAME]: #ffffffVocê desbaniu o jogador com sucesso", playerSource, 255, 255, 255, true) bannedName = nil bannedSerial = nil bannedAccs = nil bannedBy = nil else outputChatBox ("#4169E1[Use]: #ffffff/" .. cmd .. " [Nome Completo] [Motivo]", playerSource, 255, 255, 255, true) end end end )
  5. I did it, but they still won't die.
  6. Will setElementHealth(seg1, 100) work? or how can I put it so the ped can die?
  7. This is how they are being created. seg1 = createPed(164, -2660.91235, 1399.24121, 906.46094, 0 ) setElementInterior(seg1,3) setTimer(setElementHealth,1000,0,seg1,100) setTimer(setElementFrozen,1000,1,seg1,true) setElementData ( seg1, "ModoPassivo", true )
  8. Does anyone have any Idea on why bots won't die? Mods like bank robbery, and project hacking, the bots just won't die. Thank you.
  9. I tried doing so but, no matter what I do the vehicle keeps spawning at the same place.
  10. How can I change the position of the spawn in this function ? I suppose it is where it says " vehicle = createVehicle(Model, x-5, y+5, z, 0, 0, rz) " But I see it gets the position stored in a local variable that gets the position of an element. But I don't understand which element is this. Can someone help me? function(Model, cost, r1, g1, b1, r2, g2, b2) abc = false local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(source))), -1) for i, data in ipairs (data) do if data["Model"] == Model then abc = true break end end if #data >= 3 then exports.Scripts_Dxmessages:outputDx ( source, "Desculpe, mas você só pode comprar 3 veículos.","error" ) return end if abc then exports.Scripts_Dxmessages:outputDx ( source, "você já tem este veículo", "error" ) return end if getPlayerMoney(source) >= tonumber(cost) then takePlayerMoney ( source, cost ) local x, y, z = getElementPosition(source) local _, _, rz = getElementRotation(source) local shopID = getElementData ( source, "atVehShop") local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 if shopID and shopsVehSpawns[shopID] then vehicle = createVehicle(Model, shopsVehSpawns[shopID][1], shopsVehSpawns[shopID][2], shopsVehSpawns[shopID][3], shopsVehSpawns[shopID][4], shopsVehSpawns[shopID][5], shopsVehSpawns[shopID][6]) else vehicle = createVehicle(Model, x-5, y+5, z, 0, 0, rz) end setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) setElementData(vehicle, "Owner", source) local NewID = getFreeID() setElementData(vehicle, "ID", NewID) dbExec(db, "INSERT INTO VehicleList VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", NewID, getAccountName(getPlayerAccount(source)), Model, x-5, y+5, z, rz, color, "", 3, cost, 1000, 0) exports.Scripts_Dxmessages:outputDx ( source, "Comprou este carro por: R$"..cost, "success" ) updateVehicleInfo(source) setElementData(vehicle, "ownercar", getAccountName(getPlayerAccount(source))) warpPedIntoVehicle ( source, vehicle ) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 150, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) else exports.Scripts_Dxmessages:outputDx ( source, "Você não tem grana para comprar este veiculo.", "error" ) end end)
  11. I'm not a programmer y'know, I found the resource on a free website. I see that there's a file that should be the databese I suppose, but seems like it's not working.
  12. Hi Guys, I have a question... I have this resource I want to use in my server. It is a car dealership, but what happens is, every car that a player buys disappear when the server or the resource is restarted. I was hoping that someone could help me with this. or at least give me a clue on how to prevent this to happen again. Thanks
  13. como está nomeado o executavel do gta sa? deve ser gta_sa.exe
  14. MAAAAAAAAAN! I WORKED!!! Thank you sooo much! I was almost giving it up! Thank you very much for that!! I really appreciate it!
×
×
  • Create New...