Jump to content

Pedro001

Members
  • Posts

    53
  • Joined

  • Last visited

Everything posted by Pedro001

  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!
  15. I did it, I don't get eny errors, but nothing is shown on the scoreboard though.
  16. Thank you for responding. but where do I put this? I guess I found it, But I still get the number on the scoreboard. Is it really possible to get the name shown instead of the number? I don't wanna bother you guys.
  17. '<name>' expected near '#' on line 13 attempt to index global 'clanRankNames' (a nil value) on line 161
  18. Hii. I tried this one, but now it shows nothing, it stays blank.
  19. No I've got another one, do you need it? MAX_PRIRORITY_SLOT = 500 scoreboardColumns = { { ["name"] = "ID", ["width"] = 20, ["friendlyName"] = "ID", ["priority"] = 1 }, { ["name"] = "name", ["width"] = 200, ["friendlyName"] = "Name", ["priority"] = 2 }, { ["name"] = "fps", ["width"] = 50, ["friendlyName"] = "FPS", ["priority"] = 3 }, --{ ["name"] = "country", ["width"] = 100, ["friendlyName"] = "Country", ["priority"] = MAX_PRIRORITY_SLOT-1 }, { ["name"] = "ping", ["width"] = 30, ["friendlyName"] = "Ping", ["priority"] = MAX_PRIRORITY_SLOT } } resourceColumns = {} function toboolean( bool ) bool = tostring( bool ) if bool == "true" then return true elseif bool == "false" then return false else return nil end end forceShowTeams = toboolean( get( "forceShowTeams" ) ) or false forceHideTeams = toboolean( get( "forceHideTeams" ) ) or false allowColorcodedNames = toboolean( get( "allowColorcodedNames" ) ) or false scrollStep = tonumber( get( "scrollStep" ) ) or 1 local function iif( cond, arg1, arg2 ) if cond then return arg1 end return arg2 end function scoreboardAddColumn( name, forElement, width, friendlyName, priority ) if type( name ) == "string" then width = tonumber( width ) or 70 friendlyName = friendlyName or name priority = tonumber( priority ) or getNextFreePrioritySlot( scoreboardGetColumnPriority( "name" ) ) fixPrioritySlot( priority ) forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then for key, value in ipairs( scoreboardColumns ) do if name == value.name then return false end end table.insert( scoreboardColumns, { ["name"] = name, ["width"] = width, ["friendlyName"] = friendlyName, ["priority"] = priority } ) table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end ) if sourceResource then if not resourceColumns[sourceResource] then resourceColumns[sourceResource] = {} end table.insert ( resourceColumns[sourceResource], name ) end return triggerClientEvent( getRootElement(), "doScoreboardAddColumn", getRootElement(), name, width, friendlyName, priority, sourceResource ) end else return triggerClientEvent( forElement, "doScoreboardAddColumn", getRootElement(), name, width, friendlyName, priority, sourceResource ) end end return false end function scoreboardRemoveColumn( name, forElement ) if type( name ) == "string" then forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then for key, value in ipairs( scoreboardColumns ) do if name == value.name then table.remove( scoreboardColumns, key ) for resource, content in pairs( resourceColumns ) do table.removevalue( content, name ) end return triggerClientEvent( getRootElement(), "doScoreboardRemoveColumn", getRootElement(), name ) end end else return triggerClientEvent( forElement, "doScoreboardRemoveColumn", getRootElement(), name ) end end return false end function scoreboardClearColumns( forElement ) forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then while ( scoreboardColumns[1] ) do table.remove( scoreboardColumns, 1 ) resourceColumns = {} end return triggerClientEvent( getRootElement(), "doScoreboardClearColumns", getRootElement() ) else return triggerClientEvent( forElement, "doScoreboardClearColumns", getRootElement() ) end end function scoreboardResetColumns( forElement ) forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then while ( scoreboardColumns[1] ) do table.remove( scoreboardColumns, 1 ) resourceColumns = {} end local result = triggerClientEvent( getRootElement(), "doScoreboardResetColumns", getRootElement() ) if result then scoreboardAddColumn( "name", 200, "Name" ) scoreboardAddColumn( "ping", 40, "Ping" ) end return result else return triggerClientEvent( forElement, "doScoreboardResetColumns", getRootElement(), false ) end end function scoreboardSetForced( forced, forElement ) if type( forced ) == "boolean" then forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) return triggerClientEvent( forElement, "doScoreboardSetForced", getRootElement(), forced ) else return false end end function scoreboardSetSortBy( name, desc, forElement ) if type( name ) == "string" or name == nil then if name == nil then forElement = iif( type( desc ) == "userdata" and isElement( desc ), desc, getRootElement() ) else forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) end desc = iif( type( desc ) == "boolean", desc, true ) return triggerClientEvent( forElement, "doScoreboardSetSortBy", getRootElement(), name, desc ) else return false end end function scoreboardGetColumnPriority( name ) if type( name ) == "string" then for key, value in ipairs( scoreboardColumns ) do if name == value.name then return value.priority end end end return false end function scoreboardSetColumnPriority( name, priority, forElement ) if type( name ) == "string" and type( priority ) == "number" then if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then local columnIndex = false for key, value in ipairs( scoreboardColumns ) do if name == value.name then columnIndex = key end end if columnIndex then scoreboardColumns[columnIndex].priority = -1 -- To empty out the current priority fixPrioritySlot( priority ) scoreboardColumns[columnIndex].priority = priority table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end ) return triggerClientEvent( forElement, "doScoreboardSetColumnPriority", getRootElement(), name, priority ) end else return triggerClientEvent( forElement, "doScoreboardSetColumnPriority", getRootElement(), name, priority ) end end end return false end function scoreboardForceTeamsVisible( enabled ) if type( enabled ) == "boolean" then forceShowTeams = enabled return true end return false end function scoreboardForceTeamsHidden( enabled ) if type( enabled ) == "boolean" then forceHideTeams = enabled return true end return false end function scoreboardGetColumnCount() return #scoreboardColumns end function onClientDXScoreboardResourceStart() for key, column in ipairs( scoreboardColumns ) do triggerClientEvent( client, "doScoreboardAddColumn", getRootElement(), column.name, column.width, column.friendlyName, column.priority ) end end addEvent( "onClientDXScoreboardResourceStart", true ) addEventHandler( "onClientDXScoreboardResourceStart", getResourceRootElement( getThisResource() ), onClientDXScoreboardResourceStart ) function requestServerInfoHandler() local mapmanager = getResourceFromName( "mapmanager" ) local output = {} output.forceshowteams = forceShowTeams output.forcehideteams = forceHideTeams output.allowcolorcodes = allowColorcodedNames output.scrollStep = scrollStep output.server = getServerName() output.players = getMaxPlayers() output.gamemode = false output.map = false if mapmanager and getResourceState( mapmanager ) == "running" then local gamemode = exports.mapmanager:getRunningGamemode() if gamemode then output.gamemode = getResourceInfo( gamemode, "name" ) or getResourceName( gamemode ) end local map = exports.mapmanager:getRunningGamemodeMap() if map then output.map = getResourceInfo( map, "name" ) or getResourceName( map ) end end triggerClientEvent( source, "sendServerInfo", getRootElement(), output ) end addEvent( "requestServerInfo", true ) addEventHandler( "requestServerInfo", getRootElement(), requestServerInfoHandler ) function removeResourceScoreboardColumns( resource ) if resourceColumns[resource] then while resourceColumns[resource][1] do local success = scoreboardRemoveColumn( resourceColumns[resource][1], getRootElement() ) if not success then break end end resourceColumns[resource] = nil end end addEventHandler( "onResourceStop", getRootElement(), removeResourceScoreboardColumns ) -- Compability addScoreboardColumn = function( name, forElement, position, size ) if type( size ) == "number" and size >= 0 and size <= 1.0 then size = size*700 end return scoreboardAddColumn( name, forElement, size, name, position ) end removeScoreboardColumn = scoreboardRemoveColumn resetScoreboardColumns = scoreboardResetColumns setPlayerScoreboardForced = function( forElement, forced ) return scoreboardSetForced( forced, forElement ) end --[[function onPlayerJoinToServer() if source then findIDForPlayer(source) local country = call(getResourceFromName("admin"),"getPlayerCountry",source) if country then setElementData(source,"country",country) else setElementData(source,"country","?") end end end addEventHandler("onPlayerJoin",getRootElement(),onPlayerJoinToServer)]]-- function findIDForPlayer(thePlayer) if thePlayer and not getElementData(thePlayer,"ID") then local i = 0 local players = getElementsByType("player") repeat local foundID = false i = i + 1 for _,player in pairs(players) do if player ~= thePlayer then local playerID = tonumber(getElementData(player,"ID")) if playerID == i then foundID = true break end end end until not foundID setElementData(thePlayer,"ID",i) end end --[[function onServerIDStart() for i,thePlayer in pairs(getElementsByType("player")) do findIDForPlayer(thePlayer) local country = call(getResourceFromName("admin"),"getPlayerCountry",source) if country then setElementData(source,"country",country) else setElementData(source,"country","?") end end end addEventHandler("onResourceStart",resourceRoot,onServerIDStart) ]]---
  20. dxscoreboard_exports.lua ? I don't get it.
  21. It's a script for creating gangs, I wanted to show the rank of the player in the gang on the scorebord. the rank names are in the Ranknames file, which is this one clanRankNames = { [1] = "Aprendiz", [2] = "Membro", [3] = "Treinador", [4] = "Sub-Comandante", [5] = "Comandante", [6] = "Líder" } But instead of getting shown "Comandante" on the scoreboard, I get the number 5 shown. I wanted the rank name shown.
  22. Server local clanDB = nil local clanTable = {} zp = 300000 function initDatabase() clanDB = dbConnect( "sqlite", "clans.db" ) dbExec(clanDB, "CREATE TABLE IF NOT EXISTS Clans (Name PRIMARY KEY, Color, Members, X, Y, Z, Cash)") end initDatabase() function fillClanTable() local result = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans"),-1) if result and type(result) == "table" then clanTable = {} for k,v in pairs(result) do v["Color"] = fromJSON(v["Color"]) v["Members"] = fromJSON(v["Members"]) for key,val in pairs(v["Members"]) do if val[2] == 6 then v["Leader"] = val[1] end end table.insert(clanTable,v) createTeam( v["Name"], unpack(v["Color"]) ) end end end fillClanTable() function createClan(name,r,g,b) local result = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans WHERE Name = ?", name),-1) local resultt = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans WHERE Members = ?", getAccountName(getPlayerAccount(source))),-1) if resultt and #resultt <= 0 then if result and #result <= 0 then if name and #name <= 15 then local accName = getAccountName(getPlayerAccount(source)) if r and g and b then if tonumber(getPlayerMoney(source, localPlayer)) >= 20000000 then setPlayerMoney(source, tonumber(getPlayerMoney(source, localPlayer)) - 20000000) local color = {tonumber(r),tonumber(g),tonumber(b)} dbExec(clanDB, "INSERT INTO Clans VALUES(?,?,?,?,?,?,?)",name,toJSON(color),toJSON({{accName,6}}),0,0,0,0) local team = createTeam(name,unpack(color)) setPlayerTeam(source,team) local oldName = getPlayerName(source) fillClanTable() setElementData(source,"faction", name) outputChatBox("#FF0000[GANG]: #FFFFFFVoce criou a facção #FF0000"..name.." #FFFFFFcom sucesso",source,255, 0, 0, true) else outputChatBox("#FF0000[GANG]: #FFFFFFParece que voce nao tem dinheiro o suficiente", source, 255, 0, 0, true) outputChatBox("#FF0000[GANG]: #FFFFFFPara poder criar uma você precisa de #00800030,000,000$", source, 255, 0, 0, true) return end end else outputChatBox("#ff0000[GANG] #ffffffO nome é muito longo!",source) end else outputChatBox("#ff0000[GANG]: #ffffffO facção já existe !",source) end end end addEvent( "createNewClan", true ) addEventHandler("createNewClan", root, createClan) function getFreeID() local result = dbPoll(dbQuery(clanDB, "SELECT ID FROM Clans ORDER BY ID ASC"), -1) newID = false for i, id in pairs (result) do if id["ID"] ~= i then newID = i break end end if newID then return newID else return #result + 1 end end function was () local faction, rank = getPlayerFaction(source) local data = getFactionData(faction) if faction and rank then if data["X"] ~= 0 or 0 and data["Y"] ~= 0 or 0 and data["Z"] ~= 0 or 20 then spawnPlayer(source,data["X"],data["Y"],data["Z"]+0.2) setTimer (spawnPlayer, 1000, 1, source, data["X"],data["Y"],data["Z"]+0.2, 0, getPedSkin (source), 0, 0, getPlayerTeam(source)) end end end addEventHandler("onPlayerWasted", getRootElement(), was) function initClanCreationWindow(ply) local accName = getAccountName ( getPlayerAccount ( ply ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Console" ) ) then triggerClientEvent( ply, "initClanCreationWindow", ply, clanTable ) end end addCommandHandler("gangs",initClanCreationWindow) function getPlayerFaction(ply) local accName = getAccountName ( getPlayerAccount ( ply ) ) for k,v in pairs(clanTable) do for key,val in pairs(v["Members"]) do if val[1] == accName then return v["Name"], val[2] end end end end function getFactionData(name) for k,v in pairs(clanTable) do if v["Name"] == name then return v end end end function setFactionOnLogin() local faction, rank = getPlayerFaction(source) local data = getFactionData(faction) if faction and rank then setElementData(source,"faction",faction) setElementData(source,"GangRank",rank) if getTeamFromName (faction) then setPlayerTeam(source,getTeamFromName (faction)) else local team = createTeam(faction,unpack(data["Color"])) setPlayerTeam(source,team) end local oldName = getPlayerName(source) local newName = "["..faction.."]"..oldName setPlayerName(source, newName ) if data["X"] ~= 0 and data["Y"] ~= 0 and data["Z"] ~= 0 then setElementPosition(source,data["X"],data["Y"],data["Z"]+0.2) end end end addEventHandler("onPlayerLogin",root,setFactionOnLogin) function setFactionOnStart() GangRank = clanRankNames[rank] exports.scoreboard:addScoreboardColumn("GangRank") for i, v in ipairs (getElementsByType ("player")) do local acc = getPlayerAccount (v) if not isGuestAccount (acc) then local faction, rank = getPlayerFaction(v) local data = getFactionData(faction) if faction and rank then setElementData(v,"faction",faction) setElementData(v,"GangRank",rank) if getTeamFromName (faction) then setPlayerTeam(v,getTeamFromName (faction)) else local team = createTeam(faction,unpack(data["Color"])) setPlayerTeam(v,team) end local oldName = getPlayerName(v) local newName = "["..faction.."]"..oldName setPlayerName(v, newName ) if data["X"] ~= 0 and data["Y"] ~= 0 and data["Z"] ~= 0 then setElementPosition(v,data["X"],data["Y"],data["Z"]+0.2) end end end end end addEventHandler("onResourceStart",resourceRoot,setFactionOnStart) function deleteClan(name) local clan = getFactionData(name) for k,v in pairs(clan["Members"]) do local acc = getAccount(v[1]) local ply = getAccountPlayer( acc ) if ply then removeElementData(ply,"faction") removeElementData(ply,"GangRank") setPlayerTeam(ply,nil) outputChatBox("#FF0000[GANG]: #FFFFFFSua gang #FF0000"..name.." #FFFFFFfoi excluida por um de nossos #FF0000ADMINISTRADORES", ply, 255, 0, 0, true) end end dbExec(clanDB, "DELETE FROM Clans WHERE Name = ?",name) fillClanTable() end addEvent( "deleteClan", true ) addEventHandler("deleteClan", root, deleteClan) function inviteToClan(ply) if not getElementData(ply,"faction") then if not isGuestAccount (getPlayerAccount (ply)) then local clan = getFactionData(getElementData(source,"faction")) triggerClientEvent(ply,"clanInvitation",source,clan) else outputChatBox("#ff0000[GANG]: #ffffffO jogador ainda não esta logado no servidor.",source, 255, 255, 255,true) end else outputChatBox("#32CD32[GANG]: #ffffffO jogador já está na facção.",source, 255, 0, 0) end end addEvent( "inviteToClan", true ) addEventHandler("inviteToClan", root, inviteToClan) function acceptInvite(clan) setElementData(source,"faction", clan["Name"]) setElementData(source,"GangRank", 1) setPlayerTeam(source,getTeamFromName (clan["Name"])) local newMembers = clan["Members"] local accName = getAccountName ( getPlayerAccount ( source ) ) table.insert(newMembers,{accName,1}) dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"]) fillClanTable() end addEvent( "acceptInvite", true ) addEventHandler("acceptInvite", root, acceptInvite) function kickFromClan(login) if getElementData(source,"GangRank") == 6 or getElementData(source,"GangRank") == 5 then local acc = getAccount( login ) local clan = getFactionData(getElementData(source,"faction")) local newMembers = clan["Members"] for k,v in pairs(clan["Members"]) do if v[1] == login and v[2] < 6 then table.remove(newMembers,k) else end end dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"]) local ply = getAccountPlayer( acc ) if ply then removeElementData(ply,"faction") removeElementData(ply,"GangRank") outputChatBox("#ff0000[GANG]: #ffffffVocê foi excluído da facção.",ply) end fillClanTable() end end addEvent( "kickFromClan", true ) addEventHandler("kickFromClan", root, kickFromClan) function leaveClan() local clan = getFactionData(getElementData(source,"faction")) local newMembers = clan["Members"] local login = getAccountName(getPlayerAccount(source)) for k,v in pairs(clan["Members"]) do if v[1] == login and v[2] < 10 then table.remove(newMembers,k) end end dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"]) removeElementData(source,"faction") removeElementData(source,"GangRank") setPlayerTeam(source,nil) fillClanTable() end addEvent( "leaveClan", true ) addEventHandler("leaveClan", root, leaveClan) function changeClanCash(state,count) local clan = getFactionData(getElementData(source,"faction")) if clan then if state == "take" then if clan["Cash"] >= count then outputChatBox("#ff0000[GANG]: #ffffffVocê retirou com sucesso "..count.." #32CD32reais #ffffffda conta da facção!",source,255,255,255,true) givePlayerMoney(source,count) dbExec(clanDB, "UPDATE Clans SET Cash = ? WHERE Name = ? ",clan["Cash"]-count, clan["Name"]) fillClanTable() end elseif state == "give" then if getPlayerMoney(source) >= count then outputChatBox("#32CD32[GANG]: #ffffffVocê adicionou "..count.." #32CD32reias #ffffffpara sua facção!",source,255,255,255,true) takePlayerMoney(source,count) dbExec(clanDB, "UPDATE Clans SET Cash = ? WHERE Name = ? ",clan["Cash"]+count, clan["Name"]) fillClanTable() end end end end addEvent( "changeClanCash", true ) addEventHandler("changeClanCash", root, changeClanCash) function changeClanSpawnPoint(state) local x,y,z = getElementPosition(source) local clan = getElementData(source,"faction") if state then dbExec(clanDB, "UPDATE Clans SET X = ?, Y = ?, Z = ? WHERE Name = ? ",x,y,z, clan) fillClanTable() else dbExec(clanDB, "UPDATE Clans SET X = ?, Y = ?, Z = ? WHERE Name = ? ",0,0,0, clan) fillClanTable() end end addEvent( "changeClanSpawnPoint", true ) addEventHandler("changeClanSpawnPoint", root, changeClanSpawnPoint) function setNewClanRank(login,rank) if getElementData(source,"GangRank") == 6 or getElementData(source,"GangRank") == 5 then local acc = getAccount( login ) local clan = getFactionData(getElementData(source,"faction")) local newMembers = clan["Members"] for k,v in pairs(clan["Members"]) do if v[1] == login then if v[2] < 6 then v[2] = rank else return end end end dbExec(clanDB, "UPDATE Clans SET Members = ? WHERE Name = ? ",toJSON(newMembers), clan["Name"]) local ply = getAccountPlayer( acc ) if ply then removeElementData(ply,"faction") removeElementData(ply,"GangRank") setPlayerTeam(ply,nil) outputChatBox("#32CD32[GANG]: #ffffffSua nova classificação: #32CD32"..rank,ply,255,255,255,true) end fillClanTable() end end addEvent( "setNewClanRank", true ) addEventHandler("setNewClanRank", root, setNewClanRank) function playerQuit() local team = getPlayerTeam(source) setPlayerTeam(source,nil) if team then local teamCount = getPlayersInTeam(team) outputServerLog( "CONTAGEM DE EQUIPE: "..#teamCount ) if #teamCount <= 1 then destroyElement(team) end end end addEventHandler("onPlayerQuit",root,playerQuit) setTimer(function() for _,v in pairs(getElementsByType ("pickup")) do data = getElementData(v,"teamZone") if data then local result = dbPoll(dbQuery(clanDB, "SELECT * FROM Clans WHERE Name = ?",data),-1) if result and #result ~= 0 then cash1 = result[1].Cash cash2 = tonumber(cash1 + zp) dbExec(clanDB, "UPDATE Clans SET Cash = ? WHERE Name = ? ",cash2,data) fillClanTable() end end end end,3600000,0) Client local scx,scy = guiGetScreenSize() local px = scx/1920 local sizeX, sizeY = 400*px,600*px local posX,posY = 10*px,scy-sizeY-100*px local screen = dxCreateScreenSource( scx,scy ) local selectionsi_player_list_clan = 0 local presi_player_list_clan = false local scrollsi_player_list_clan = 0 local scrollMaxsi_player_list_clan = 0 local rtsi_player_list_clan = dxCreateRenderTarget( 280,160, true ) local clksi_player_list_clan = false local selectionsi_piglos = 0 local presi_piglos = false local scrollsi_piglos = 0 local scrollMaxsi_piglos = 0 local rtsi_piglos = dxCreateRenderTarget( 190,170, true ) local clksi_piglos = false local clanTable = nil local myClanTable = nil local creationWindow = nil local newClanWindow = nil local clanWindow = nil local font = guiCreateFont( "font.ttf", 32 ) local blipos = createBlip(2318.49194, 75.57992, 26.48438,60) setBlipVisibleDistance(blipos, 300) local marketbuy = createMarker(2318.49194, 75.57992, 25.48438, "cylinder", 1.5, 0, 255, 106, 50 ) function openNewClanWindows (element) if element == localPlayer then if stat_create_clan_mark == false then stat_create_clan_mark = true showCursor(true) addEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, true) guiSetInputMode("no_binds_when_editing", true) end end end addEventHandler( "onClientMarkerHit", marketbuy, openNewClanWindows ) function initClanCreationWindow(clans) if isElement(creationWindow) then showCursor(false) destroyElement(creationWindow) else clanTable = clans showCursor(true) creationWindow = guiCreateWindow(0.3,0.25,0.3,0.5,"Lista de Gangs - Servidor", true) local clanlist = guiCreateGridList(0.1,0.1,0.8,0.7,true,creationWindow) guiGridListAddColumn( clanlist, "Nome",0.5 ) guiGridListAddColumn( clanlist, "Lider",0.45 ) for k,v in pairs(clans) do local row = guiGridListAddRow(clanlist) guiGridListSetItemText(clanlist,row,1,v["Name"],false,false) guiGridListSetItemText(clanlist,row,2,v["Leader"],false,false) end local btnCreate = guiCreateButton(0.7,0.85,0.2,0.1,"Criar",true,creationWindow) local btnDelete = guiCreateButton(0.4,0.85,0.2,0.1,"Excluir",true,creationWindow) local btnClose = guiCreateButton(0.1,0.85,0.2,0.1,"Fechar",true,creationWindow) addEventHandler("onClientGUIClick",creationWindow,function() if source == btnCreate then initClanCreationWindow() if stat_create_clan_mark == false then stat_create_clan_mark = true showCursor(true) addEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, true) guiSetInputMode("no_binds_when_editing", true) else stat_create_clan_mark = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, false) guiSetInputMode("no_binds_when_editing", false) end elseif source == btnDelete then local clanName = guiGridListGetItemText( clanlist, guiGridListGetSelectedItem( clanlist ) ) triggerServerEvent( "deleteClan", localPlayer,clanName ) outputChatBox("#FF0000[GANG]: #FFFFFFVocê excluiu #FF0000"..clanName.." #FFFFFFcom sucesso", 255, 0, 0, true) initClanCreationWindow() elseif source == btnClose then initClanCreationWindow() end end) end end addEvent( "initClanCreationWindow", true ) addEventHandler("initClanCreationWindow", root, initClanCreationWindow) function isClanExists(name) for k,v in pairs(clanTable) do if v["Name"] == name then return true end end end function isRGB(str) local s = tonumber(str) if s and s >= 0 and s <= 255 then return true else return false end end stat_create_clan_mark = false name_clan = "Digite o nome da gang" scrolR_1 = scx / 2 + 127.5 ProcentR_1 = 1 visualPocentClan_1 = 0 scrolG_2 = scx / 2 + 127.5 ProcentG_2 = 1 visualPocentClan_2 = 0 scrolB_3 = scx / 2 + 127.5 ProcentB_3 = 1 visualPocentClan_3 = 0 edit = guiCreateEdit(scx / 2 - 145, scy / 2 - 15, 290, 20,name_clan,false) guiSetVisible(edit, false) function wnd_create_clan_mark () dxDrawWindow( scx / 2 - 150 , scy / 2 - 150, 300, 235, "Painel - Criar Gang") dxDrawScrollBarR(scx / 2 - 127.5, scy / 2 - 90, 255, 10, scrolR_1, "Vermelho "..math.floor(visualPocentClan_1 / 2.55).." %", ProcentR_1) dxDrawScrollBarG(scx / 2 - 127.5, scy / 2 - 65, 255, 10, scrolG_2, "Verde "..math.floor(visualPocentClan_2 / 2.55).." %", ProcentG_2) dxDrawScrollBarB(scx / 2 - 127.5, scy / 2 - 40, 255, 10, scrolB_3, "Azul "..math.floor(visualPocentClan_3 / 2.55).." %", ProcentB_3) dxDrawButtonText_pas(scx / 2 - 150, scy / 2 - 120, 300, 20, "Nome: "..name_clan, 1, 1) dxDrawButtonText(scx / 2 - 145, scy / 2 + 10, 290, 20, "Valor: 30 000 000$", 1, 1) dxDrawButton( scx / 2 - 145, scy / 2 + 35, 290, 20, "Criar") dxDrawButton( scx / 2 - 145, scy / 2 + 60, 290, 20, "Fechar") name_clan = guiGetText(edit) end addEventHandler( "onClientClick", root, function(button, state) if stat_create_clan_mark == true then if button == "left" and state == "down" then local x, y, w, h = scx / 2 - 127.5, scy / 2 - 90, 255, 10 if cursorPosition( scrolR_1, y-5, 10, h+10 ) then scrollMovingR_1 = true else if scrolR_1 <= x then if cursorPosition( x, y-5, 10, h+10 ) then scrollMovingR_1 = true end else if cursorPosition( (x+w)-10, y-5, 10, h+10 ) then scrollMovingR_1 = true end end end elseif button == "left" and state == "up" then if scrollMovingR_1 then scrollMovingR_1 = false end end if button == "left" and state == "down" then local x, y, w, h = scx / 2 - 127.5, scy / 2 - 65, 255, 10 if cursorPosition( scrolG_2, y-5, 10, h+10 ) then scrollMovingG_2 = true else if scrolG_2 <= x then if cursorPosition( x, y-5, 10, h+10 ) then scrollMovingG_2 = true end else if cursorPosition( (x+w)-10, y-5, 10, h+10 ) then scrollMovingG_2 = true end end end elseif button == "left" and state == "up" then if scrollMovingG_2 then scrollMovingG_2 = false end end if button == "left" and state == "down" then local x, y, w, h = scx / 2 - 127.5, scy / 2 - 40, 255, 10 if cursorPosition( scrolB_3, y-5, 10, h+10 ) then scrollMovingB_3 = true else if scrolB_3 <= x then if cursorPosition( x, y-5, 10, h+10 ) then scrollMovingB_3 = true end else if cursorPosition( (x+w)-10, y-5, 10, h+10 ) then scrollMovingB_3 = true end end end elseif button == "left" and state == "up" then if scrollMovingB_3 then scrollMovingB_3 = false end end end end) addEventHandler( "onClientCursorMove", getRootElement( ), function ( _, _, xMove ) if scrollMovingR_1 then scrolR_1 = xMove end if scrollMovingG_2 then scrolG_2 = xMove end if scrollMovingB_3 then scrolB_3 = xMove end end) function click_clan_mark (button, state) if stat_create_clan_mark == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 - 145, scy / 2 - 15, 290, 20) then guiSetText(edit, "") end if cursorPosition(scx / 2 - 145, scy / 2 + 36, 290, 20) then if name_clan and #name_clan >= 2 and #name_clan <=15 then local Color_1 = getElementData(localPlayer, "ColorRclan") or 255 local Color_2 = getElementData(localPlayer, "ColorGclan") or 255 local Color_3 = getElementData(localPlayer, "ColorBclan") or 255 triggerServerEvent( "createNewClan", localPlayer, name_clan, Color_1, Color_2, Color_3 ) else outputChatBox("#FF0000[GANG]: #FFFFFFNome invalido. O comprimento mínimo do nome é de 2 caracteres, o máximo é de 15 caracteres..", 255, 0, 0, true) end stat_create_clan_mark = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, false) guiSetInputMode("no_binds_when_editing", false) end if cursorPosition(scx / 2 - 145, scy / 2 + 60, 290, 20) then stat_create_clan_mark = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, false) guiSetInputMode("no_binds_when_editing", false) end end end end addEventHandler("onClientClick", root, click_clan_mark) function open_wnd_clan_mark () if stat_create_clan_mark == false then stat_create_clan_mark = true showCursor(true) addEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, true) guiSetInputMode("no_binds_when_editing", true) else stat_create_clan_mark = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_mark) guiSetVisible(edit, false) guiSetInputMode("no_binds_when_editing", false) end end clans = "" memberName = nil stat_create_clan_upravlenie = false function wnd_create_clan_upravlenie () local rank = getElementData(localPlayer,"factionrank") dxDrawWindow( scx / 2 - 150 , scy / 2 - 155, 300, 330, "Gang : "..clans["Name"].." | Rank : "..clanRankNames[rank]) dxDrawRectangle(scx / 2 - 140,scy / 2 - 125,280,170,tocolor(0,0,0,200)) dxDrawButton( scx / 2 - 145, scy / 2 + 50, 290, 20, "Banir jogador da gang") dxDrawButton( scx / 2 - 145, scy / 2 + 75, 290, 20, "Alterar a classificação do jogador") dxDrawButton( scx / 2 - 145, scy / 2 + 100, 290, 20, "Convidar jogador para a gang") dxDrawButton( scx / 2 - 145, scy / 2 + 125, 142.5, 20, "Definir Spawn") dxDrawButton( scx / 2 + 2.5, scy / 2 + 125, 142.5, 20, "Remover Spawn") dxDrawButton( scx / 2 - 145, scy / 2 + 150, 142.5, 20, "Abandonar a gang") dxDrawButton( scx / 2 + 2.5, scy / 2 + 150, 142.5, 20, "$ Tesouro da gang $") local CRL = getElementData(localPlayer, "ColorR") or standartR local CGL = getElementData(localPlayer, "ColorG") or standartG local CBL = getElementData(localPlayer, "ColorB") or standartB dxUpdateScreenSource( screen ) dxSetRenderTarget( rtsi_player_list_clan,true ) if scrollsi_player_list_clan < 0 then scrollsi_player_list_clan = 0 elseif scrollsi_player_list_clan >= scrollMaxsi_player_list_clan then scrollsi_player_list_clan = scrollMaxsi_player_list_clan end local sy = 0 for k,v in pairs(clans["Members"]) do if k == selectionsi_player_list_clan then yes_cl_w = 280 yes_cl_x = 0 dxDrawRectangle(yes_cl_x,sy-scrollsi_player_list_clan,yes_cl_w,15,tocolor(CRL, CGL, CBL, 255)) else no_cl_w = 270 no_cl_x = 5 dxDrawRectangle(no_cl_x,sy-scrollsi_player_list_clan,no_cl_w,15,tocolor(200, 200, 200, 200)) end dxDrawText("Login : "..v[1],10,sy-scrollsi_player_list_clan - 10,490,sy-scrollsi_player_list_clan+26,tocolor(255,255,255),1,1,"default-bold","left","center") dxDrawText("Rank : "..clanRankNames[v[2]],155,sy-scrollsi_player_list_clan - 10,490,sy-scrollsi_player_list_clan+26,tocolor(255,255,255),1,1,"default-bold","left","center") sy = sy + 16 end dxSetRenderTarget() dxDrawImage( scx / 2 - 140,scy / 2 - 120,280,160,rtsi_player_list_clan) if sy >= 160 then scrollMaxsi_player_list_clan = sy-160 local size = 160/sy*160 end local spy = 0 for k,v in pairs(clans["Members"]) do if cursorPosition(scx / 2 - 140,scy / 2 - 120,280,170) then if cursorPosition( scx / 2 - 140,scy / 2 - 120+spy-scrollsi_player_list_clan,280,15) then if getKeyState("mouse1") and not clksi_player_list_clan then selectionsi_player_list_clan = k memberName = v[1] end end end spy = spy + 16 end if getKeyState("mouse1") then clksi_player_list_clan = true else clksi_player_list_clan = false end end stat_set_rank = false edit_rank = guiCreateEdit(scx / 2 - 80, scy / 2 - 205, 160, 20,"Nova classificação (1a5)",false) guiSetVisible(edit_rank, false) function set_rank () dxDrawWindow( scx / 2 - 85 , scy / 2 - 235, 170, 80, "Alterar Classificação") dxDrawButton( scx / 2 - 80, scy / 2 - 180, 160, 20, "Confirmar") end function click_clan_set_rank (button, state) if stat_set_rank == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 - 80, scy / 2 - 205, 160, 20) then guiSetText(edit_rank, "") end if cursorPosition(scx / 2 - 80, scy / 2 - 180, 160, 20) then if selectionsi_player_list_clan == 1 then outputChatBox("#ff0000[GANG]: #ffffffVocê não pode mudar a sua classificação.!",255,0,0,true) else local text = guiGetText(edit_rank) if tonumber(text) and tonumber(text) >= 1 and tonumber(text) <= 5 then local rank = tonumber(text) outputChatBox("#32cd32[GANG]: #ffffffVocê alterou com sucesso a classificação do jogador: #32CD32"..memberName.."#ffffff!",0,255,0,true) triggerServerEvent( "setNewClanRank", localPlayer, memberName, rank ) stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) else outputChatBox("Valor inválido.",255,0,0) end end end end end end addEventHandler("onClientClick", root, click_clan_set_rank) function click_clan_upravlenie (button, state) if stat_create_clan_upravlenie == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 - 145, scy / 2 + 50, 290, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 or rank == 5 then if memberName then if selectionsi_player_list_clan == 1 then outputChatBox("#FF0000[GANG]: #FFFFFFO lider da #FF0000[GANG] #FFFFFFnão pode ser banido", 255, 0, 0, true) else if cc == 5 then outputChatBox("#ff0000[GANG]: #ffffffVocê não pode se banir, você só pode deixar a facção!",255,255,255) else triggerServerEvent( "kickFromClan", localPlayer, memberName ) outputChatBox("#32cd32[GANG] #ffffffVocê excluiu com sucesso um jogador!",255,255,255,true) end end else outputChatBox("#ff0000[GANG]: #ffffffNenhum jogador selecionado!",255,255,255,true) end else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end if cursorPosition(scx / 2 - 145, scy / 2 + 75, 290, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 or rank == 5 then if memberName then if stat_exit == true then stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end if stat_set_rank == false then stat_set_rank = true addEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, true) guiSetInputMode("no_binds_when_editing", true) else stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end else outputChatBox("#ff0000[GANG]: #ffffffNenhum jogador selecionado!",255,255,255,true) end else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end if cursorPosition(scx / 2 - 145, scy / 2 + 100, 290, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 or rank == 5 then if stat_exit == true then stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == false then stat_piglos = true addEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 else stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end if cursorPosition(scx / 2 - 145, scy / 2 + 125, 142.5, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 then outputChatBox("#32cd32[GANG]: #ffffffVocê adicionou um ponto de renacimento para sua facção!!",255,255,255,true) triggerServerEvent("changeClanSpawnPoint",localPlayer,true) else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end if cursorPosition(scx / 2 + 2.5, scy / 2 + 125, 142.5, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 then triggerServerEvent("changeClanSpawnPoint",localPlayer,false) outputChatBox("#ff0000[GANG]: #ffffffVocê removeu o ponto de renacimento de sua facção!!",255,255,255,true) else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end if cursorPosition(scx / 2 + 2.5, scy / 2 + 150, 142.5, 20) then if stat_exit == true then stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == false then stat_kazna = true addEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, true) guiSetInputMode("no_binds_when_editing", true) else stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end end if cursorPosition(scx / 2 - 145, scy / 2 + 150, 142.5, 20) then if stat_exit == false then stat_exit = true addEventHandler("onClientRender", root, wnd_exit) else stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end end end end end addEventHandler("onClientClick", root, click_clan_upravlenie) stat_exit = false function wnd_exit () dxDrawWindow( scx / 2 - 150 , scy / 2 - 235, 300, 80, "Pense bem antes de abandonar, nao tera volta.") dxDrawButtonText(scx / 2 - 150 , scy / 2 - 205, 300, 20, "Tem certeza que voce quer abandonar a gang?\n"..clans["Name"].." ??", 1, 1) dxDrawButton( scx / 2 - 145, scy / 2 - 180, 142.5, 20, "Sim, Abandonar") dxDrawButton( scx / 2 + 2.5, scy / 2 - 180, 142.5, 20, "Não, Fechar") end function click_clan_exit(button, state) if stat_exit == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 - 145, scy / 2 - 180, 142.5, 20) then triggerServerEvent( "leaveClan", localPlayer) stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) outputChatBox("Você deixou o clã com sucesso",0,255,0) stat_create_clan_upravlenie = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie) memberName = nil selectionsi_player_list_clan = 0 if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end end if cursorPosition(scx / 2 + 2.5, scy / 2 - 180, 142.5, 20) then stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end end end end addEventHandler("onClientClick", root, click_clan_exit) stat_kazna = false edit_kazna = guiCreateEdit(scx / 2 - 100, scy / 2 - 205, 198.5, 20,"0",false) guiSetVisible(edit_kazna, false) function wnd_kazna () dxDrawWindow( scx / 2 - 102.5 , scy / 2 - 235, 205, 80, "Tesouro do clã : "..clans["Cash"]) dxDrawButton( scx / 2 - 98.5, scy / 2 - 180, 95, 20, "Colocar") dxDrawButton( scx / 2 + 2.5 , scy / 2 - 180, 95, 20, "Retirar") end function click_clan_kazna(button, state) if stat_kazna == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 - 100, scy / 2 - 205, 198.5, 20) then guiSetText(edit_kazna, "") end if cursorPosition(scx / 2 - 98.5, scy / 2 - 180, 95, 20) then local cashText = guiGetText(edit_kazna) if tonumber(cashText) and tonumber(cashText) <= getPlayerMoney(localPlayer) then if ( string.find ( tonumber(cashText), '-' ) ) then outputChatBox("Valor errado",255,0,0) else triggerServerEvent( "changeClanCash", localPlayer, "give", tonumber(cashText) ) stat_create_clan_upravlenie = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie) memberName = nil selectionsi_player_list_clan = 0 if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end end end end if cursorPosition(scx / 2 + 2.5 , scy / 2 - 180, 95, 20) then local rank = getElementData(localPlayer,"factionrank") if rank == 6 or rank == 5 then local cashText = guiGetText(edit_kazna) if tonumber(cashText) and tonumber(cashText) <= clans["Cash"] then if ( string.find ( tonumber(cashText), '-' ) ) then outputChatBox("Valor inválido",255,0,0) else triggerServerEvent( "changeClanCash", localPlayer, "take", tonumber(cashText) ) stat_create_clan_upravlenie = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie) memberName = nil selectionsi_player_list_clan = 0 if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end end else outputChatBox("#ff0000[GANG]: #ffffffQuantidade inválida!",255,255,255,true) end else outputChatBox("#ff0000[GANG]: #ffffffVocê não tem permissão suficiente!",255,255,255,true) end end end end end addEventHandler("onClientClick", root, click_clan_kazna) stat_piglos = false function wnd_rpiglos () dxDrawWindow( scx / 2 + 155 , scy / 2 - 155, 200, 235, "Lista de jogadores") dxDrawButton( scx / 2 + 160, scy / 2 + 55, 190, 20, "Convidar") dxDrawRectangle(scx / 2 + 160 , scy / 2 - 125,190,175,tocolor(0,0,0,200)) local CRL = getElementData(localPlayer, "ColorR") or standartR local CGL = getElementData(localPlayer, "ColorG") or standartG local CBL = getElementData(localPlayer, "ColorB") or standartB dxUpdateScreenSource( screen ) dxSetRenderTarget( rtsi_piglos,true ) if scrollsi_piglos < 0 then scrollsi_piglos = 0 elseif scrollsi_piglos >= scrollMaxsi_piglos then scrollsi_piglos = scrollMaxsi_piglos end local sy = 0 for k,player in pairs(getElementsByType("player")) do if not getElementData(player,"faction") then if k == selectionsi_piglos then yes_cl_w = 190 yes_cl_x = 0 dxDrawRectangle(yes_cl_x,sy-scrollsi_piglos,yes_cl_w,15,tocolor(CRL, CGL, CBL, 255)) else no_cl_w = 180 no_cl_x = 5 dxDrawRectangle(no_cl_x,sy-scrollsi_piglos,no_cl_w,15,tocolor(200, 200, 200, 200)) end local nick = getPlayerName(player) dxDrawText(string.gsub( nick, "#%x%x%x%x%x%x", "", 1 ),0,sy-scrollsi_piglos - 10,190,sy-scrollsi_piglos+26,tocolor(255,255,255),1,1,"default-bold","center","center") sy = sy + 16 end end dxSetRenderTarget() dxDrawImage(scx / 2 + 160, scy / 2 - 120,190,170,rtsi_piglos) if sy >= 170 then scrollMaxsi_piglos = sy-170 local size = 170/sy*170 end local spy = 0 for k,player in pairs(getElementsByType("player")) do if not getElementData(player,"faction") then if cursorPosition(scx / 2 + 160, scy / 2 - 120,190,170) then if cursorPosition(scx / 2 + 160, scy / 2 - 120+spy-scrollsi_piglos,190,15) then if getKeyState("mouse1") and not clksi_piglos then if k == 1 then outputChatBox("você não pode se convidar") else selectionsi_piglos = k igrok = player end end end end spy = spy + 16 end end if getKeyState("mouse1") then clksi_piglos = true else clksi_piglos = false end end function click_clan_invite (button, state) if stat_piglos == true then if button == "left" and state == "down" then if cursorPosition(scx / 2 + 160, scy / 2 + 55, 190, 20) then if selectionsi_piglos == 0 then outputChatBox("Você não selecionou um jogador",255,0,0) else triggerServerEvent( "inviteToClan", localPlayer, igrok ) outputChatBox("Convite para o jogador enviado com sucesso",0,255,0) selectionsi_piglos = 0 end end end end end addEventHandler("onClientClick", root, click_clan_invite) addEventHandler("onClientKey",root,function(key,presi_piglos) if presi_piglos then if not stat_piglos then return end if key == "mouse_wheel_down" then scrollsi_piglos = scrollsi_piglos + 12 elseif key == "mouse_wheel_up" then scrollsi_piglos = scrollsi_piglos - 12 end end end) addEventHandler("onClientKey",root,function(key,presi_player_list_clan) if presi_player_list_clan then if not stat_create_clan_upravlenie then return end if key == "mouse_wheel_down" then scrollsi_player_list_clan = scrollsi_player_list_clan + 12 elseif key == "mouse_wheel_up" then scrollsi_player_list_clan = scrollsi_player_list_clan - 12 end end end) function open_wnd_clan_upravlenie (clan) clans = clan if stat_create_clan_upravlenie == false then stat_create_clan_upravlenie = true showCursor(true) addEventHandler("onClientRender", root, wnd_create_clan_upravlenie) memberName = nil selectionsi_player_list_clan = 0 else stat_create_clan_upravlenie = false showCursor(false) removeEventHandler("onClientRender", root, wnd_create_clan_upravlenie) memberName = nil selectionsi_player_list_clan = 0 if stat_set_rank == true then stat_set_rank = false removeEventHandler("onClientRender", root, set_rank) guiSetVisible(edit_rank, false) guiSetInputMode("no_binds_when_editing", false) end if stat_piglos == true then stat_piglos = false removeEventHandler("onClientRender", root, wnd_rpiglos) selectionsi_piglos = 0 end if stat_kazna == true then stat_kazna = false removeEventHandler("onClientRender", root, wnd_kazna) guiSetVisible(edit_kazna, false) guiSetInputMode("no_binds_when_editing", false) end if stat_exit == true then stat_exit = false removeEventHandler("onClientRender", root, wnd_exit) end end end addEvent( "openClanWindow", true ) addEventHandler("openClanWindow", root, open_wnd_clan_upravlenie) function bindd_wnd_clan_upravlenie () if not getElementData(localPlayer,"faction") then outputChatBox("#FF0000[ACESSO-NEGAGO]: #FFFFFFPara acessar esse painel, voce precisa estar em uma #FF0000[GANG]", 255, 0, 0, true) else triggerServerEvent("openClanWindowS", localPlayer) end end bindKey("F7","down",bindd_wnd_clan_upravlenie) local inviteWindow = nil function clanInvitation(clan) if not isElement(inviteWindow) then inviteWindow = guiCreateWindow(0.35,0.4,0.25,0.1,"Convite para gang",true,inviteWindow) local btnClose = guiCreateButton(0.1,0.6,0.3,0.3,"Negar",true,inviteWindow) local btnAccept = guiCreateButton(0.6,0.6,0.3,0.3,"Aceitar",true,inviteWindow) addEventHandler("onClientGUIClick",inviteWindow,function() if source == btnClose then showCursor(false) destroyElement(inviteWindow) elseif source == btnAccept then showCursor(false) destroyElement(inviteWindow) triggerServerEvent( "acceptInvite", localPlayer, clan ) end end) local label = guiCreateLabel(0,0.3,1,0.2,"Você quer se juntar a gang "..clan["Name"],true,inviteWindow) guiLabelSetHorizontalAlign( label, "center" ) end end addEvent( "clanInvitation", true ) addEventHandler("clanInvitation", root, clanInvitation) Ranknames clanRankNames = { [1] = "Aprendiz", [2] = "Membro", [3] = "Treinador", [4] = "Sub-Comandante", [5] = "Comandante", [6] = "Líder" } please, help me out
  23. Please! Someone help me with this!
  24. Hi guys, I'm trying to export the info of this function here clanRankNames = { [1] = "Aprendiz", [2] = "Membro", [3] = "Treinador", [4] = "Sub-Comandante", [5] = "Comandante", [6] = "Líder" } into the scoreboard using this GangRank = clanRankNames[rank] exports.scoreboard:addScoreboardColumn("GangRank") but instead of getting the text in the quotes, i'm getting the number in brackets. How can I get the text in the scoreboard?
×
×
  • Create New...