Jump to content

Chainsaw

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by Chainsaw

  1. Cuando se compraban items online qué pasaba si al mismo tiempo estabas conectado en el servidor mirando el inventario? tengo ciertas dudas sobre eso acá en mta porque no he visto nada referente a sockets.
  2. really you did DDoS attacks? In SA: MP can do that freely, I'm really happy which MTA Team ban people for this
  3. with "?" you mean for ternaries? you could "simulate" operators
  4. Sorry, I still do not get used to the aesthetics of language change DestroyElement to destroyElement and change getElementID for getVehicleName (this vehicles not have id default)
  5. addEventHandler("onVehicleExplode", getRootElement(), function () if(not vehicleIsStatic(source)) then -- Not is vehicle from map outputChatBox("The vehicle ID: " .. getElementID(source) .. " was destroyed"); DestroyElement(source) end end)
  6. well, i did a test code: addCommandHandler("v", function(player, command) local v = getPedOccupiedVehicle(player); if (v) then local n = (not vehicleIsStatic(v)) and ("player") or ("map"); outputChatBox("This vehicle is from " .. n) else outputChatBox("you are't in a vehicle") end end) function vehicleIsStatic(element) if(getElementType(element) == "vehicle") then local tag = getElementID(element); if(tag and (string.find(tag, "server_"))) then return 1; end end end And yes, server-side! do not forget which this works with tag
  7. addCommandHandler("test", function(player, command) local v = getPedOccupiedVehicle(player); if (v) then outputChatBox("This vehicle is from " .. (vehicleIsStatic(v)) and "map" or "player", player) end end) function vehicleIsStatic(element) if(getElementType(element) == "vehicle") then local tag = getElementID(element); if(tag and (string.find(tag, "server_"))) then return 1; end end end
  8. In your .map vehicles you have something like: <vehicle id="vehicle (Buffalo) (3)" paintjob="3" interior="0" alpha="160" model="405" plate="INT6 8C7" dimension="0" posX="1802.0996" posY="-1932.990" posZ="13.2" rotX="0" rotY="0" rotZ="0" color="45,58,53,159,157,148,0,0,0,0,0,0"></vehicle> Change to <vehicle id="server_vehicle (Buffalo) (3)" paintjob="3" interior="0" alpha="160" model="405" plate="INT6 8C7" dimension="0" posX="1802.0996" posY="-1932.990" posZ="13.2" rotX="0" rotY="0" rotZ="0" color="45,58,53,159,157,148,0,0,0,0,0,0"></vehicle> and in the script function vehicleIsStatic(element) if(getElementType(element) == "vehicle") local tag = ''; if(tag = getElementID(element)) if(string.find(tag, "server_")) return 1; end end end end if that function return 1 the vehicle from map This is a form that I can think of, I do not know if there is an official way
  9. I imagine you can do this by setting variables when creating a vehicle, another way I can think of is to assign a tag following the ID in a specific way to the map vehicles and then get the string from getElementID Example: id="Uranus 5" to id="server_Uranus 5" and check if the vehicle belongs to map with string.find
  10. I doubt that it is hate. This is the line of everything, I know that there are people who still want to give life to XP but that is very subjective .. If we talk about objectivity XP takes the same course as everything you need to get rid of your old structures, really is very hard for you go to Win 7?
  11. Actualice el recurso, la función dateToUnix tenía un bug en la conversión de tiempo ______________________ Por cierto, lo que está en la imagen de presentación del tema se puede lograr así: local time = getRealTime(); local day, month, year = time.monthday, time.month + 1, time.year + 1900; for i=1,getRemaningDaysInYear(day, month, year) do local d, m, y = getDateInAdd(day, month, year, i, 0, 0) outputServerLog(string.format("In +%i days will be: %s %i, %i (%s)", i, getMonthName(m), d, y, getWeekDay(d, m, y))) end Dicho script te dirá qué día de la semana serán todos los días del año que restan según el año en que estés
  12. Introducción Este recurso es una ayuda a los programadores que busquen tener un control más amplio del tiempo! Funciones: getWeekDay getMonthDays getMonthName getYearDays getRemaningDaysInYear getSpentsDaysInYear dateToUnix unixToDate getDateInAdd Ejemplos string getWeekDay(day, month, year) Permite obtener qué día de la semana es la fecha específicada (Su funcionamiento es puramente matemático, para conocer más sobre su funcionamiento https://en.wikipedia.org/wiki/Zeller's_congruence) outputchatBox(getWeekDay(13, 11, 2016)); -- output: Domingo int getMonthDays(month, year) Obtiene la cantidad de días de cierto mes tomando en cuenta los años biciestos (razón por la cual es obligatorio el argumento) local days = getMonthDays(2, 2016) -- Año biciesto -- days contains: 29, local days = getMonthDays(2, 2017) -- Año normal -- days contains: 28, string getMonthName(month) Obtiene el nombre del mes especificado local n = getMonthName(11) -- n contains: Noviembre int getYearDays(year) Obtiene la cantidad de días del año especificado incluyendo los días al ser año biciesto local n = getYearDays(2016) -- n contains: 366 local n = getYearDays(2015) -- n contains: 365 int getRemaningDaysInYear(day, month, year) Obtiene la cantidad de días que faltan en el año según los datos especificados local n = getRemaningDaysInYear(13, 11, 2016) -- n contains: 48 int getSpentsDaysInYear(day, month, year) Obtiene la cantidad de días que han pasado en el año según los datos especificados local n = getSpentsDaysInYear(13, 11, 2016) -- n contains: 318 int dateToUnix(day, month, year) Convierte el día, año y mes al tiempo unix para tener un mayor control de éste mediante el unixtime (https://es.wikipedia.org/wiki/Tiempo_Unix) local time = dateToUnix(13, 11, 2016) -- time contains: 1512864000 int, int, int unixToDate(unixtime) Convierte el unixtime a datos leibles local day, month, year = unixToDate(1512864000); --- days, mounth, year contains: 13, 11, 2016 int, int, int getDateInAdd(_day, _month, _year, days, months, years) Añade días a una fecha especificada y obtiene la fecha con los días, meses y años añadidos siguendo el formato del calendario (añades 20 días siendo 12 de diciembre de 2016 te dará) 1, enero 2017 sin alterar el orden local d, m, y = getDateInAdd(13, 11, 2016, 2, 0, 0); outputServerLog(getWeekDay(d, m, y)) -- output: Martes (15) ya que Domingo (13) meta.xml Todas las funciones pueden ser exportadas, para poner el resource en español configurar en el meta.xml <setting name="*Lang" value="[1]"/> -- Cambiar a <setting name="*Lang" value="[2]"/> Link de del recurso -> https://github.com/iZume/time-functions-LUA/archive/master.zip
  13. Chainsaw

    speaker

    Where do you want to spawn the object?
  14. Hello, i am new in this world.. But i believe i can help you: Well, so i'll try explain some things.. as you do know MTA is client-server, so your need to make this system use both sides, why? playSound3D is a function a client side and your need access to that from the server side.. Example, this is a command in server side: addCommandHandler("play", function(player, cmd, ...) if(getElementData(player, "players:admin") == true) then if(getElementData(player, "playing") == true) then triggerClientEvent(root, "client:stopSound", root); setElementData(player, "playing", false); outputChatBox("Sound stopped!", player); else local url = table.concat({...}, " "); local x, y, z = getElementPosition(player); triggerClientEvent(root, "client:playSound", root, x, y, z, url); setElementData(player, "playing", true); outputChatBox("You're listening: " .. url, player); end end end); and put this in client-side addEvent("client:playSound", true) addEventHandler("client:playSound", root, function (x, y, z, ...) local url = table.concat({...}, " "); clientSpeaker = playSound3D(url, x, y, z); end) addEvent("client:stopSound", true) addEventHandler("client:stopSound", root, function () stopSound(clientSpeaker) end) you only need change getElementData(player, "players:admin") for your admin variable or change for your function, etc.. if you have any question, do it.
  15. Se me ocurre que puedes hacerlo obteniendo las coordenadas cartesianas X, Y obteniendo de éstas el máximo y el mínimo y luego comprobar si está en dicha área con algo como esto: if(X >= MinX && X <= MaxX && Y >= MinY && Y <= MaxY) Sacarías el MinX, MaxX, MinY, MaxY basándote en esta imagen:
  16. Sí, lo hice yo. Conozco otros lenguajes de programación y soy totalmente nuevo en LUA por lo que no sé si el código sea lo más optimo a lo que se puede llegar en LUA, me gustaría saber si el código lo es, a ver si alguien me dice algo que pueda mejorar!
  17. Introducción Es un script muy básico de lado del server que consiste en enviar al jugador al hospital más cercano al morir, la función busca en una tabla de datos flotantes la posición del hospital más cercano del jugador cuando éste muere. El script busca el ID y posteriormente utiliza otra función para obtener las coordenadas de dicho hospital ID. Codigo -- <script name="Near hospital spawn"> hospitalsTable = { {-318.8799, 1049.2433, 20.3403, 0.0000}, {1172.8372, -1325.3186, 15.4000, 270.0000}, {-2655.1240, 638.6232, 14.4531, 180.0000}, {1241.6802, 326.4038, 19.7555, 335.0000}, {1607.4869, 1816.0693, 10.8203, 0.0000}, {2034.0670, -1402.6815, 17.2938, 180.0000}, } function spawnPlayerInHospital(player) local id = getHospitalCLosestID(player); local x, y, z, a = getHospitalCoords(id); fadeCamera(player, true, 0.5); spawnPlayer(player, x, y, z, a); end function getHospitalCLosestID(player) local s = -1; local temp1 = 99999.0; local temp2 = 0.0 local x,y,z = getElementPosition(player); for key,val in pairs(hospitalsTable) do temp2 = getDistanceBetweenPoints2D(x, y, val[1], val[2]); if(temp2 == false) then s = 1 break end if(temp1 > temp2) then temp1 = temp2 s = key end end return s end function getHospitalCoords(id) if (id == -1 or id <= table.getn(hospitalsTable)-1 or id >= table.getn(hospitalsTable)+1) then id = 1 end return hospitalsTable[id][1], hospitalsTable[id][2], hospitalsTable[id][3], hospitalsTable[id][4] end -- </script> Una vez añadido el script solamente faltaría agregarlo al evento deseado: addEventHandler("onPlayerWasted", root, function() fadeCamera(source, false, 1.0); setTimer(spawnPlayerInHospital, 2*1000, 1, source) end)
  18. Entiendo, eso me soluciona muchas dudas.. Y otra cosa, tengo esto: addEvent("onZombieWasted",true) addEventHandler("onZombieWasted", root, function(killer, weapon) outputChatBox ("Skin del asesino: " .. getElementModel(killer), killer, 255, 255, 255, true) end) Estoy haciendo algunas pruebas, aprendiendo como funcionan los parámetros de las funciones en los eventos y tengo duda en lo siguiente: onZombieWasted tiene el trigger triggerEvent ( "onZombieWasted", source, attacker, weapon, bodypart ) y por lo que veo tiene 4 parámetros, ahora cuando uso addEventHandler para agregar una función al evento (supongo que así se dice) agrego nada más en la función los parámetros killer y weapon.. cómo puedo obtener el userdata id (no sé qué tipo de datos sean pero espero que se entienda) para saber el skin del zombie al que maté desde ese Handler?
  19. Tengo una duda, soy nuevo acá y me gustaría saber como actualizar el dxDrawText, en el código que veo se crea otro sobre el que ya estaba (viendo el código a simple vista, puede que no sea así y lo esté mal interpretando) cómo actualizo el texto de un dxDrawText?
  20. wow, me sorprende ver cosas de Gantzyo acá (ex administrador de Pawnoscripting :o)
×
×
  • Create New...