Jump to content

Table maker and Vehicle[Solved]


#RooTs

Recommended Posts

Hello friends, I'm having trouble on my table.

I did a heliport script, however I tried to add a table to it,

createBlip ( 1534.68079, -1353.91235, 328 , 48 ) 
  
maker = createMarker(1534.68079, -1353.91235, 328,"cylinder",1.5,230,0,85,225) 
local Helli = { } 
  
function teste(hitElement) 
        if ( isPedInVehicle ( hitElement ) ) then 
        else 
        if (source == maker) then 
            if isElement ( Helli [ hitElement ] ) then destroyElement ( Helli [ hitElement ] ) end 
            Helli [ hitElement ] = createVehicle ( 487, 1544.40454, -1353.25867, 329.47440 , 0, 0, 0 ) 
            warpPlayerIntoVehicle ( hitElement, Helli [ hitElement ] ) 
        end 
    end 
end 
addEventHandler ("onMarkerHit",root,teste) 
  
addEventHandler ( "onVehicleExplode", resourceRoot, 
    function ( ) 
        destroyElement ( source ) 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if ( isElement ( Helli [ source ] ) ) then 
            destroyElement ( Helli [ source ] ) 
        end 
        Helli [ source ] = nil 
    end 
) 

most did not work out what's wrong with it?

local Positions2 = 
    { 
        { -2237.92749, 2328.21558, 6.4 }, 
        { 2577.23926, -1119.34814, 80.5 }, 
       -- { 1532.44519, -1350.25830, 328 } 
  
    } 
  
--------------------------------- 
  
local Positions1 = 
    { 
        { -2227.85522, 2326.74170, 7.54688, 0, 0, 0 }, 
        { 2592.02979, -1123.67065, 80.94149, 0, 0, 180 }, 
        --{ 1544.21667, -1353.34680, 329.47424, 0, 0, 0 } 
  
    } 
  
  
local vehicleID = 487 -- maverick 
  
for index2 = 1, #Positions2 do 
createBlip ( Positions2 [ index2 ] [ 1 ], Positions2 [ index2 ] [ 2 ], Positions2 [ index2 ] [ 3 ], 5 ) 
maker = createMarker(Positions2 [ index2 ] [ 1 ], Positions2 [ index2 ] [ 2 ], Positions2 [ index2 ] [ 3 ], "cylinder",1.5,230,0,85,225) 
end 
  
local Helli = { } 
  
function teste(hitElement) 
        if ( isPedInVehicle ( hitElement ) ) then 
        else 
        if (source == maker) then 
            if isElement ( Helli [ hitElement ] ) then destroyElement ( Helli [ hitElement ] ) end 
for index1 = 1, #Positions1 do 
            Helli [ hitElement ] = createVehicle ( vehicleID, Positions1 [ index1 ] [ 1 ], Positions1 [ index1 ] [ 2 ], Positions1 [ index1 ] [ 3 ] , Positions1 [ index1 ] [ 4 ], Positions1 [ index1 ] [ 5 ], Positions1 [ index1 ] [ 6 ] ) 
end 
            warpPlayerIntoVehicle ( hitElement, Helli [ hitElement ] ) 
        end 
    end 
end 
addEventHandler ("onMarkerHit",root,teste) 
  
addEventHandler ( "onVehicleExplode", resourceRoot, 
    function ( ) 
        destroyElement ( source ) 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if ( isElement ( Helli [ source ] ) ) then 
            destroyElement ( Helli [ source ] ) 
        end 
        Helli [ source ] = nil 
    end 
) 

Edited by Guest
Link to comment
Do you get any error in the debugscript? which part doesn't work?

it has no errors, more. only works 1

Example:

local Positions2 = 
    { 
        { -2237.92749, 2328.21558, 6.4 }, -- no work 
        { 2577.23926, -1119.34814, 80.5 }, -- no work 
        { 1532.44519, -1350.25830, 328 }, --  work 
  
    } 
or 
  
    { 
        { -2237.92749, 2328.21558, 6.4 }, -- no work 
        { 2577.23926, -1119.34814, 80.5 }, --  work 
       -- { 1532.44519, -1350.25830, 328 }, 
  
    } 
  
  

not to mention that. when I create one, heli. other point is also created

sorry my English

Link to comment
local Positions2 = 
    { 
        { -2237.92749, 2328.21558, 6.4 }, 
        { 2577.23926, -1119.34814, 80.5 }, 
        { 1532.44519, -1350.25830, 328 }, 
  
    } 
  
--------------------------------- 
  
local Positions1 = 
    { 
        { -2227.85522, 2326.74170, 7.54688, 0, 0, 0 }, 
        { 2592.02979, -1123.67065, 80.94149, 0, 0, 180 }, 
        { 1544.21667, -1353.34680, 329.47424, 0, 0, 0 }, 
  
    } 
  
  
local vehicleID = 487 -- maverick 
  
for k,v in ipairs (Positions2) do 
createBlip ( v[1], v[2], v[3], 5 ) 
maker = createMarker( v[1],v[2],v[3], "cylinder",1.5,230,0,85,225) 
end 
  
local Helli = { } 
  
function teste(hitElement) 
        if ( isPedInVehicle ( hitElement ) ) then 
        else 
        if (source == maker) then 
            if isElement ( Helli [ hitElement ] ) then destroyElement ( Helli [ hitElement ] ) end 
for k,v in ipairs (Positions1) do 
            Helli [ hitElement ] = createVehicle ( vehicleID, v[1], v[2], v[3], v[4],v[5],v[6] ) 
end 
            warpPlayerIntoVehicle ( hitElement, Helli [ hitElement ] ) 
        end 
    end 
end 
addEventHandler ("onMarkerHit",root,teste) 
  
addEventHandler ( "onVehicleExplode", resourceRoot, 
    function ( ) 
        destroyElement ( source ) 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if ( isElement ( Helli [ source ] ) ) then 
            destroyElement ( Helli [ source ] ) 
        end 
        Helli [ source ] = nil 
    end 
) 

Link to comment

the table that I did, just is not working

if anyone knows add 2 tables with 2 different positions, please help me

(Without the table it works perfectly, more wanted to add more places in the same script without duplicating it in several files)

OBS: are 2 tables

position 1 = createmaker -- table 01

position 2 createVehicle -- table 02

my script without the table

  
createBlip ( 1534.68079, -1353.91235, 328 , 48 ) 
  
maker = createMarker(1534.68079, -1353.91235, 328,"cylinder",1.5,230,0,85,225) 
local Helli = { } 
  
function teste(hitElement) 
        if ( isPedInVehicle ( hitElement ) ) then 
        else 
        if (source == maker) then 
            if isElement ( Helli [ hitElement ] ) then destroyElement ( Helli [ hitElement ] ) end 
            Helli [ hitElement ] = createVehicle ( 487, 1544.40454, -1353.25867, 329.47440 , 0, 0, 0 ) 
            warpPlayerIntoVehicle ( hitElement, Helli [ hitElement ] ) 
        end 
    end 
end 
addEventHandler ("onMarkerHit",root,teste) 
  
addEventHandler ( "onVehicleExplode", resourceRoot, 
    function ( ) 
        destroyElement ( source ) 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if ( isElement ( Helli [ source ] ) ) then 
            destroyElement ( Helli [ source ] ) 
        end 
        Helli [ source ] = nil 
    end 
) 
  

Look image

xttVNPr.png

Edited by Guest
Link to comment

i do not understand your english very well, what you mean by "perfeiramente"?

ok, if you say that my code is not working, try this way:

local Positions2 = { 
    { X=-2237.92749, Y=2328.21558, Z=6.4 }, 
    { X=2577.23926, Y=-1119.34814, Z=80.5 } 
} 
  
for i,v in pairs(Positions2) do 
    createMarker(v.X,v.Y,v.Z,"cylinder",1.5,230,0,85,225) 
end 

Link to comment

i already gave you the example of how to create the table, now it's up to you to work a bit and create the two tables that you want.

Remember, we're not your slaves, we are here only to help correct their mistakes, or clarify your doubts. I already gave you an example of how to create a table, if you can not create several tables with this example, you probably should not be doing this sort of scripts yet.

Remember to always search in the wiki for documentation!

Or if you want someone create 54868741 tables and put them in your code, I think you should look for a paid scripter.

Link to comment
  
local heliPos =  
{ 
    { 
        marker = { -2237.92749, 2328.21558, 6.4 }, 
        vehicle = { -2227.85522, 2326.74170, 7.54688, rot=0 }, 
    }, 
    { 
        marker = { 2577.23926, -1119.34814, 80.5 }, 
        vehicle = { 2592.02979, -1123.67065, 80.94149, rot=180 }, 
    }, 
    { 
        marker = { 1532.44519, -1350.25830, 328 }, 
        vehicle = { 1544.21667, -1353.34680, 329.47424, rot=0 }, 
    } 
} 
  
local markers = {} 
local Helli = { } 
local vehicleID = 487 -- maverick 
  
addEventHandler( "onResourceStart", resourceRoot, 
    function() 
        for i=1, #heliPos do 
            local x,y,z = unpack(heliPos[i].marker) 
            createBlip(x, y, z, 5) 
            markers[i] = createMarker(x, y, z, "cylinder",1.5,230,0,85,225) 
        end 
    end 
) 
  
function teste(hitElement) 
    if getElementType(hitElement) ~= "player" then return end; 
    if isPedInVehicle(hitElement) then return end; 
     
    for i=1, #markers do 
        if (source == markers[i]) then 
            if isElement(Helli[hitElement]) then destroyElement(Helli[hitElement]) end; 
             
            local vx,vy,vz = unpack(heliPos[i].vehicle) 
            local vrot = heliPos[i].vehicle.rot 
            Helli[hitElement] = createVehicle(vehicleID, vx, vy, vz, 0, 0, vrot) 
            setTimer(warpPedIntoVehicle, 80, 1, hitElement, Helli[hitElement]) 
            break 
        end 
    end 
end 
addEventHandler("onMarkerHit", resourceRoot, teste) 
  
addEventHandler ( "onVehicleExplode", resourceRoot, 
    function ( ) 
        destroyElement ( source ) 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if ( isElement ( Helli [ source ] ) ) then 
            destroyElement ( Helli [ source ] ) 
        end 
        Helli [ source ] = nil 
    end 
) 

Is that what you mean?

Link to comment
  
local heliPos =  
{ 
    { 
        marker = { -2237.92749, 2328.21558, 6.4 }, 
        vehicle = { -2227.85522, 2326.74170, 7.54688, rot=0 }, 
    }, 
    { 
        marker = { 2577.23926, -1119.34814, 80.5 }, 
        vehicle = { 2592.02979, -1123.67065, 80.94149, rot=180 }, 
    }, 
    { 
        marker = { 1532.44519, -1350.25830, 328 }, 
        vehicle = { 1544.21667, -1353.34680, 329.47424, rot=0 }, 
    } 
} 
  
local markers = {} 
local Helli = { } 
local vehicleID = 487 -- maverick 
  
addEventHandler( "onResourceStart", resourceRoot, 
    function() 
        for i=1, #heliPos do 
            local x,y,z = unpack(heliPos[i].marker) 
            createBlip(x, y, z, 5) 
            markers[i] = createMarker(x, y, z, "cylinder",1.5,230,0,85,225) 
        end 
    end 
) 
  
function teste(hitElement) 
    if getElementType(hitElement) ~= "player" then return end; 
    if isPedInVehicle(hitElement) then return end; 
     
    for i=1, #markers do 
        if (source == markers[i]) then 
            if isElement(Helli[hitElement]) then destroyElement(Helli[hitElement]) end; 
             
            local vx,vy,vz = unpack(heliPos[i].vehicle) 
            local vrot = heliPos[i].vehicle.rot 
            Helli[hitElement] = createVehicle(vehicleID, vx, vy, vz, 0, 0, vrot) 
            setTimer(warpPedIntoVehicle, 80, 1, hitElement, Helli[hitElement]) 
            break 
        end 
    end 
end 
addEventHandler("onMarkerHit", resourceRoot, teste) 
  
addEventHandler ( "onVehicleExplode", resourceRoot, 
    function ( ) 
        destroyElement ( source ) 
    end 
) 
  
addEventHandler ( "onPlayerQuit", root, 
    function ( ) 
        if ( isElement ( Helli [ source ] ) ) then 
            destroyElement ( Helli [ source ] ) 
        end 
        Helli [ source ] = nil 
    end 
) 

Is that what you mean?

yes, working without bugs or apparent bugs

thanks man :wink:

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