Jump to content

onMarkerHit - Problem


spAik

Recommended Posts

Hi, I want a special Marker being created when a map starts. Als people should get money when they jump through it. Whats wrong? :(

addEvent("onRaceStateChanging", true) 
addEventHandler("onRaceStateChanging", getRootElement(), 
function(newState, oldState) 
    if(newState == "Running")then 
myMarker = createMarker ( 156.8359375, 2504.0920410156, 34, "ring", 6.7, 255, 0, 0, 255 ) 
end 
end) 
  
addEventHandler("onMarkerHit", getRootElement(), 
function MarkerHit( source, player, matchingDimension ) -- define MarkerHit function for the handler 
if source == myMarker then 
setTimer ( function() 
myMarker = createMarker ( 156.8359375, 2504.0920410156, 34, "ring", 6.7, 255, 0, 0, 255 ) 
    end, 500, 1 ) 
local account = getPlayerAccount (player) 
setAccountData(account, "cash", getAccountData(account,"cash") + 100 ) 
outputChatBox ( "#FFFFFFYou have earned #FF0000$100#FFFFFF for that jump!", player,255,0,0,true) 
scoreboardRefresh(player) 
end 
end) 

Link to comment

Main problem was that you were defining the function name, but with the method you were attaching the event handler of "onMarkerHit", it didn't work.

addEvent ( "onRaceStateChanging", true ) 
addEventHandler ( "onRaceStateChanging", getRootElement(), 
    function ( newState, oldState ) 
        if ( newState == "Running" ) then 
            myMarker = createMarker ( 156.8359375, 2504.0920410156, 34, "ring", 6.7, 255, 0, 0, 255 ) 
        end 
    end 
) 
  
addEventHandler ( "onMarkerHit", getRootElement(), 
    function ( player, matchingDimension ) -- define MarkerHit function for the handler 
        if ( getElementType ( player ) == "player" ) then 
            if ( source == myMarker ) then 
                setTimer ( 
                    function ( ) 
                        myMarker = createMarker ( 156.8359375, 2504.0920410156, 34, "ring", 6.7, 255, 0, 0, 255 ) 
                    end 
                    ,500, 1 
                ) 
                local account = getPlayerAccount ( player ) 
                setAccountData ( account, "cash", getAccountData ( account, "cash" ) + 100 ) 
                outputChatBox ( "#FFFFFFYou have earned #FF0000$100#FFFFFF for that jump!", player, 255, 0, 0, true ) 
                scoreboardRefresh ( 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...