itHyperoX Posted March 27, 2017 Share Posted March 27, 2017 (edited) Hello guys. I wanna make an "airdrop" script, i think this is very easy, i just dont know what should i use for this. The idea: When the resource start,or the next "timer" start the script pick a random position from table, and starting dropping down the "object". When the object is on the ground, its creating marker or anything, (onPlayerHit) then give the player weapons, and ammos. Can anybody give me any tip, what should i use for this? Which functions Edited March 27, 2017 by TheMOG 1 Link to comment
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 I think you could use some nicer things tho. Maybe create some objects, attach them together (so you can move them easily, with moveObject). You'll have to set up some positions early on, or you could just get a random player call a function near to him to get the ground's height. (If you want to do it this way, feel free to ask here, I'll help about it.) Back to the easy part. Creating an object and moving it on server side is easy. After that, you could use a marker, or a nicer way would be onElementClicked on client side. Again, feel free to choose, and respond here, so we can help about it. 2 Link to comment
itHyperoX Posted March 27, 2017 Author Share Posted March 27, 2017 hmm.. I'm stuck here, its always saying "Hit" and destroying everything when the resource start. local objectID = 964 --< The object ID >-- local Dx, Dy, Dz = 1348.4276123047, 1333.0045166016, 23.620292663574 --< Starting Position >-- local rotX, rotY, rotZ = 0, 0, 90 --< Rotation >-- local Ex, Ey, Ez = 1348.4276123047, 1333.0045166016, 9.8 --< Ending Position >-- local Speed = 15000 --< Speed >-- local markerSize = 2 local object = createObject(objectID, Dx, Dy, Dz, rotX, rotY, rotZ) --< Creating the object >-- local arrowMarker = createMarker(0,0,0, "cylinder",markerSize, 255, 0, 0, 170 ) --< Creating the marker because attaching >-- attachElements(arrowMarker,object, 0, 0, 2 ) -- < Attach... >-- function dropTHIS() moveObject(object, Speed, Ex, Ey, Ez) setElementDoubleSided(object,true) end addEventHandler("onResourceStart",root,dropTHIS) function hitT(hitElement) destroyElement(arrowMarker) destroyElement(object) outputChatBox("Hit") end addEventHandler("onMarkerHit",root,hitT) Link to comment
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 function hitT(hitElement) if source == arrowMarker and getElementType(hitElement) == "player" then destroyElement(arrowMarker) destroyElement(object) outputChatBox("Hit") end end addEventHandler("onMarkerHit",root,hitT) 1 Link to comment
itHyperoX Posted March 27, 2017 Author Share Posted March 27, 2017 Is that okey, when i hit the marker nothing happens, but when i'm jump into the marker then destroying? Link to comment
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 Try putting the marker lower. 1 Link to comment
itHyperoX Posted March 27, 2017 Author Share Posted March 27, 2017 im tried buddy nothing. Link to comment
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 Did you rewrite this line? attachElements(arrowMarker,object, 0, 0, 2 ) -- < Attach... >-- 1 Link to comment
itHyperoX Posted March 27, 2017 Author Share Posted March 27, 2017 (edited) yes ofcurse, not destroying when im just run in to marker, but when i'm on the "box" (object) then destroying Edited March 27, 2017 by TheMOG Link to comment
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 Can you copy that line for me please? Did you try changing the marker size? 1 Link to comment
itHyperoX Posted March 27, 2017 Author Share Posted March 27, 2017 (edited) local markerSize = 2.4 local object = createObject(objectID, Dx, Dy, Dz, rotX, rotY, rotZ) --< Creating the object >-- setElementDoubleSided(object,true) local arrowMarker = createMarker(0,0,0, "cylinder",markerSize, 255, 0, 0, 170 ) --< Creating the marker because attaching >-- attachElements(arrowMarker,object, 0, 0, 0, 0, 0, 0) -- < Attach... >-- now this looks like the ration is fine Edited March 27, 2017 by TheMOG Link to comment
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 Make the markerSize bigger, I think the marker is inside the object, so the hit is not registered. Can you hit the marker now, or it's only possible if you jump up on top of the object? 1 Link to comment
itHyperoX Posted March 27, 2017 Author Share Posted March 27, 2017 Its not working. I tried to move the marker away like + x ,y ,z ,tried to make marker bigger but not. But when i'm jump on it then working Link to comment
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 I'm gonna give it a shot, wait a sec. Actually if you remove the attachElements line, it works fine. 2 Link to comment
itHyperoX Posted March 27, 2017 Author Share Posted March 27, 2017 (edited) if i'm remove that, there is no marker Edited March 27, 2017 by TheMOG Link to comment
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 Create the marker on the end coordinates. 1 Link to comment
itHyperoX Posted March 27, 2017 Author Share Posted March 27, 2017 i want make that, when the box on the ground only then destroy the box, not when the resource start, because what you said, it creating the marker when resource start. I want that when the box on the ground and the player hit the marker destroy Link to comment
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 (edited) You can just check the boxes position, and if it's at its end location, then destroy it. Edited March 27, 2017 by NeXuS™ 1 Link to comment
itHyperoX Posted March 27, 2017 Author Share Posted March 27, 2017 I think you dont understand what i want to do. Anyway thanks your help. Link to comment
NeXuS™ Posted March 27, 2017 Share Posted March 27, 2017 Try posting it in the Hungarian section, maybe you can express yourself better there. 1 Link to comment
itHyperoX Posted March 27, 2017 Author Share Posted March 27, 2017 (edited) I need a little help again. So i want make more positions, how can i add that? Because if i just add random positions with random ending positions, its can be so bad because of the object. i wondering something like this: local table = { local table = { --ID, StartingPOS, ENDINGPOS [0] = { "6556,411,60", "6556,411,40",}, [1] = {"445,31,502", "445,31,480""}, } And picking the random position by id, and it going good all the time because the positions is the same, only the Z cordinata changing So i want to add more starting positions and ending positions, but this can NOT work with random, because of the object ground.. Anybody please give me any tip how can i add more positions? I hope anyone understand what i want to do. Here is the code local objectID = 964 --< The object ID >-- local Dx, Dy, Dz = 2640.75390625, 805.8369140625, 469.8203125 --< Starting Position >-- local rotX, rotY, rotZ = 0, 0, 90 --< Rotation >-- local Ex, Ey, Ez = 2640.75390625, 805.8369140625, 5.3157968521118 --< Ending Position >-- local Speed = 9*100000 --< Speed >-- function dropTHIS() object = createObject(objectID, Dx, Dy, Dz, rotX, rotY, rotZ) --< Creating the object >-- moveObject(object, Speed, Ex, Ey, Ez) setElementDoubleSided(object,true) setTimer(function() outputChatBox("The airdrop is on the ground in about 5 minutes!",root,255,255,255,true) end,3*100000,1) setTimer(function() arrowMarker = createMarker(1348.4276123047, 1333.0045166016,9.8,"cylinder",2, 255, 0, 0, 170 ) --< Creating the marker because attaching >-- end,9*100000,1) end addEventHandler("onResourceStart",root,dropTHIS) setTimer(function() dropTHIS() end,43200000,1) --< 12 hours each drop >-- function hitT(hitElement) local timeTO = 12*100000 --< 2 minutes >-- if source == arrowMarker and getElementType(hitElement) == "player" then destroyElement(arrowMarker) setElementFrozen(hitElement, true) setPedAnimation(hitElement , "rob_bank", "cat_safe_rob", timeTO, true, true, true, false) setTimer(setElementFrozen,timeTO,1,hitElement,false) setTimer(function() destroyElement(object) outputChatBox("Hit") giveWeapon(hitElement,24,math.random(20,60)) giveWeapon(hitElement,26,math.random(40,120)) giveWeapon(hitElement,math.random(30,31),math.random(200,500)) giveWeapon(hitElement,math.random(33,34),math.random(20,150)) giveWeapon(hitElement,math.random(35,38),math.random(25,200)) end,timeTO,1) end end addEventHandler("onMarkerHit",root,hitT) Edited March 27, 2017 by TheMOG Link to comment
NeXuS™ Posted March 28, 2017 Share Posted March 28, 2017 local posTable = { {{6556, 411, 60}, {6556, 411, 40}}, {{445, 31, 502}, {445, 31, 480}} } And then function dropTHIS() local rTable = posTable[math.random(#posTable)] spawnX, spawnY, spawnZ = unpack(rTable[1]) endX, endY, endZ = unpack(rTable[2]) object = createObject(objectID, spawnX, spawnY, spawnZ, rotX, rotY, rotZ) --< Creating the object >-- moveObject(object, Speed, endX, endY, endZ) setElementDoubleSided(object,true) setTimer(function() outputChatBox("The airdrop is on the ground in about 5 minutes!",root,255,255,255,true) end,3*100000,1) setTimer(function() arrowMarker = createMarker(1348.4276123047, 1333.0045166016,9.8,"cylinder",2, 255, 0, 0, 170 ) --< Creating the marker because attaching >-- end,9*100000,1) end addEventHandler("onResourceStart",root,dropTHIS) Link to comment
itHyperoX Posted March 28, 2017 Author Share Posted March 28, 2017 Thank you Nexus. One and last question. How can i make that, if the airdrop is down, then not starting the new one? I tried with setElementData, getElementData but i always got debugerror. Expected element at argument 1 Here is how i did function dropTHIS() local rTable = posTable[math.random(#posTable)] spawnX, spawnY, spawnZ = unpack(rTable[1]) endX, endY, endZ = unpack(rTable[2]) object = createObject(objectID, spawnX, spawnY, spawnZ, rotX, rotY, rotZ) --< Creating the object >-- moveObject(object, Speed, endX, endY, endZ) setElementDoubleSided(object,true) thisblip = createBlip(endX, endY, endZ,40) setTimer(function() outputChatBox("The airdrop is on the ground in about 5 minutes!",root,255,255,255,true) end,3*100,1) setTimer(function() arrowMarker = createMarker(endX, endY, endZ,"cylinder",2, 255, 0, 0, 170 ) setElementData(root,"AirDropDown",true) -- Trying to set the data, the object is on the ground end,9*100,1) end addEventHandler("onResourceStart",root,dropTHIS) setTimer(function() if getElementData(root,"AirdropDown") == true then return end -- Trying to get the data, if is on the ground cancel the drop. local players = getPlayerCount() if tonumber(players) > 0 then -- 0 = 1 dropTHIS() else outputChatBox("players",root,255,255,255,true) return end end,20000,0) Link to comment
NeXuS™ Posted March 28, 2017 Share Posted March 28, 2017 setTimer(function() if isElement(object) then return end -- Trying to get the data, if is on the ground cancel the drop. local players = getPlayerCount() if tonumber(players) > 0 then -- 0 = 1 dropTHIS() else outputChatBox("players",root,255,255,255,true) return end end,20000,0) And just remove the setElementData line. (Nr. 18) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now