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 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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.

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Kenix, we always must use a setTimer() to use warpPedIntoVehicle() ? Is more recommended? Or he must use only in this example?

Software Engineer & Entrepreneur Running Lustrel and VilarikA • Highly engaged on open source community

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

Software Engineer & Entrepreneur Running Lustrel and VilarikA • Highly engaged on open source community

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
getElementModel 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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