Jump to content

Tuning Garage Help


shaio

Recommended Posts

Could someone tell me what is wrong with this script?

garages = { 
    {x = 14795,4105.1455078125,y = -1620.6474609375,z = 226.63835144043,rx = 180,ry = 0,rz = 0}, 
    {x = 14795,4105.1455078125,y = -1620.6474609375,z = 216.1208190918,rx = 0,ry = 0,rz = 0} 
} 
  
markers = { 
    {x = 2066.962890625,y = -1831.306640625,z = 13.546875}, 
    {x = 1848.5556640625,y = -1856.2978515625,z = 13.3828125}, 
    {x = 1024.705078125,y = -1025.365234375,z = 32.1015625}, 
    {x = -1936.2119140625,y = 243.2685546875,z = 34.4609375}, 
    {x = -1904.5869140625,y = 282.06640625,z = 41.046875}, 
    {x = -2426.064453125,y = 1023.9189453125,z = 50.397659301758}, 
    {x = -1786.8173828125,y = 1212.4912109375,z = 25.125}, 
    {x = -1420.451171875,y = 2587.189453125,z = 55.84326171875} 
} 
  
for _,g in pairs(garages) do 
    garage = createObject(g.x,g.y,g.z,g.rx,g.ry,g.rz) 
end 
  
for _,t in pairs(markers) do 
    marker = createMarker(t.x,t.y,t.z,"cylinder",3,0,0,0,0) 
end 
  
function onHit(element,dimension) 
    if isPlayerInVehicle(source) then 
        local vehicle = getPedOccupiedVehile(source) 
        setElementPosition(vehicle,4104.921875,-1621.7041015625,211.47169494629) 
        setElementFrozen(vehicle,true) 
    end 
end 
addEventHandler("onPlayerMarkerHit",marker,onHit) 

Link to comment

Actually no I don't. It makes a marker for each location.. There is no destroyElement, or destroyMarker. I've tested this, all the markers get created and I've created the garages.

I've debugged the script and found that the event handler has a bad argument. It cannot find the marker. Even tho I made the variable global.

I still need help..

Link to comment

So it should look something like this?

garages = { 
    {x = 14795,4105.1455078125,y = -1620.6474609375,z = 226.63835144043,rx = 180,ry = 0,rz = 0}, 
    {x = 14795,4105.1455078125,y = -1620.6474609375,z = 216.1208190918,rx = 0,ry = 0,rz = 0} 
} 
  
markers = { 
    {x = 2066.962890625,y = -1831.306640625,z = 13.546875}, 
    {x = 1848.5556640625,y = -1856.2978515625,z = 13.3828125}, 
    {x = 1024.705078125,y = -1025.365234375,z = 32.1015625}, 
    {x = -1936.2119140625,y = 243.2685546875,z = 34.4609375}, 
    {x = -1904.5869140625,y = 282.06640625,z = 41.046875}, 
    {x = -2426.064453125,y = 1023.9189453125,z = 50.397659301758}, 
    {x = -1786.8173828125,y = 1212.4912109375,z = 25.125}, 
    {x = -1420.451171875,y = 2587.189453125,z = 55.84326171875} 
} 
  
for _,g in ipairs(garages) do 
    garage = createObject(g.x,g.y,g.z,g.rx,g.ry,g.rz) 
end 
  
for _,t in pairs(markers) do 
    marker = createMarker(t.x,t.y,t.z-1,"cylinder",3,255,255,255,255) 
    addEventHandler("onMarkerHit",marker,onHit) 
end 
  
function onHit(element,dimension) 
    if (getElementType(element) == "vehicle") then 
        setElementPosition(element,4104.921875,-1621.7041015625,211.47169494629) 
        setElementFrozen(element,true) 
    end 
end 

Link to comment
    garages = { 
        {14795,4105.1455078125,-1620.6474609375,226.63835144043,180,0,0}, 
        {14795,4105.1455078125,-1620.6474609375,216.1208190918,0,0,0} 
    } 
      
    markers = { 
        {2066.962890625,-1831.306640625,13.546875}, 
        {1848.5556640625,-1856.2978515625,13.3828125}, 
        {1024.705078125,-1025.365234375,32.1015625}, 
        {-1936.2119140625,243.2685546875,34.4609375}, 
        {-1904.5869140625,282.06640625,41.046875}, 
        {-2426.064453125,1023.9189453125,50.397659301758}, 
        {-1786.8173828125,1212.4912109375,25.125}, 
        {-1420.451171875,2587.189453125,55.84326171875} 
    } 
      
    for _,g in ipairs(garages) do 
        garage = createObject(g[1],g[2],g[3],g[4],g[5],g[6]) 
    end 
      
    for _,t in pairs(markers) do 
        marker = createMarker(t[1],t[2],t[3]-1,"cylinder",3,255,255,255,255) 
        addEventHandler("onMarkerHit",marker,onHit) 
    end 
      
    function onHit(element,dimension) 
        if (getElementType(element) == "vehicle") then 
            setElementPosition(element,4104.921875,-1621.7041015625,211.47169494629) 
            setElementFrozen(element,true) 
        end 
    end 
     

Link to comment

I've done this, cuz it wont call the function globally.. It works, without any errors. I've debugged the script as well, still no errors. Thanks for the help guys..

garages = { 
    {x = 14795,4105.1455078125,y = -1620.6474609375,z = 226.63835144043,rx = 180,ry = 0,rz = 0}, 
    {x = 14795,4105.1455078125,y = -1620.6474609375,z = 216.1208190918,rx = 0,ry = 0,rz = 0} 
} 
  
markers = { 
    {x = 2066.962890625,y = -1831.306640625,z = 13.546875}, 
    {x = 1848.5556640625,y = -1856.2978515625,z = 13.3828125}, 
    {x = 1024.705078125,y = -1025.365234375,z = 32.1015625}, 
    {x = -1936.2119140625,y = 243.2685546875,z = 34.4609375}, 
    {x = -1904.5869140625,y = 282.06640625,z = 41.046875}, 
    {x = -2426.064453125,y = 1023.9189453125,z = 50.397659301758}, 
    {x = -1786.8173828125,y = 1212.4912109375,z = 25.125}, 
    {x = -1420.451171875,y = 2587.189453125,z = 55.84326171875} 
} 
  
for _,g in ipairs(garages) do 
    garage = createObject(g.x,g.y,g.z,g.rx,g.ry,g.rz) 
end 
  
for _,t in pairs(markers) do 
    marker = createMarker(t.x,t.y,t.z-1,"cylinder",3,255,255,255,255) 
    addEventHandler("onMarkerHit",marker, 
    function (element,dimension) 
        if (getElementType(element) == "vehicle") then 
            setElementPosition(element,4104.921875,-1621.7041015625,211.47169494629) 
            setElementFrozen(element,true) 
        end 
    end) 
end 

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