Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 27/10/20 in all areas

  1. You are not stupid, it might be too complex to begin with. This is called the element tree: https://wiki.multitheftauto.com/wiki/Element_tree And as you know, tree's do start with the root element. (With this tree, there is a single root, yea I know that is strange...) Under this (inverted) tree you can see it is branching in to different other elements. This is how MTA organize it's elements. resourceRoot is the start of a single resource. Under the resourceRoot, you can see 1 resourceDynamicElementRoot. (This is where all your elements created by script are childs of) There are also resourceMapRootElement(s). Each element represents a map element, created by a .map file. Knowing all this and look at this representation of your resource (based on the code above): Serverside <resource id="your-resource"> <!-- resourceRoot --> <map id="dynamic"> <!-- resourceDynamicElementRoot --> </map> </resource> Clientside <resource id="your-resource"> <!-- (serverside) resourceRoot --> <map id="dynamic"> <!-- (serverside) resourceDynamicElementRoot --> <!-- START clientside --> <vehicleBlipRoot> <blip/> <blip/> <blip/> </vehicleBlipRoot> <!-- END clientside --> </map> <!-- (serverside) --> </resource> <!-- (serverside) --> As I said before, clientside has access to all serverside elements. But serverside has no access/isn't ware of clientside elements. You want to destroy client elements with serverside, but serverside is not ware that they exist. With the following element structure you can solve that: <resource id="your-resource"> <map id="dynamic"> <vehicleBlipRoot> <blipServerSide> <!-- START clientside --> <blip/> <!-- END clientside --> </blipServerSide> <blipServerSide> <!-- START clientside --> <blip/> <!-- END clientside --> </blipServerSide> <blipServerSide> <!-- START clientside --> <blip/> <!-- END clientside --> </blipServerSide> </vehicleBlipRoot> </map> </resource> If you delete blipServerSide, with the function destroyElement, then the blip clientside will also be deleted. This is happening because when you call the destroyElement function on serverside, the same function will be called on clientside on the same element (behind the scenes). And thx to propagation (already enabled) the function will also be called for all the children of the element that is about to be destroyed, which is in this case the client element blip. I can't explain it better than this.
    2 points
  2. Exactly, that is why I gave you an example of how to do that, don't waste it. Since you still do not understand it, this is my last attempt to show you how you can delete clientside elements by also using a serverside element. If you still don't understand it, then that is unfortunately. Serverside local playerBlipElementContainerElement = createElement("playerBlipElementContainer", "playerBlipElementContainer:24436dg45632Ddfg") addEventHandler("onPlayerJoin", root, function () local serverSideElement = createElement("playerBlipElement_serverSide") setElementData(serverSideElement, "owner", source) setElementParent(serverSideElement, playerBlipElementContainerElement) end) --[[ -- Players already ingame addEventHandler("onClientResourceStart"... getElementsByType("player") ... ]] Clientside local playerBlipElementContainerElement = getElementByID("playerBlipElementContainer:24436dg45632Ddfg") ------------------- -- MODIFY THIS, for players already ingame (add a little delay) and for new players (onClientPlayerJoin + add a little delay) local serverSideElements = getElementChildren(playerBlipElementContainerElement) for i=1, #serverSideElements do local serverSideElement = serverSideElements[i] local owner = getElementData(serverSideElement, "owner") local blip = createBlipAttachedTo(owner, 0, 1, 150, 150, 150, 255, 1) setElementParent(blip, serverSideElement) end
    1 point
  3. Server created elements are available clientside. Client created elements are NOT available on serverside. But there is 1 trick you can use to delete clientside elements by serverside. Start the following example when you are not downloading other resources, clientside must have been started before 10 seconds. Server local serverSideElement = createElement("exampleElement", "id:3563454hasduy3685dsfs") setTimer(function () -- destroy the element over 10 seconds destroyElement(serverSideElement) end, 10000, 1) Client local clientSideElement = createElement("exampleExample") -- get the serverside element local serverSideElement = getElementByID("id:3563454hasduy3685dsfs") if isElement(serverSideElement) then setElementParent(clientSideElement, serverSideElement) -- set the clientside element as child of the serverside element end addEventHandler("onClientElementDestroy", clientSideElement, function () iprint("onClientElementDestroy") end, false) *** Fixed the wrong ID value.
    1 point
  4. Server local pedParentElement = createElement("pedParent", "pedParent-323536") ---------------- local ped1 = createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) local ped2 = createPed ( 120, 5550.6654, 1020.55122, 1240.545 ) local ped3 = createPed ( 120, 5560.6654, 1020.55122, 1240.545 ) setElementParent(ped1, pedParentElement) setElementParent(ped2, pedParentElement) setElementParent(ped3, pedParentElement) Client addEventHandler("onClientPedDamage", getElementByID("pedParent-323536"), function() cancelEvent() end )
    1 point
  5. local class = { --class name, hp, armor, skin, { {weapon id, weapon ammo} } {"Juggernaut", 100, 100, 0,{ {30,200},{24,50}, {34,10} } }, }
    1 point
  6. you must fit the above value within your function, understand? I just gave you an example so you can get a sense of what to do ...
    0 points
×
×
  • Create New...