Jump to content

someone help me with this code


MR.S3D

Recommended Posts

hi guys

this my code

server side

local marker1 = createMarker(1525.3000488281,2834.3999023438,23.39999961853,"checkpoint",20,255,255,255,255) 
function marker(player) 
if (source == marker1) then 
local players = getElementsByType ( "player" ) 
timer = setTimer (function (player) 
if isPedInVehicle(player) then 
local veh = getPedOccupiedVehicle(player) 
if veh then 
destroyElement(veh) 
end end 
end ,1000,0, player) 
end 
end 
addEventHandler ("onMarkerHit",getRootElement(),marker) 
addEventHandler ("onMarkerLeave",getRootElement(),function() 
    if (source == marker1) then 
        if isTimer(timer) then killTimer(timer) end 
end 
end) 

this work onMarkerHit

but when i leave the marker

my Vehicle destroyed agin why ?

please some one help me

Link to comment
local marker1 = createMarker(1525.3000488281,2834.3999023438,23.39999961853,"checkpoint",20,255,255,255,255) 
function marker(player) 
if (source == marker1) then 
local players = getElementsByType ( "player" ) 
timer = setTimer (function (player) 
if isPedInVehicle(player) then 
local veh = getPedOccupiedVehicle(player) 
end end 
end ,1000,0, player) 
end 
end 
addEventHandler ("onMarkerHit",getRootElement(),marker) 
addEventHandler ("onMarkerLeave",getRootElement(),function() 
    if (source == marker1) then 
        if isTimer(timer) then killTimer(timer) end 
end 
end) 

Link to comment
local marker1 = createMarker(1525.3000488281,2834.3999023438,23.39999961853,"checkpoint",20,255,255,255,255) 
function marker(player) 
if (source == marker1) then 
local players = getElementsByType ( "player" ) 
timer = setTimer (function (player) 
if isPedInVehicle(player) then 
local veh = getPedOccupiedVehicle(player) 
end end 
end ,1000,0, player) 
end 
end 
addEventHandler ("onMarkerHit",getRootElement(),marker) 
addEventHandler ("onMarkerLeave",getRootElement(),function() 
    if (source == marker1) then 
        if isTimer(timer) then killTimer(timer) end 
end 
end) 

not work :(

Link to comment
local marker1 = createMarker(1525.3000488281,2834.3999023438,23.39999961853,"checkpoint",20,255,255,255,255) 
local timers = {} 
  
function marker(player) 
    if (source == marker1) then 
        timers[player] = setTimer (function (player) 
        if isPedInVehicle(player) then 
            local veh = getPedOccupiedVehicle(player) 
                if veh then 
                    destroyElement(veh) 
                end  
            end 
        end, 1000, 0, player) 
    end 
end 
addEventHandler ("onMarkerHit",getRootElement(),marker) 
  
addEventHandler ("onMarkerLeave",getRootElement(),function(player) 
    if (source == marker1) then 
        if isTimer(timers[player]) then killTimer(timers[player]) end 
    end 
end) 

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...