Popular Content

Showing content with the highest reputation on 21/11/19 in all areas

  1. 1 point
    It starts with the addEventHandler, which is called in JavaScript the addEventListener. (might have been a better name) This attached handler is something that listens to events, as if it is a microphone which listens to everything you say. But there is a catch, the listener/handler does have a filter ability. It does only it's thing (calling the function attached to it, when all conditions are met. This makes sure that not every addEventHandler triggers for every event. The first filter moment is the eventName. "onPlayerJoinRoom" Only eventHandlers do trigger with the exact same event. The second filter moment is the baseElement. local baseElement = root triggerClientEvent(source, "onPlayerJoinRoom", baseElement, arg) local handlerElement = root addEvent("onPlayerJoinRoom", true) addEventHandler("onPlayerJoinRoom", handlerElement, function () end) Trigger "onPlayerJoinRoom" Rules - If the baseElement is the same as the handlerElement. OR - If the baseElement is an (indirect) child of the handlerElement. AND propagation enabled <root> <console/> <player dontRespawn="false"/> <player dontRespawn="false" lastSpawnarea=""/> <resource id="resourcebrowser"/> <resource id="assault"> <map id="dynamic"> <team/> <team/> <blip/> <marker/> <colshape/> <blip/> <blip/> </map> </resource> </root> Root parent > console child Root parent > player child Root parent > resource child Resource parent > map child Map parent > team child Map parent > marker child See element tree: https://wiki.multitheftauto.com/wiki/Element_tree Feedback Call the handler function
  2. 1 point
    Try this local respawnTime = 1000*60 addEventHandler("onPlayerWasted", getRootElement(), function() local theVehicle = getPedOccupiedVehicle(source) if theVehicle then removePedFromVehicle(source) setTimer(respawnPlayer,respawnTime,1,source,true) -- Here the player will respawn with a vehicle if he was in one return --Here we abort the function | The function that comes below won't be executed. end setTimer(respawnPlayer,respawnTime,1,source,false) -- Here the player will resapwn WITHOUT a vehicle end) function respawnPlayer(thePlayer,inVehicle) local x,y,z = 0,0,5 -- SET THE CORDINATES YOU WANT if inVehicle then spawnPlayer(thePlayer, x,y,z+5) -- We move the player a bit up to prevent collision with the vehicle local theVehicle = createVehicle(411,x,y,z) warpPedIntoVehicle(thePlayer,theVehicle) return --Here we abort the function | The function that comes below won't be executed. end spawnPlayer(thePlayer, x,y,z+3) --Here we don't move the player 5 points up (Just try) end Im not sure if this is what you want. As far as I understand, you want that: When a player dies, if he was in a vehicle then respawn it in a vehicle, otherwise not. Im using a similar system with it, however, to prevent the creation of a new vehicle im storing them into a table and when the player respawn (In the case that he was a vehicle, restore the vheicle by fixing it ...etc) Regards.
  3. 1 point
    I had thought of that, but the custom name tag still appears at the new location which led me to believe it wasn't a camera issue, I appreciate the thought though I did resolve my issue with my previous post, now the vehicle doesn't respawn until the player does which I figured was the best fix for it
  4. 1 point
    that because the camera follow the Vehicle you need unfollow the camera try the code if this work ... addEventHandler( "onPlayerWasted", getRootElement( ), function() setCameraMatrix(source,vector3(getElementPosition(source)),vector3(getElementPosition(source))) end )
  5. 1 point
    triggerEvent("onDestroyCurrentMap",arenaSrv.players,arg) TriggerEvent is not used to be send to players or to the server. It stays on the same side as it is triggered from. so yes, the same adjustment to the code: triggerEvent("onDestroyCurrentMap",resourceRoot,arg) In case of cross resource triggering: (two different resources) addEvent("onDestroyCurrentMap", true) addEventHandler("onDestroyCurrentMap", root, function () end, true --[[ << Enable propagation ]])
  6. 1 point
    You can also remove the ped from the vehicle even if he is not in a vehicle. The function will simply return false in that case. Not sure if that solves the whole issue. You could also re- set the player position with setElementPosition. But remember to disable the warp argument, else they become zombies 😆. https://wiki.multitheftauto.com/wiki/SetElementPosition
  7. 1 point
    Faça if condição then elseif condição then end Em vez de vários blocos de if's E também: verifique o parâmetro button para o clique com o botão esquerdo do mouse e se o state é 'down' para não chamar duas vezes a mesma ação.