Jump to content

Recover marker after destroyed?


Recommended Posts

hello i'm currently working on a bankrob script right now but,

is it possible when the marker got destroyed by destroyelement , it can recover again? here's my code of client.lua

local bankmarker = createMarker( -725.01849, 969.94299, 11.4, "cylinder", 1.5, 255, 0, 0, 255 ) 
  
addEventHandler ( "onClientMarkerHit", bankmarker, 
    function ( hitElement ) 
        if ( hitElement == localPlayer and getElementType ( hitElement ) == "player" ) then 
            local playerTeam = getPlayerTeam ( hitElement ) 
            if ( playerTeam and getTeamName ( playerTeam ) == "Criminals" ) then 
                triggerServerEvent ("stealstart",getLocalPlayer(),stealstart) 
                triggerServerEvent ("trespass",getLocalPlayer(),trespass) 
                setTimer ( destroyElement, 30000, 1, source, bankmarker ) 
            end 
        end 
    end 
) 

Link to comment

tried this but marker doensn't create and marker doesn't appear even tho i restart the script

addEventHandler("onElementDestroy", getRootElement(), function (player) 
if getElementType(source) == "marker" then 
setTimer ( createElement, 30000, 1, source, bankmarker ) 
end 

Link to comment
this is clientside not server side.
addEventHandler("onClientElementDestroy", getRootElement(), 
function () 
    if getElementType(source) == "marker" and source == bankmarker then 
    setTimer ( function() 
    createMarker( -725.01849, 969.94299, 11.4, "cylinder", 1.5, 255, 0, 0, 255 ) 
    end,3000,1) 
end) 

Link to comment
loading script failed: prison/client.lua:45 unexpected symbol near ')'

what should i do

addEventHandler("onClientElementDestroy", getRootElement(), 
function () 
    if getElementType(source) == "marker" and source == bankmarker then 
    setTimer ( function() 
    createMarker( -725.01849, 969.94299, 11.4, "cylinder", 1.5, 255, 0, 0, 255 ) 
    end,3000,1) 
end 
end  
) 

Link to comment
EDIT:

When it creates the marker again, the trigger doesn't work anymore when i step in the new created marker.

when i step in the new created marker , nothing happens

You must define the marker like this :

addEventHandler("onClientElementDestroy", getRootElement(), 
function () 
    if getElementType(source) == "marker" and source == bankmarker then 
    setTimer ( function() 
    bankmarker = createMarker( -725.01849, 969.94299, 11.4, "cylinder", 1.5, 255, 0, 0, 255 ) 
    end,3000,1) 
end 
end 
) 

Link to comment

img of problem:

KX2owAq.png

here is the line of 30-41 in my server.lua 34 is the killtimer( V )

function killPlayer( ) 
outputChatBox ( "Radio: the robber stopped stealing money!", getRootElement(), 100, 200, 0, true ) 
    for i, v in ipairs( players[ source ] ) do 
        if isTimer( v ) then 
            killTimer( v ) 
            players[ source ][ i ] = nil 
        end 
    end 
    players[ source ] = nil 
end 
addEvent( "killplayer", true ) 
addEventHandler( "killplayer", root, killPlayer ) 

Link to comment

full server.lua

local players = {} 
local ticks = {} 
addEvent("stealstart",true)  
addEventHandler("stealstart",root,  
function() 
    if players[ source ] and players[ source ][ 3 ] then 
        return  
    end 
    players[ source ] = {} 
    players[ source ][ 1 ] = setTimer ( outputChatBox, 30000, 1, "You have successfully stolen 50000$ in the bank",source, 255, 0, 0, false) 
    players[ source ][ 2 ] = setTimer ( givePlayerMoney, 30000, 1, source, 50000 ) 
    players[ source ][ 3 ] = setTimer( function( ) end, 100, 1 ) 
    setTimer( function( source ) players[ source ][ 3 ] = nil end, 100, 1, source ) 
   if ( getPlayerMoney (source) >= 0 ) then 
outputChatBox("You need to wait 30 seconds to get your 50000$ stay in the marker to get the money", source, 255, 0, 0) 
  
  
end 
end) 
  
addEvent("trespass",true)  
addEventHandler("trespass",root,  
function() 
    if ticks[ source ] and getTickCount( ) - ticks[ source ] < 1000 then return end 
    ticks[ source ] = getTickCount() 
   if ( getPlayerMoney (source) >= 0 ) then 
outputChatBox ( "Radio: Someone is robbing the bank! , all police respond immediately!", getRootElement(), 100, 200, 0, true ) 
end 
end) 
  
function killPlayer( ) 
outputChatBox ( "Radio: the Robber(s) stopped stealing money!", getRootElement(), 100, 200, 0, true ) 
    for i, v in ipairs( players[ source ] ) do 
        if isTimer( v ) then 
            killTimer( v ) 
            players[ source ][ i ] = nil 
        end 
    end 
    players[ source ] = nil 
end 
addEvent( "killplayer", true ) 
addEventHandler( "killplayer", root, killPlayer ) 

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