Jump to content

Razor64

Members
  • Posts

    15
  • Joined

  • Last visited

Everything posted by Razor64

  1. Hola y buen dia, tengo un problema con script que lee mapas y almacena los datos en tablas, el problema está en que al ejecutar la funcion toda la informacion se almacena en la memoria RAM (pienso que asi es como trabaja) y no encuentro la forma correcta de vaciar esa memoria usada por el script, entonces esto provoca que al ejcutarse varias veces el mismo, se termine consumiendo la meroia del VPS hasta bloquearlo. He probado con varias formas pero ninguna parece funcionar, les adjunto toda la informacion y esperoque puedan ayudarme con este problema. local cacheRead = {} function readMapData(executeElement, mapName) cacheRead[executeElement] = { objects = {}; vehicles = {}; peds = {}; markers = {}; } local meta = xmlLoadFile(":"..mapName.."/meta.xml") if meta then for i, metaData in ipairs(xmlNodeGetChildren(meta)) do local metaTypeData = xmlNodeGetName(metaData) if metaTypeData == "map" then local metaMapFileMap = xmlNodeGetAttribute(metaData,"src") if metaMapFileMap then local mapFile = xmlLoadFile(":"..mapName.."/"..metaMapFileMap) if mapFile then for index, elementsMap in ipairs(xmlNodeGetChildren(mapFile)) do local mapTypeNode = xmlNodeGetName(elementsMap) if mapTypeNode == "object" then table.insert(cacheRead[executeElement]["objects"] ,{ modelId = tonumber(xmlNodeGetAttribute(elementsMap,"model")), interiorID = tonumber(xmlNodeGetAttribute(elementsMap, "interior")) or 0, posX = tonumber(xmlNodeGetAttribute(elementsMap,"posX")), posY = tonumber(xmlNodeGetAttribute(elementsMap,"posY")), posZ = tonumber(xmlNodeGetAttribute(elementsMap,"posZ")), rotX = tonumber(xmlNodeGetAttribute(elementsMap,"rotX")) or 0, rotY = tonumber(xmlNodeGetAttribute(elementsMap,"rotY")) or 0, rotZ = tonumber(xmlNodeGetAttribute(elementsMap,"rotZ")) or 0, }) elseif mapTypeNode == "vehicle" then table.insert(cacheRead[executeElement]["vehicles"] ,{ paintjobID = tonumber(xmlNodeGetAttribute(elementsMap,"paintjob")) or 3, interiorID = tonumber(xmlNodeGetAttribute(elementsMap, "interior")) or 0, dimensionID = tonumber(xmlNodeGetAttribute(elementsMap, "dimension")) or 0, modelID = tonumber(xmlNodeGetAttribute(elementsMap,"model")) or 411, plate = tonumber(xmlNodeGetAttribute(elementsMap,"plate")) or "LATIN-SV", posX = tonumber(xmlNodeGetAttribute(elementsMap,"posX")) or 0, posY = tonumber(xmlNodeGetAttribute(elementsMap,"posY")) or 0, posZ = tonumber(xmlNodeGetAttribute(elementsMap,"posZ")) or 0, rotX = tonumber(xmlNodeGetAttribute(elementsMap,"rotX")) or 0, rotY = tonumber(xmlNodeGetAttribute(elementsMap,"rotY")) or 0, rotZ = tonumber(xmlNodeGetAttribute(elementsMap,"rotZ")) or 0, }) elseif mapTypeNode == "ped" then table.insert(cacheRead[executeElement]["peds"] ,{ modelID = tonumber(xmlNodeGetAttribute(elementsMap,"model")) or 0, interiorID = tonumber(xmlNodeGetAttribute(elementsMap, "interior")) or 0, dimensionID = tonumber(xmlNodeGetAttribute(elementsMap, "dimension")) or 0, posX = tonumber(xmlNodeGetAttribute(elementsMap,"posX")) or 0, posY = tonumber(xmlNodeGetAttribute(elementsMap,"posY")) or 0, posZ = tonumber(xmlNodeGetAttribute(elementsMap,"posZ")) or 0, rotZ = tonumber(xmlNodeGetAttribute(elementsMap,"rotZ")) or 0, alpha = tonumber(xmlNodeGetAttribute(elementsMap,"alpha")) or 255, frozen = tonumber(xmlNodeGetAttribute(elementsMap,"frozen")) or "false", }) elseif mapTypeNode == "marker" then table.insert(cacheRead[executeElement]["markers"] ,{ theType = xmlNodeGetAttribute(elementsMap, "type"), interiorID = tonumber(xmlNodeGetAttribute(elementsMap, "interior")) or 0, posX = tonumber(xmlNodeGetAttribute(elementsMap, "posX")), posY = tonumber(xmlNodeGetAttribute(elementsMap, "posY")), posZ = tonumber(xmlNodeGetAttribute(elementsMap, "posZ")), rotX = tonumber(xmlNodeGetAttribute(elementsMap,"rotX")) or 0, rotY = tonumber(xmlNodeGetAttribute(elementsMap,"rotY")) or 0, rotZ = tonumber(xmlNodeGetAttribute(elementsMap,"rotZ")) or 0, size = tonumber(xmlNodeGetAttribute(elementsMap, "size")), color = xmlNodeGetAttribute(elementsMap, "color"), }) end end xmlSaveFile(mapFile) xmlUnloadFile(mapFile) else return false end end end end xmlSaveFile(meta) xmlUnloadFile(meta) outputDebugString('Fueron leidos los datos del mapa ( '..mapName..' ) correctamente' , 0, 0, 255, 0) meta = nil metaTypeData = nil metaMapFileMap = nil mapFile = nil return cacheRead[executeElement] else outputDebugString('Se produjo un error al leer los datos del mapa ( '..mapName..' )' , 0, 255, 0, 0) return false end end
  2. Espero que esto te sea util, no pude probarlo pero igual te podria dar una idea en caso de no servirte. -- Server Side. local hillRadar = createRadarArea ( 93, 1800, 200, 200, 181, 0, 0, 200 ) function BossDayZ ( ) nemesi = exports [ "slothBot" ]:spawnBot ( 259.837890625, 1816.2080078125, 1.0078125, 90, 33, 0, 0, Nemesis, 38, "hunting", true ) setElementData( nemesi, "blood", 9999999999 ) triggerClientEvent ( "nsound", root ) end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), BossDayZ ) function onPedAttack ( attacker ) if ( isElement ( attacker ) == true ) then -- Comprueba si existe el atacante antes de proceder. if ( getElementModel ( attacker ) == 33) then setElementData ( source, getElementData(source, "blood") - 400) setElementData ( ptarget, source, "blood" - 2000) end end end addEventHandler( "onPlayerDamage", getRootElement ( ), OnPedAttack ) addEvent ( "getBloodBoss", true ) function getBloodBoss( nemesi ) if ( isElement ( nemesi ) ) then killPed ( nemesi ) destroyElement ( nemesi ) end end addEventHandler ( "getBloodBoss", getRootElement(), getBloodBoss ) -- Client Side. function Skinemesis1() engineImportTXD( engineLoadTXD ("data/107.txd", 93 ), 93) engineReplaceModel( engineLoadDFF ("data/107.dff", 93), 93) end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), Skinemesis1 ) addEvent ( "nsound", true ) addEventHandler ( "nsound", root, function ( ) playSound ( "data/nemesis.mp3" ) end) function getBloodBoss ( attacker, weapon, bodypart ) if ( isElement ( attacker ) ) then -- Comprueba si existe el atacante antes de proceder. if ( getElementModel ( source == 33 ) ) then -- Ahora revisa si es nemesis el ped que es atacado. setElementData ( source, getElementData(source, "blood") - 6000) if ( getElementData( source, "blood") < 1 ) then -- Al mismo tiempo comprueba si le queda poca vida para asi destruir al ped. triggerServerEvent ( "getBloodBoss", root ) end end end end addEventHandler ( "onClientPedDamage", root, getBloodBoss )
  3. Razor64

    [Ayuda]Ped

    function makeAPed ( ) myped = exports.slothbot:spawnBot ( -377.888671875, 2184.87109375, 42.431251525879, 0, 226 , 0, 0, akatsuki, 4, "fire", true ) end addEventHandler ( "onResourceStart", resourceRoot, makeAPed) addEvent("onBotWasted", true) addEventHandler("onBotWasted", root, function(attacker, weapon, bodypart) setTimer(outputChatBox, 15*1000, 1, "* Se ha creado un nuevo ped", root, 0, 255, 120 ) setTimer(makeAPed, 15*1000, 1) end)
  4. Seria como TheCrazy17 dice, pero sin eso del index... if #tabla == 1 then
  5. No se si comprendi bien lo que quieres, pero a lo que entendi podria servirte lo siguiente... function onPlayerChat(mensaje, tipo_mensaje) triggerEvent("onPlayerSendMessage", source, mensaje, tipo_mensaje) -- Aqui se envia el trigger con el tipo de mensaje y el mensaje, para tu crear un mensaje personalizado. cancelEvent() -- Y con esto se cancela el envio del mensaje predeterminado. end addEventHandler( "onPlayerChat", getRootElement(), onPlayerChat ) addEvent("onPlayerSendMessage", true) function chatMessage( mensaje, tipo_mensaje ) if isCommand(source, mensaje) then return end if (tipo_mensaje == 0) then -- Si el player envia un mensaje comun (precionando la tecla T) saldra un 'outputChatBox' con tag de 'Global'. outputChatBox("#990000[Global]#FFFFFF "..getPlayerName(source).."#FFFFFF: "..mensaje, root, 255, 255, 255, true) end end addEventHandler( "onPlayerSendMessage", root, chatMessage) function isCommand(player, text) local c1, c2 = string.find(text, "/") if not c1 or c1 ~= 1 then return false end text = text:sub(2, #text) if #text:gsub("%s", "") == 0 then return true end local command = text:split(" ") local argList = "" for i=2, #command do argList = argList.." "..command[i] end if not hasObjectPermissionTo(player, "command.".. text, true) then return end executeCommandHandler(command[1], player, argList) triggerClientEvent(player, "onClientExecuteCommand", player, command, argList) return true end function string:split(sep) local sep, fields = sep or ":", {} local pattern = string.format("([^%s]+)", sep) self:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end Con esto cancelaras el mensaje default que se envia al precionar la tecla T y en su lugar saldra un mensaje mas personalizado, no se bien por que requieres de un trigger yo en hubiese hecho todo de forma directa, pero de igual manera sirve aun que es mas largo :v si tienes alguna al respecto hazla saber.
  6. Esto te podria servir... elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Everyone")) then cancelEvent() local lvl = getElementData( source, "level" ) local r, g, b = getPlayerNametagColor( source ) local gang = exports.gang_system:getPlayerGang ( source) if ( gang ~= "None" ) then -- Aqui compruebas que el gang del player sea diferente a 'None'. tagGang = "#FFFFFF[" .. gang .. "] " -- Si el 'getPlayerGang' retorna un resultado diferente a 'None', te saldra este tag. else tagGang = "" -- Y aqui, si el 'getPlayerGang' retorna 'None', simplemente no aparecera nada. end outputChatBox( tagGang.. getPlayerName ( source ) ..":#FFFFFF " .. text, getRootElement(), r, g, b, true ) outputServerLog("CHAT: [user] " .. getPlayerName ( source ) .. ": " .. text)
  7. Tal vez podrias utilizar esto... addEventHandler( "Taser", getRootElement(), function() if source then setElementFrozen (source,true) setElementData(source,"Anim2",true) setPedAnimation(source, "CRACK", "crckdeth2", 5000, false, false, false, true) Elemento = source setTimer(function() if Elemento then setElementData(Elemento , "Anim2",false) setElementFrozen(Elemento , false) end end, 5000, 1) end end)
  8. Creo que con esto se solucionara en parte tu problema... local sx, sy = guiGetScreenSize() function mostrarsed () local sed = getElementData(localPlayer,"sed") or 100 local anchototal = 120*(sed/100) dxDrawRectangle((848/1024)*sx, (198/768)*sy, (124/1024)*sx, (14/768)*sy, tocolor(0, 0, 0, 255), false) dxDrawRectangle((850/1024)*sx, (200/768)*sy, (120/1024)*sx, (10/768)*sy, tocolor(0, 57, 0, 255), false) dxDrawRectangle((850/1024)*sx, (200/768)*sy, (anchototal/1024)*sx, (10/768)*sy, tocolor(0, 200, 0, 255), false) dxDrawText("Sed", (892/1024)*sx, (200/768)*sy, (925/1024)*sx, (212/768)*sy, tocolor(0, 0, 0, 255), (0.40/1024)*sx, (0.40/768)*sy, "bankgothic", "center", "center", false, false, false, false, false) dxDrawText("Sed", (891/1024)*sx, (199/768)*sy, (924/1024)*sx, (211/768)*sy, tocolor(255, 255, 255, 255), (0.40/1024)*sx, (0.40/768)*sy, "bankgothic", "center", "center", false, false, false, false, false) end function abrirsed() addEventHandler ( "onClientRender", getRootElement(), mostrarsed ) end addEvent( "onSed", true ) addEventHandler( "onSed", getRootElement(), abrirsed ) Usandolo de esa manera los dx quedaran en la misma posicion en cualquier tipo de resolucion no importa si es muy baja o alta y el el texto tambien se ajusta, pero el problema esta en el HUD el cual si cambia de tamaño segun la resolucion por ejemplo en la resolucion de 1024x768 el HUD queda arriba de la barra de Sed, pero en 1366x768 esta queda encima, te recomendaria ponerla un poco mas abajo o en otro sitio donde no estorbe, eso en caso de que uses el HUD default si usas uno hecho por ti y que use dx podrias usar las mismas variables para que mantenga la misma posicion en cualquier resolucion, bueno espero que te sirva.
  9. Razor64

    Boton

    Creo que podrias tener suerte si pruebas esto... function agua() if (source == BucearSinMorir) then if not(funcActive) then funcActive = true local maxOxygen = math.floor(1000 + getPedStat(localPlayer, 22) * 1.5 + getPedStat(localPlayer, 225) * 1.5) timerFunction = setTimer(setPedOxygenLevel, 50, 0, localPlayer, maxOxygen) outputChatBox("#0099FFBucear sin morir: #00FF00ON", 255, 255, 255, true) else funcActive = false outputChatBox("#0099FFBucear sin morir: #FF0000OFF", 255, 255, 255, true) if isTimer(timerFunction) then killTimer(timerFunction) outputChatBox("Timer Kill") end end end end addEventHandler("onClientGUIClick", root, agua) Con esta funcion podras activar/desactivar la funcion solo con precionar el boton del GUI, hace lo que pides osea no morira al bucear pero si podra morir por otros medios, si lo que buscas es que sea completamente inmortal sigue pobrando con el "onClientPlayerDamage" y "cancelEvent", espero que te sirva.
  10. Si lo estaba probando talcual me diste el ejemplo y funcionaba bien pero te digo aparecia el problema que le daba stats a todos, pero aqui el problema yo solo remplase tu ejemplo por el mio pero no hice lo mismo con los demas con la escuasa de "pues si funciona este bien depues arrglo los demas" y pues asi estube probando solo con el arma del ejemplo que me diste y no funcionaba pasaba lo mismo y ahora que vi tu ultimo mensaje dije pues puede que no trabaje bien por que los demas estan mal y eso afecta a todo, pues arregle todo y que crees funciona al 100% bien, mucha gracias Tomas por ayudarme de verdad te lo agradesco y siento mucho a verte hecho perder tiempo si tan solo lo hubiera colocado bien todo desde el inicio ya hubiese quedado desde cuando. gracias por tu atencion
  11. eso no lo he chekado pero casi estoy seguro que le ha de salir a todos, y por ejemplo si yo completo el stat de alguna arma ya no sigue sumando puntos a los stats de nadie en el server, pero si estoy solo yo si funciona bien es decir si alguien llega a los 1000 deja de funcionar el script, o sabes de que otra forma puedo hacer esto? gracias por tu atencion
  12. Pues no estoy muy seguro, pero he probado con varios argumentos y nada sigue compartiendo los stats con todos, y la verdad no se que poner para que solo le de stats a quien disparo, rayos esto si que es complicado que otra cosa se podria hacer? addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 22 then givePlayerMoney(killer,10) setPedStat (killer, 69, getPedStat(killer,69)+1) if (tonumber(getPedStat( killer, 69 )) == 999) then outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Pistola", killer, 255, 255, 255, true) end end end)
  13. Gracias Tomas por responder, es que son muy nuevo en esto de lua pero he usado tu consejo y funciono bien, pero sigue dando stats a todos en el server, cres que me podrias ayudar con eso? espero que si y gracias por la respuesta
  14. Hola buen dia, bueno quisiera que me ayudaran con un scipr que estoy haciendo para que te de habilidad con el arma con la que mataste al zombies, es decir si matas a un zombie con una M4 te dara un punto en habilidad o stats, el problema es que si otro jugador tambien le da stats del arma usada sin que el mate ningun zombie es decir si yo mato zombie le da habilidad en el arma usada a todos en el server, cosa que no tiene que pasar ya busque varias forma de como arreglarlo pero nada mas no puedo, ademas de que tampoco conosco mucho de scripting y por eso les pido su ayuda, y una cosa mas si reinicio el resource o lo paro y lo cargo de nuevo se reinician todos los stats quisiera ver si tambien me pueden ayudar con eso. bueno espero me ayuden y muchas gracias por su atencion a qui el codigo todo esto lo puse en server-side local stat22 = 0 local stat23 = 0 local stat24 = 0 local stat25 = 0 local stat26 = 0 local stat27 = 0 local stat28 = 0 local stat29 = 0 local stat30 = 0 local stat31 = 0 local stat34 = 0 ------------ Pistola addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 22 then givePlayerMoney(killer,10) setPedStat (killer, 69, stat22) stat22 = stat22 + 1 if (tonumber(getPedStat( killer, 69 )) == 999) then outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Pistola", killer, 255, 255, 255, true) end end end) ------------ Silenced addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 23 then givePlayerMoney(killer,10) setPedStat(killer, 70, stat23 ) stat23 = stat23 + 1 if (tonumber(getPedStat( killer, 70 )) == 999) then outputChatBox ( "#FFFF00#FFFF00Has conseguido la habilidad maxima en #FF0000Silenced", killer, 255, 255, 255, true) end end end) ------------ Desert Eagle addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 24 then givePlayerMoney(killer,10) setPedStat(killer, 71, stat24 ) stat24 = stat24 + 1 if (tonumber(getPedStat( killer, 71 )) == 999) then outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Desert Eagle", killer, 255, 255, 255, true) end end end) ------------ Escopeta addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 25 then givePlayerMoney(killer,10) setPedStat(killer, 72, stat25 ) stat25 = stat25 + 1 if (tonumber(getPedStat( killer, 72 )) == 999) then outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Escopeta", killer, 255, 255, 255, true) end end end) ----------- Escopeta recortada addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 26 then givePlayerMoney(killer,10) setPedStat(killer, 73, stat26 ) stat26 = stat26 + 1 if (tonumber(getPedStat( killer, 73 )) == 999) then outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Escopeta Recortada", killer, 255, 255, 255, true) end end end) ----------- Spaz-12 addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 27 then givePlayerMoney(killer,10) setPedStat(killer, 74, stat27 ) stat27 = stat27 + 1 if (tonumber(getPedStat( killer, 74 )) == 999) then outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Escopeta SPAZ-12", killer, 255, 255, 255, true) end end end) ----------- Uzi addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 28 then givePlayerMoney(killer,10) setPedStat(killer, 75, stat28 ) stat28 = stat28 + 1 if (tonumber(getPedStat( killer, 75 )) == 999) then outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Metralleta Uzi", killer, 255, 255, 255, true) end end end) ----------- MP5 addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 29 then givePlayerMoney(killer,10) setPedStat(killer, 76, stat29 ) stat29 = stat29 + 1 if (tonumber(getPedStat( killer, 76 )) == 999) then outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Metralleta MP5", killer, 255, 255, 255, true) end end end) ----------- AK-47 addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 30 then givePlayerMoney(killer,10) setPedStat(killer, 77, stat30 ) stat30 = stat30 + 1 if (tonumber(getPedStat( killer, 77 )) == 999) then outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Ametralladora AK-47", killer, 255, 255, 255, true) end end end) ----------- Ametralladora M4 addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 31 then givePlayerMoney(killer,10) setPedStat(killer, 78, stat31 ) stat31 = stat31 + 1 if (tonumber(getPedStat( killer, 78 )) == 999) then outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Ametralladora M4", killer, 255, 255, 255, true) end end end) ----------- Sniper addEvent("onZombieWasted",true) addEventHandler("onZombieWasted",root, function (killer, weapon) if weapon == 34 then givePlayerMoney(killer,10) setPedStat(killer, 80, stat34 ) stat34 = stat34 + 1 if (tonumber(getPedStat( killer, 79 )) == 999) then outputChatBox ( "#FFFF00Has conseguido la habilidad maxima en #FF0000Rifle de Francotirador", killer, 255, 255, 255, true) end end end) ------------- Seccion que hace que se guarden los stats -------------------------- function saveWeaponStats(player) if (not player or not isElement(player)) then return end local account = getPlayerAccount(player) if (account and not isGuestAccount(account)) then local stats = "" for stat=69, 79 do local value = getPedStat(player, stat) stats = stats ..",".. stat ..";".. value end setAccountData(account, "weaponStats", stats) end end addEventHandler("onPlayerQuit",root,function () saveWeaponStats(source) end) function loadWeaponStats(player) if (not player or not isElement(player)) then return end local account = getPlayerAccount(player) if (account and not isGuestAccount(account)) then local statsData = getAccountData(account,"weaponStats") local stats = split(statsData, ",") for k, v in ipairs(stats) do local stat = split(v, ";") setPedStat(player, tonumber(stat[1]), tonumber(stat[2])) end end end addEventHandler("onPlayerLogin",root,function () loadWeaponStats(source) end)
×
×
  • Create New...