Hero192 Posted August 2, 2015 Share Posted August 2, 2015 This part working fine , but the cmd works even if i didn't pick up the Pickup,how to check that, only the guy who picked up the pickup he who can use this cmd addCommandHandler("drop", function (player) if isElement(myBlip) then destroyElement(myBlip) end if isElement(deliveryBaseLV) then destroyElement(deliveryBaseLV) end if isElement(blip) then destroyElement(blip) end if isElement(deliveryBase) then destroyElement(deliveryBase) end if isElement(burger) then destroyElement(burger) end local x, y, z = getElementPosition ( player ) deliveryBase = createPickup ( x, y+3, z, 3, 1210, 200, 1 ) blip = createBlip(x, y+3, z, 37, 2, 255, 255, 255, 255, 0, 400) addEventHandler("onPickupHit", deliveryBase , goTake) end) function goTake(player) burger = createObject(1210,0,0,0) myBlip = createBlipAttachedTo ( burger, 37 ) exports.attacher:attachElementToBone(burger,player,12,0,0.1,0.3,0,180,0) if isElement(blip) then destroyElement(blip) end destroyElement(source) triggerClientEvent(player, "delivery:gotJob",player,pickupMallete) end Link to comment
Hero192 Posted August 2, 2015 Author Share Posted August 2, 2015 onPickupHit I already used that,I am doing a job when you hit the pickup you get an Element in your hand 2nd thing when you suicide the pickup be at your death position, all that is going fine.. What im trying to do, Only the guy who toke the pickup if he dead then the pickup will be at his position, if he didn't take the pickup then even if he dead the pickup won't be at his position. Link to comment
GTX Posted August 2, 2015 Share Posted August 2, 2015 Well, if you don't give the necessary part, I can't help you. And about your last post, I didn't get a word you said. Link to comment
Hero192 Posted August 2, 2015 Author Share Posted August 2, 2015 (edited) Currently when you do /kill the pickup will be at your place even if you didn't hit the main pickup(job) i want check if the player toke the main pickup (deliveryBaseLV) then he can drop the pickup on his death if he's not then he can't drop anything even if he dead.. local locations = { { 1463.80, 2823.78, 10.82}, { -1975.6, 1227.14, 31.83 }, { -2285.64, -12.7, 35.53 }, { -2147.59, -139.86, 36.73 }, { -2035.11, -43.72, 35.65 }, { -2120.84, -4.27, 35.53 }, { -2053.64, 82.59, 28.6 }, { -1917.56, 82.59, 28.6 }, { -1481, 686.4, 1.32 } } local pos = locations[math.random(#locations)] local x,y,z = unpack ( pos ) deliveryBaseLV = createPickup(x, y, z, 3, 1210, 222, 1) blip = createBlip(x, y, z, 37, 2, 255, 255, 255, 255, 0, 400) function pickupMallete(player) setElementData(player, "havePickup", true) burger = createObject(1210,0,0,0) myBlip = createBlipAttachedTo ( burger, 37 ) exports.attacher:attachElementToBone(burger,player,12,0,0.1,0.3,0,180,0) if isElement(blip) then destroyElement(blip) end if isElement(deliveryBaseLV) then destroyElement(deliveryBaseLV) end triggerClientEvent(player, "delivery:gotJob",player,pickupMallete) end addEventHandler ( "onPickupHit", deliveryBaseLV , pickupMallete ) local reward = math.random (2999,5300) function deliveryDoneJob() if isElement(burger) then destroyElement(burger) end if isElement(myBlip) then destroyElement(myBlip) end setElementData(source, "reward", reward) givePlayerMoney(source,reward) outputChatBox("You deliveryed the briefcase succesfully,Here's your reward: " ..reward.."$ well done!",source,0,255,231) setElementData(source, "havePickup", false) end addEvent("delivery:doneJob", true) addEventHandler("delivery:doneJob", root, deliveryDoneJob) function pickupthit(player) if getElementData(source, "havePickup") ~= true then return end if isElement(myBlip) then destroyElement(myBlip) end if isElement(deliveryBaseLV) then destroyElement(deliveryBaseLV) end if isElement(blip) then destroyElement(blip) end if isElement(deliveryBase) then destroyElement(deliveryBase) end if isElement(burger) then destroyElement(burger) end local x, y, z = getElementPosition ( source ) deliveryBase = createPickup ( x, y, z, 3, 1210, 200, 1 ) blip = createBlip(x, y, z, 37, 2, 255, 255, 255, 255, 0, 400) addEventHandler("onPickupHit", deliveryBase , goTake) end addEventHandler( "onPlayerWasted", root,pickupthit) function goTake(player) burger = createObject(1210,0,0,0) myBlip = createBlipAttachedTo ( burger, 37 ) exports.attacher:attachElementToBone(burger,player,12,0,0.1,0.3,0,180,0) if isElement(blip) then destroyElement(blip) end destroyElement(source) triggerClientEvent(player, "delivery:gotJob",player,pickupMallete) end end Edited August 2, 2015 by Guest Link to comment
GTX Posted August 2, 2015 Share Posted August 2, 2015 Your code is such a mess. I won't even bother tabulating it. local locations = { { 1463.80, 2823.78, 10.82}, { -1975.6, 1227.14, 31.83 }, { -2285.64, -12.7, 35.53 }, { -2147.59, -139.86, 36.73 }, { -2035.11, -43.72, 35.65 }, { -2120.84, -4.27, 35.53 }, { -2053.64, 82.59, 28.6 }, { -1917.56, 82.59, 28.6 }, { -1481, 686.4, 1.32 } } local pos = locations[math.random(#locations)] local x,y,z = unpack ( pos ) deliveryBaseLV = createPickup(x, y, z, 3, 1210, 222, 1) blip = createBlip(x, y, z, 37, 2, 255, 255, 255, 255, 0, 400) function pickupMallete(player) setElementData(player, "havePickup", true) burger = createObject(1210,0,0,0) myBlip = createBlipAttachedTo ( burger, 37 ) exports.attacher:attachElementToBone(burger,player,12,0,0.1,0.3,0,180,0) if isElement(blip) then destroyElement(blip) end if isElement(deliveryBaseLV) then destroyElement(deliveryBaseLV) end triggerClientEvent(player, "delivery:gotJob",player,pickupMallete) end addEventHandler ( "onPickupHit", deliveryBaseLV , pickupMallete ) local reward = math.random (2999,5300) function deliveryDoneJob() if isElement(burger) then destroyElement(burger) end if isElement(myBlip) then destroyElement(myBlip) end setElementData(source, "reward", reward) givePlayerMoney(source,reward) outputChatBox("You deliveryed the briefcase succesfully,Here's your reward: " ..reward.."$ well done!",source,0,255,231) setElementData(source, "havePickup", false) end addEvent("delivery:doneJob", true) addEventHandler("delivery:doneJob", root, deliveryDoneJob) function pickupthit(player) if getElementData(source, "havePickup") ~= true then return end if isElement(myBlip) then destroyElement(myBlip) end if isElement(deliveryBaseLV) then destroyElement(deliveryBaseLV) end if isElement(blip) then destroyElement(blip) end if isElement(deliveryBase) then destroyElement(deliveryBase) end if isElement(burger) then destroyElement(burger) end local x, y, z = getElementPosition ( source ) deliveryBase = createPickup ( x, y, z, 3, 1210, 200, 1 ) blip = createBlip(x, y, z, 37, 2, 255, 255, 255, 255, 0, 400) addEventHandler("onPickupHit", deliveryBase , goTake) end addEventHandler( "onPlayerWasted", root,pickupthit) function goTake(player) burger = createObject(1210,0,0,0) myBlip = createBlipAttachedTo ( burger, 37 ) exports.attacher:attachElementToBone(burger,player,12,0,0.1,0.3,0,180,0) if isElement(blip) then destroyElement(blip) end destroyElement(source) triggerClientEvent(player, "delivery:gotJob",player,pickupMallete) end Link to comment
Hero192 Posted August 2, 2015 Author Share Posted August 2, 2015 -Read what i just wrote Currently when you do /kill the pickup will be at your place even if you didn't hit the main pickup(job) i want check if the player toke the main pickup (deliveryBaseLV) then he can drop the pickup on his death if he's not then he can't drop anything even if he dead.. --It's the main pickup deliveryBaseLV = createPickup(x, y, z, 3, 1210, 222, 1) Link to comment
GTX Posted August 2, 2015 Share Posted August 2, 2015 Test what I gave you, don't create a new post... The code I gave you should do the job... If I understood you correctly... Link to comment
Hero192 Posted August 2, 2015 Author Share Posted August 2, 2015 Doesn't works it keep doing the same Link to comment
GTX Posted August 2, 2015 Share Posted August 2, 2015 Then I don't know, because I don't understand you. Maybe someone else will help you. 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