Jump to content

[HELP] DESTROY WANTEDLEVEL


#RooTs

Recommended Posts

It is possible, create a colshape around the pickup, make it trigger whenever an elements hits it and get the vehiclecontroller to remove the wanted level from.

That's also a way to do it, the most simple solutions are always easy to forget about ;)

More I can not do this, can you help me and show an example?

Look at my earlier example and replace the object with a pickup, there is a colshape and an event handler in that one already.

Link to comment
  • Replies 63
  • Created
  • Last Reply

Top Posters In This Topic

All he's saying is to replace this ( from his earlier code )

star = createObject (1247, 653.35773, -1769.18567, 13.57368 ) 

to

star = createPickup(653.35773, -1769.18567, 13.57368, 3, 1239, 60000) -- I got some of this from what you posted earlier 

Link to comment

Just try this and tell me if the pickup destroys now

function onHit() 
setTimer(function() 
test = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 10000 ) 
addEventHandler("onPickupHit",test, 
function(player) 
if isPedInVehicle(player) then 
local vehicle = getPedOccupiedVehicle(player) 
setPlayerWantedLevel(getVehicleController(vehicle),getPlayerWantedLevel(getVehicleController(vehicle))-1) 
destroyElement(test) 
else 
setPlayerWantedLevel(player,getPlayerWantedLevel(player)-1) 
destroyElement(test) 
end 
end,60000,0) 
end) 
end 
addEventHandler("onResourceStart",resourceRoot, onHit) 

Link to comment
Just try this and tell me if the pickup destroys now
function onHit() 
setTimer(function() 
test = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 10000 ) 
addEventHandler("onPickupHit",test, 
function(player) 
if isPedInVehicle(player) then 
local vehicle = getPedOccupiedVehicle(player) 
setPlayerWantedLevel(getVehicleController(vehicle),getPlayerWantedLevel(getVehicleController(vehicle))-1) 
destroyElement(test) 
else 
setPlayerWantedLevel(player,getPlayerWantedLevel(player)-1) 
destroyElement(test) 
end 
end,60000,0) 
end) 
end 
addEventHandler("onResourceStart",resourceRoot, onHit) 

Don't destroy test, if you do it won't spawn again. Use usePickup instead.

function onHit() 
test = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 10000 ) 
addEventHandler("onPickupHit",test, 
function(player) 
if isPedInVehicle(player) then 
local vehicle = getPedOccupiedVehicle(player) 
usePickup ( test, player ) 
setPlayerWantedLevel(getVehicleController(vehicle),getPlayerWantedLevel(getVehicleController(vehicle))-1) 
else 
setPlayerWantedLevel(player,getPlayerWantedLevel(player)-1) 
usePickup ( test, player ) 
end 
end) 
end 
addEventHandler("onResourceStart",resourceRoot, onHit) 

Also, what is the point of having the timer :|

Link to comment

(Chronic) worked

is possible create one table for elsewhere coordinates

EXAMPLE:

local Positions = 
    { 
    { 653.35773, -1769.18567, 13.57368 }, 
    { 664.65936, -1755.74182, 13.45477 }, 
    } 
  
for index = 1, #Positions do 
    local test = createPickup ( Positions [ index ] [ 1 ], Positions [ index ] [ 2 ], Positions [ index ] [ 3 ], 3, 1239, 10000 ) 
end 

( I tested it, and it only worked in one pickup )

ADD:

function onHit() 
test = createPickup (653.35773, -1769.18567, 13.57368, 3, 1247, 10000 ) 
addEventHandler("onPickupHit",test, 
function(player) 
if isPedInVehicle(player) then 
local vehicle = getPedOccupiedVehicle(player) 
usePickup ( test, player ) 
setPlayerWantedLevel(getVehicleController(vehicle),getPlayerWantedLevel(getVehicleController(vehicle))-1) 
else 
setPlayerWantedLevel(player,getPlayerWantedLevel(player)-1) 
usePickup ( test, player ) 
end 
end) 
end 
addEventHandler("onResourceStart",resourceRoot, onHit) 

Link to comment
local Positions = 
    { 
    { 653.35773, -1769.18567, 13.57368 }, 
    { 664.65936, -1755.74182, 13.45477 }, 
    } 
  
local pickups = { pickup = { } } 
  
function onHit ( ) 
for _, v in ipairs ( Positions )    do 
    local x, y, z = unpack ( v ) 
    local pickups.pickup[v] = createPickup ( x, y, z, 3, 1247, 10000 ) 
end 
addEventHandler ( "onPickupHit", test, 
    function ( player ) 
    if isPedInVehicle ( player ) then 
        local vehicle = getPedOccupiedVehicle ( player ) 
        usePickup ( test, player ) 
        setPlayerWantedLevel ( getVehicleController ( vehicle ), getPlayerWantedLevel ( getVehicleController ( vehicle ) )-1 ) 
    else 
        setPlayerWantedLevel ( player, getPlayerWantedLevel ( player )-1 ) 
        usePickup ( test, player ) 
    end 
end) 
end 
addEventHandler ( "onResourceStart", resourceRoot, onHit ) 

Link to comment
local Positions = 
    { 
    { 653.35773, -1769.18567, 13.57368 }, 
    { 664.65936, -1755.74182, 13.45477 }, 
    } 
  
local pickups = { pickup = { } } 
  
function onHit ( ) 
for _, v in ipairs ( Positions )    do 
    local x, y, z = unpack ( v ) 
    local pickups.pickup[v] = createPickup ( x, y, z, 3, 1247, 10000 ) 
end 
addEventHandler ( "onPickupHit", test, 
    function ( player ) 
    if isPedInVehicle ( player ) then 
        local vehicle = getPedOccupiedVehicle ( player ) 
        usePickup ( test, player ) 
        setPlayerWantedLevel ( getVehicleController ( vehicle ), getPlayerWantedLevel ( getVehicleController ( vehicle ) )-1 ) 
    else 
        setPlayerWantedLevel ( player, getPlayerWantedLevel ( player )-1 ) 
        usePickup ( test, player ) 
    end 
end) 
end 
addEventHandler ( "onResourceStart", resourceRoot, onHit ) 

Where is test defined?

Link to comment

Ah, my bad I was using his other script and forgot to change test to pickups.pickup[v]

Thanks for letting me know :D

local Positions = 
    { 
    { 653.35773, -1769.18567, 13.57368 }, 
    { 664.65936, -1755.74182, 13.45477 }, 
    } 
  
local pickups = { pickup = { } } 
  
function onHit ( ) 
for _, v in ipairs ( Positions )    do 
    local x, y, z = unpack ( v ) 
    pickups.pickup[v] = createPickup ( x, y, z, 3, 1247, 10000 ) 
addEventHandler ( "onPickupHit", pickups.pickup[v], 
    function ( player ) 
    if isPedInVehicle ( player ) then 
        local vehicle = getPedOccupiedVehicle ( player ) 
        usePickup ( pickups.pickup[v], player ) 
        setPlayerWantedLevel ( getVehicleController ( vehicle ), getPlayerWantedLevel ( getVehicleController ( vehicle ) )-1 ) 
    else 
        setPlayerWantedLevel ( player, getPlayerWantedLevel ( player )-1 ) 
        usePickup ( pickups.pickup[v], player ) 
    end 
end) 
end 
end 
addEventHandler ( "onResourceStart", resourceRoot, onHit ) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...