Jump to content

how to make car spawn


Recommended Posts

That one is as simple as it could possibly be, don't be afraid of long data tables or detailed GUI code, read it line by line and you'll find out how it works pretty fast. There are other spawn systems too but most of them doesn't use tables and are full of bugs.

Link to comment

Here is a basic code to get you started:

local maker = createMarker ( 0, 0, 11, "cylinder", 2, 255, 255, 255 ,255 ) 
local vehicles = { } 
  
addEventHandler ( "onMarkerHit", marker, function ( p ) 
    if ( p and getElementType ( p ) == "player" and not isPedInVehicle ( p ) ) then 
         
        -- destroy their old vehicle, if it exists 
        if ( isElement ( vehicles [ p ] ) ) then 
            destroyElement ( vehicles [ p ] ) 
        end 
  
        -- create the new vehicle 
        vehicles [ p ] = createVehicle ( 411, 0, 0, 20 ) 
    end  
end ) 

Link to comment
Here is a basic code to get you started:
local maker = createMarker ( 0, 0, 11, "cylinder", 2, 255, 255, 255 ,255 ) 
local vehicles = { } 
  
addEventHandler ( "onMarkerHit", marker, function ( p ) 
    if ( p and getElementType ( p ) == "player" and not isPedInVehicle ( p ) ) then 
         
        -- destroy their old vehicle, if it exists 
        if ( isElement ( vehicles [ p ] ) ) then 
            destroyElement ( vehicles [ p ] ) 
        end 
  
        -- create the new vehicle 
        vehicles [ p ] = createVehicle ( 411, 0, 0, 20 ) 
    end  
end ) 

so on line 1.local maker = createMarker ( 0, 0, 11, "cylinder", 2, 255, 255, 255 ,255 )

what does it mean ? sorry for too much questions but im new scriptor can u explane that language

Link to comment
Here is a basic code to get you started:
local maker = createMarker ( 0, 0, 11, "cylinder", 2, 255, 255, 255 ,255 ) 
local vehicles = { } 
  
addEventHandler ( "onMarkerHit", marker, function ( p ) 
    if ( p and getElementType ( p ) == "player" and not isPedInVehicle ( p ) ) then 
         
        -- destroy their old vehicle, if it exists 
        if ( isElement ( vehicles [ p ] ) ) then 
            destroyElement ( vehicles [ p ] ) 
        end 
  
        -- create the new vehicle 
        vehicles [ p ] = createVehicle ( 411, 0, 0, 20 ) 
    end  
end ) 

so on line 1.local maker = createMarker ( 0, 0, 11, "cylinder", 2, 255, 255, 255 ,255 )

what does it mean ? sorry for too much questions but im new scriptor can u explane that language

Line 1 is telling the script to create a maker element, and define it to the variable marker.

If you want to get a better understanding of Lua, you can try reading this to help you out:

viewtopic.php?f=148&t=75501

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