Jump to content

Why is this not working?


PARKAH

Recommended Posts

marker = createMarker(1949, -1705, 13,"corona",2,0,255,0) 
  
addEventHandler("onClientMarkerHit",marker, 
function() 
    local vh = getPedOccupiedVehicle ( source ) 
    vehicles = {462} 
    nm = tonumber ( math.random( #vehicles ) ) 
    setElementModel ( vh, nm )   
end) 

Link to comment
marker = createMarker(1949, -1705, 13,"corona",2,0,255,0) 
  
addEventHandler("onClientMarkerHit",marker, 
function(hitElement) 
    local vh = getPedOccupiedVehicle (hitElement) 
    vehicles = {462} 
    nm = tonumber ( math.random( #vehicles ) ) 
    setElementModel ( vh, nm )   
end) 

The source of onClientMarkerHit is the maker itself, use hitElement instead.

Link to comment
trailers = { 
    [606] = true, 
    [607] = true, 
    [610] = true, 
    [590] = true, 
    [569] = true, 
    [611] = true, 
    [584] = true, 
    [608] = true, 
    [435] = true, 
    [450] = true, 
    [591] = true 
} 
  
local marker = createMarker(1949, -1705, 13,"corona",2,0,255,0) 
  
addEventHandler("onClientMarkerHit",marker, 
function(thePlayer) 
    local vh = getPedOccupiedVehicle (thePlayer) 
    nm = math.random(400,602 ) 
    if (nm ~= trailers) then 
        setElementModel ( vh, nm )   
    end 
end) 

Link to comment
trailers = { 
    [606] = true, 
    [607] = true, 
    [610] = true, 
    [590] = true, 
    [569] = true, 
    [611] = true, 
    [584] = true, 
    [608] = true, 
    [435] = true, 
    [450] = true, 
    [591] = true 
} 
  
local marker = createMarker(1949, -1705, 13,"corona",2,0,255,0) 
  
addEventHandler("onClientMarkerHit",marker, 
function(thePlayer) 
    local vh = getPedOccupiedVehicle (thePlayer) 
    nm = math.random(400,602 ) 
    if (nm ~= trailers) then 
        setElementModel ( vh, nm )   
    end 
end) 

Huh?

@PARKAH - Do you have a "vehicles" table defined?

Link to comment

xXMADEXx, he does.

marker = createMarker(1949, -1705, 13,"corona",2,0,255,0) 
  
addEventHandler("onClientMarkerHit",marker, 
function() 
    local vh = getPedOccupiedVehicle ( source ) 
    vehicles = {462} -- RIGHT HERE HE DOES. 
    nm = tonumber ( math.random( #vehicles ) ) 
    setElementModel ( vh, nm )   
end) 

Link to comment
xXMADEXx, he does.
marker = createMarker(1949, -1705, 13,"corona",2,0,255,0) 
  
addEventHandler("onClientMarkerHit",marker, 
function() 
    local vh = getPedOccupiedVehicle ( source ) 
    vehicles = {462} -- RIGHT HERE HE DOES. 
    nm = tonumber ( math.random( #vehicles ) ) 
    setElementModel ( vh, nm )   
end) 

Oh, my bad. I didn't see that.

((Not Tested))

marker = createMarker(1949, -1705, 13,"corona",2,0,255,0) 
  
addEventHandler("onClientMarkerHit",marker, 
function( p ) 
    local vh = getPedOccupiedVehicle ( p ) 
    vehicles = {462} 
    nm = tonumber ( vehicles  [ math.random( #vehicles ) ] ) 
    setElementModel ( vh, nm )   
end) 

Link to comment

Use localPlayer instead p or source

marker = createMarker(1949, -1705, 13,"corona",2,0,255,0) 
  
addEventHandler("onClientMarkerHit",marker, 
function ( ) 
    local vh = getPedOccupiedVehicle ( localPlayer ) 
    if getElementModel(vh) == 462 then 
    local nm = tonumber ( vehicles  [ math.random( #vehicles ) ] ) 
    setElementModel ( vh, nm )   
    end 
end) 

Link to comment

You guys are all failing..

For vehicle id's you can look right here:

https://wiki.multitheftauto.com/wiki/Vehicle_IDs

  
local vehiclesTable = {429, 411, 541, 559, 415, 561, 480, 560, 562, 506, 565, 451, 434, 558, 494, 555, 502, 477, 503} 
  
marker = createMarker(1949, -1705, 13,"corona",2,0,255,0) 
  
function markerHit(hitElement) 
if hitElement == localPlayer then 
    local vh = getPedOccupiedVehicle ( hitElement ) 
    local nm = tonumber (1,math.random( #vehiclesTable ) ) 
    setElementModel ( vh, nm )   
end 
end 
addEventHandler("onClientMarkerHit",marker,markerHit ) 
  

Tip:

Also aligain the vehicle posZ one cordinate up for preventing the cars to get stuck into the ground.

Link to comment

Whythehex are you using a table then, maybe because you got it from a another topic?

So please, tell us why are you using usseless tables, since i tought, a table with one vehicleID, so weird. :redhotevil:

marker = createMarker(1949, -1705, 13,"corona",2,0,255,0) 
  
function markerHit(hitElement) 
if hitElement == localPlayer then 
    local vh = getPedOccupiedVehicle ( hitElement ) 
    setElementModel ( vh, 462)   
end 
end 
addEventHandler("onClientMarkerHit",marker,markerHit ) 

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