Jump to content

Salchy

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by Salchy

  1. De hecho, puede mandar el triggerServerEvent, sólamente con resourceRoot, y en server-side, en el addEventHandler, atacha el evento, al resourceRoot. Es una buena práctica en cuanto a seguridad, ya que sólo permitiría que el evento sea llamado desde el propio recurso. En caso de que el evento tenga que ser llamado de otro recurso, en el addEventHandler del lado server-side, puede atacharlo como root, y en client-side, seguir manteniendo el sourceElement como resourceRoot. En cuanto al código de Yisus: puedes usar el ejemplo de Alex, ya que sería un poco absurdo mandar un triggerServerEvent y como argumento pasarle un localPlayer, ya que existe la variable 'client' en server-side, que indica el cliente que llamó a triggerServerEvent.
  2. Hola, buenas noches. Vale, para analizar, estás añadiendo estos eventos de onMarkerHit, a todos los markers (root) -- Asignar la función tomarMarker al evento onMarkerHit addEventHandler("onMarkerHit", root, function(hitElement, matchingDimension) if isElement(marker) and source == marker and getElementType(hitElement) == "player" then tomarMarker(hitElement) end end) -- Asignar la función avisarPolicial al evento onMarkerHit addEventHandler("onMarkerHit", root, function(hitElement, matchingDimension) if isElement(marker) and source == marker and getElementType(hitElement) == "player" then avisarPolicial() end end) Esto es una mala practica, ya que sería más óptimo sólo 'atachar' ese evento sólamente al elemento que haga falta y que nos sea necesario, un cierto marker por ejemplo. Pero dejemos de lado esto. Estás verificando bien, que el source, sea el marker en cuestión, sin embargo, acá está la falla, en ningun momento se crea el marker ese del que hablamos. Podes hacer que el marker se cree al inicio del script (funcion que se ejecuta con el onResourceStart) y ahí mismo, añadir los addEventHandlers de tomarMarker() y avisarPolicial(), 'atachado' a ese marker recién creado.
  3. in Lua, the operator != is ~= if type(inv) ~= "table" then -- Something end
  4. so, you are saving a "string" value in that key. You should do a data type check. you could remaster the code, as it has some inconsistencies. Remember that the code is executed line by line, doing what we indicate, therefore, we must be logical and specific when programming. function deanimated( ammo, attacker, weapon, bodypart ) if (attacker) then if (getElementType ( attacker ) == "player") and (getElementType ( source ) == "ped") then if (getElementData (source, "zombie") == true) then local oldZcount = getElementData(attacker, "Zombie kills") or 0 -- get the value, if it has no value, by default, assign value 0 to the variable oldZcount if (type(oldZcount) ~= "number") then -- added to check the data type that is 'oldZcount', if different from number, (expected value) assign value 0 to the variable oldZcount oldZcount = 0 end setElementData(attacker, "Zombie kills", oldZcount + 1) triggerEvent("onZombieWasted", source, attacker, weapon, bodypart) end end end end it is not tested
  5. You can try it: local oldZcount = convertNumber(getElementData(attacker, "Zombie kills") or "0")
  6. Thanks a lot for your answers guys. Yes, the idea was to understand how it works and what those values are, to know what can be done with it. I see this opens up a world of immense possibilities, makes it much easier to do offset calculations. Thank you very much DiSaMe, I appreciate your time and your explanation, very clear. You can close the topic.
  7. Hello writers, good morning. I would like to know more about getElementMatrix, how does it work? What does it mean the data is what is returned to me? According to what I read on the wiki, it returns 4 'tables', with coordinates, but what does each of them mean? Might be interesting for more of an explanation on how matrices work in this game. We can take as an example, a vehicle. local vehicle = createVehicle(411, 1892, -2418, 13.5) setElementFrozen(vehicle, true) for k, v in pairs(getElementMatrix(vehicle)) do outputChatBox("index "..k.." = "..v[1]..", "..v[2]..", "..v[3]..", "..v[4]) end --[[ Return: index 1 = 1, -1.7484555314695e-07, 1.7484555314695e-07, 1 index 2 = 1.7484558156866e-07, 1, -1.7484555314695e-07, 1 index 3 = -1.7484552472524e-07, 1.7484558156866e-07, 1, 1 index 4 = 1892, -2418, 13.5, 1 ]] index 4 by deduction gives me the proper position of the vehicle, and what are the rest of the values? For more information, what I'm trying to do, is to always get the underbody of a vehicle. They told me that I could get it with this function, but without saying anything else. I'm doing math with getElementBoundingBox and getGroundPosition, but I can't get much of it right now, since my coords are getting out of phase when the vehicle is rotating. Perhaps with an explanation of what those values are, I can get closer to the result I'm looking for. Sorry for the bad grammar, I'm using google translate.
×
×
  • Create New...