Jump to content

[HELP]Car Spwan On Marker Hint


Recommended Posts

vehicleMarker = createMarker (938.79998779297,-1053.1999511719,30.60000038147, 'cylinder', 2.0, 16, 16, 16, 255 ) 
function vehicleMarkerHit ( hitElement, matchingDimension ) 
 if ( isElement( hitElement ) and getElementType( hitElement ) == "player" and not isPedInVehicle (hitElement)) then 
  local team = getPlayerTeam ( hitElement ) 
  if ( getTeamName( team ) == "FBI" ) then 
                        local x, y, z = getElementPosition( hitElement ) 
   local vehicle = createVehicle ( 490, 938.79998779297, -1050.5, 31.89999961853, 0, 0, 0 ) 
   warpPedIntoVehicle( hitElement, vehicle ) 
  else 
   outputChatBox( "You must be on the FBI to use this.", hitElement, 255, 0, 0 ) 
  end 
  
 end 
end 
addEventHandler( "onMarkerHit", vehicleMarker , vehicleMarkerHit ) 

this make car onmarkerhit but how to make it like that when take first car and whant take second car first car disappear?

Link to comment

You must create a table which will store player created vehicle.

vehicleMarker = createMarker (938.79998779297,-1053.1999511719,30.60000038147, 'cylinder', 2.0, 16, 16, 16, 255 ) 
  
playerVehicles = { } 
  
function vehicleMarkerHit ( hitElement, matchingDimension ) 
    if ( isElement ( hitElement ) and getElementType ( hitElement ) == "player" and not isPedInVehicle ( hitElement ) ) then 
        local team = getPlayerTeam ( hitElement ) 
        if ( team and getTeamName ( team ) == "FBI" ) then 
            local x, y, z = getElementPosition ( hitElement ) 
            if ( isElement ( playerVehicles [ hitElement ] ) ) then 
                destroyElement ( playerVehicles [ hitElement ] ) 
            end 
  
            playerVehicles [ hitElement ] = createVehicle ( 490, 938.79998779297, -1050.5, 31.89999961853, 0, 0, 0 ) 
            warpPedIntoVehicle( hitElement, playerVehicles [ hitElement ] ) 
        else 
            outputChatBox( "You must be on the FBI to use this.", hitElement, 255, 0, 0 ) 
        end  
    end 
end 
addEventHandler ( "onMarkerHit", vehicleMarker , vehicleMarkerHit ) 

Link to comment
local pVehicleMarker = createMarker ( 938.79998779297, -1053.1999511719, 30.60000038147, 'cylinder', 2.0, 16, 16, 16, 255 ) 
  
local aPlayerVehicles = { } 
  
local function OnMarkerHit ( pHitElement ) 
    if getElementType ( pHitElement ) == 'player' and not isPedInVehicle ( pHitElement ) then 
        local pTeam = getPlayerTeam ( pHitElement ) 
        if pTeam and getTeamName ( pTeam ) == 'FBI' then 
            if isElement ( aPlayerVehicles [ pHitElement ] ) then 
                destroyElement ( aPlayerVehicles [ pHitElement ] ) 
            end 
  
            aPlayerVehicles [ pHitElement ] = createVehicle ( 490, 938.79998779297, -1050.5, 31.89999961853, 0, 0, 0 ) 
            setTimer( warpPedIntoVehicle, 200, 1, pHitElement, aPlayerVehicles [ pHitElement ] ) 
        else 
            outputChatBox( 'You must be on the FBI to use this.', pHitElement, 255, 0, 0 ) 
        end  
    end 
end 
addEventHandler ( 'onMarkerHit', pVehicleMarker , OnMarkerHit ) 

You should use warpPedIntoVehicle with timer.

Link to comment

Strange, Kenix. Because I made this code:

function CreateVehicleCommand(source, command, VehicleName) 
     
    local VehicleModel = getVehicleModelFromName(VehicleName) 
    local PlayerX, PlayerY, PlayerZ = getElementPosition(source) 
    local Vehicle = createVehicle(VehicleModel, PlayerX+2, PlayerY+2, PlayerZ) 
    warpPedIntoVehicle(source, Vehicle) 
     
end 
addCommandHandler("CreateVehicle", CreateVehicleCommand) 

It works, bro. Here, I'm warped to the vehicle (server-sided).

Edited by Guest
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...