Search the Community
Showing results for tags 'pickup'.
-
I need help from you guys, I'm doing a script to drop moneyfrom pedestrians, but I can't. --[[ Triggers whenever a ped is killed ]]-- function killedPed(totalAmmo, killer, killerWeapon, bodypart, stealth, npc) -- Get profitability multiplier local probability_of_richness = math.random(1,1000) if probability_of_richness < 900 then probability_of_richness = 1 elseif probability_of_richness < 975 then probability_of_richness = 3 elseif probability_of_richness < 999 then probability_of_richness = 10 else probability_of_richness = 100 end -- Create a money pickup at the position of the dead bot local x,y,z = getElementPosition(source) npc[killer] = math.random(1,40)*probability_of_richness -- Max profit: $4´000 -- Make the pickup and make sure it's removed after 2 minutes if not picked up local pickup = createPickup(x, y, z, 3, 1212, 120000, npc[killer]) if pickup then setTimer(destroyMinutePickup, 120*1000, 1, pickup) addEventHandler("onPickupHit", pickup, givePickupMoney) end end addEventHandler("onPedWasted", root, killedPed) --[[ Destroy the pickup after given time ]]-- function destroyMinutePickup(pickup) if isElement(pickup) then removeEventHandler("onPickupHit", pickup, givePickupMoney) destroyElement(pickup) end end --[[ Make the robber wanted on money pickup ]]-- function givePickupMoney(plr) if not npc[plr] then npc[plr] = math.random(1,50) end removeEventHandler("onPickupHit", source, givePickupMoney) destroyElement(source) givePlayerMoney(plr, npc[plr]) -- Get wanted for stealing money setWl(source, round(wanted_level, 2), 10, "Você cometeu o crime de roubo") end
-
Hi! Can i off pickup sound when player get it?
-
I'm trying to create a custom pickup which gets destroyed when a player touches it, and respawns after 5 seconds I've created the custom pickup using "createPickup", and also placed a colSphere (using "createColSphere") at the same position. When the player hits the pickup for the first time, it disappears and respawns successfully 5 seconds later. However, after it has respawned once, it won't destroy again when you touch it. My code is below. local x = 3985.1799316406 local y = -1973.4870605469 local z = 27.812973022461 pickup = createPickup(x, y, z, 3, 1242) -- create custom pickup pickupCol = createColSphere ( x, y, z, 1) -- create colSphere for pickup function removePickup() destroyElement(pickup) -- destroy pickup destroyElement(pickupCol) -- destroy pickup colsphere setTimer(function() pickup = createPickup(x, y, z, 3, 1242) pickupCol = createColSphere ( x, y, z, 1) end, 5000, 1) -- spawn new pickup and colsphere after 5 seconds end addEventHandler ( "onColShapeHit", pickupCol, removePickup ) Any thoughts? edit: I did try using the respawnTime argument on createPickup, for 5 seconds, but it didn't have any effect, which is why I'm trying to do it this way. No errors returning either.