Jump to content

[HELP]Car Spwan On Marker Hint


Recommended Posts

Posted

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?

Posted

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 ) 

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

Posted (edited)

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
Posted

timer isn't needed as far as I'm concerned.

It's not a bug (or maybe it is), but you have to spawnPlayer first or it won't work.

if it doesn't work, it's because of this, you can fetch more info from kenix's link

Posted

In SAUR I had to use a 100 milliseconds timer to warp the player, because for some reason it teleports him really far in the sky, same happened when I gave myself a vehicle with the Admin Panel.

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