Jump to content

[SOLVED] Tiny prob


justn

Recommended Posts

PROBLEM ON LINE 30-36, When i hit the marker nothing happens

Server.lua:

addEventHandler ( "onResourceStart", getRootElement(), 
    function ( started ) 
        getCar = createVehicle ( 411, 2062.91138, -1570.18054, 12.95983, 0, 0, 272 ) 
        startBlip = createBlipAttachedTo ( getCar, 12 ) 
        Marker1 = createMarker ( 2062.82886, -1568.31702, 12.43865, "cylinder", 2, 0, 0, 255, 85 ) 
        setVehicleLocked ( getCar, true ) 
        setElementFrozen ( getCar, true ) 
        setVehicleDamageProof ( getCar, true ) 
        exports["TopBarChat"]:sendClientMessage ("Car Jacker: There's a car on the radar, go to the 'C' blip to get it.",0,0,255) 
    end 
) 
  
    function onEnter(thePlayer, seat) 
            if ( getElementType ( getCar ) == "vehicle" ) and ( getElementModel ( getCar ) == 411 ) then 
                Marker = createMarker ( x, y, z ) 
                Blip = createBlipAttachedTo ( Marker, 12 ) 
                exports["TopBarChat"]:sendClientMessage ("Car Jacker: Go to the blip on the marker to get money", thePlayer, 0, 0, 255) 
            end 
        end 
addEventHandler("onVehicleEnter", getRootElement(), onEnter ) 
  
function hitit(thePlayer, hitElement) 
    if getElementType(hitElement) == "player" and (hitElement == thePlayer) then 
    local money = math.random ( 500,800 ) 
    givePlayerMoney ( thePlayer, money ) 
 end 
 end 
 addEventHandler("onMarkerHit", getRootElement(), hitit ) 
  
 addEventHandler ( "onMarkerHit", root, 
 function ( thePlayer, hitElement ) 
    if source == Marker1 and thePlayer == hitElement  then 
        warpPedIntoVehicle( thePlayer, getCar ) 
        end 
    end 
    ) 

Edited by Guest
Link to comment
thePlayer == hitElement 

That doesn't make any sense, the second argument of onMarkerHit is "matchingDimension", remove:

thePlayer == hitElement 

Hm, this ?

addEventHandler ( "onMarkerHit", root, 
 function ( hitElement, matchingDimension, thePlayer ) 
     if source == Marker1 then 
     warpPedIntoVehicle( thePlayer, getCar ) 
        end 
    end 
    ) 

Edited by Guest
Link to comment

No, note from the wiki: "The source of this event is the marker that got hit by the element."

Use this:

addEventHandler ( "onMarkerHit", root, 
 function ( hitElement, matchingDimension ) 
     if source == Marker1 then 
         if getElementType ( hitElement ) == "player" then -- make sure that it's a player 
                warpPedIntoVehicle(hitElement, getCar ) -- warps the hitted element in the car 
            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...