Jump to content

Why doesn't this work?


Lloyd Logan

Recommended Posts

Hi, I've set the parent, so why doesn't this work? If you look where i put ----THIS HERE!! (Line 48) It's supposed to output the vehicle name, but it doesn't!

-----CREATE THE VEHICLES----- 
vehcreates = { 
    [1] = createVehicle(589, 561.3701171875, -1289.9091796875, 17.248237609863), 
    [2] = createVehicle(518, 556.1318359375, -1290.0322265625, 17.248237609863 ), 
    [3] = createVehicle(402, 550.7373046875, -1289.525390625, 17.248237609863 ), 
    [4] = createVehicle(603, 545.7001953125, -1289.4248046875, 17.248237609863), 
    [5] = createVehicle(480, 540.79296875, -1289.3271484375, 17.2421875 ), 
    [6] = createVehicle(415, 535.57421875, -1289.22265625, 17.2421875), 
    [7] = createVehicle(562, 530.060546875, -1289.1123046875, 17.2421875), 
    [8] = createVehicle(541, 542.0224609375, -1276.32421875, 17.2421875), 
    [9] = createVehicle(451, 548.0458984375, -1276.681640625, 17.248237609863 ), 
    [10] = createVehicle(506, 554.1796875, -1274.70703125, 17.248237609863), 
    [11] = createVehicle(558,558.728515625, -1273.3828125, 17.2421875), 
    [12] = createVehicle(559, 514.390625, -1300.3056640625, 17.242187), 
    [13] = createVehicle(565, 511.8505859375, -1306.9794921875, 17.2421875), 
    [14] = createVehicle(402, 512.4658203125, -1313.7265625, 17.2421875 ), 
    [15] = createVehicle(542, 544.9677734375, -1282.751953125, 17.248237609863 ), 
    [16] = createVehicle(562, 551.22265625, -1282.5458984375, 17.248237609863  ), 
    [17] = createVehicle(603, 557.4365234375, -1282.0048828125, 17.248237609863 ), 
    [18] = createVehicle(429, 563.5048828125, -1281.46875, 17.248237609863 ) 
} 
  
  
 -----CREATING THE MARKERS------ 
vehmarkers = { 
[1] = createMarker (559.7255859375, -1289.8505859375, 16.248237609863, "cylinder", 0.96),  
[2] = createMarker(554.44921875, -1289.7578125, 16.248237609863, "cylinder", 0.96),  
[3] = createMarker(548.9931640625, -1289.76171875, 16.248237609863 , "cylinder", 0.96),  
[4] = createMarker(543.8017578125, -1289.751953125, 16.2421875, "cylinder", 0.96),  
[5] = createMarker(539.234375, -1289.666015625, 16.2421875, "cylinder", 0.96),  
[6] = createMarker(534.0244140625, -1289.1962890625, 16.2421875 , "cylinder", 0.96),  
[7] = createMarker(528.0390625, -1289.3095703125, 16.2421875 , "cylinder", 0.96),  
[8] = createMarker(542.8017578125, -1283.4443359375, 16.2421875 , "cylinder", 0.96),  
[9] = createMarker(549.5830078125, -1282.9765625, 16.248237609863 , "cylinder", 0.96), 
[10] = createMarker(555.8544921875, -1282.7373046875, 16.248237609863, "cylinder", 0.96),  
[11] = createMarker(561.4638671875, -1281.9423828125, 16.248237609863 , "cylinder", 0.96), 
[12] = createMarker(556.8466796875, -1273.330078125, 16.2421875 , "cylinder", 0.96), 
[13] = createMarker(552.474609375, -1274.5380859375, 16.248237609863 , "cylinder", 0.96), 
[14] = createMarker(546.3779296875, -1276.5166015625, 16.248237609863, "cylinder", 0.96), 
[15] = createMarker(540.3125, -1276.3251953125, 16.2421875, "cylinder", 0.96) 
} 
  
-----SETTING PARENT TO THE MARKERS----- 
ele = createElement ( "markers" ) 
  
setElementParent(vehmarkers[1], vehcreates[1] ) 
  
addEventHandler("onClientMarkerHit", vehmarkers[1], ---THIS HERE!!!! 
function () 
    name1 = getElementParent(unpack (vehmarkers [1])) 
    outputChatBox("This vehicle is a " ..name1.. "!") 
end 
) 
  
  
for i, v in ipairs ( vehmarkers ) do 
    setElementParent ( v, ele ) 
    setElementAlpha(v, 50) 
end 

Link to post
-----CREATE THE VEHICLES----- 
vehcreates = { 
    [1] = createVehicle(589, 561.3701171875, -1289.9091796875, 17.248237609863), 
    [2] = createVehicle(518, 556.1318359375, -1290.0322265625, 17.248237609863 ), 
    [3] = createVehicle(402, 550.7373046875, -1289.525390625, 17.248237609863 ), 
    [4] = createVehicle(603, 545.7001953125, -1289.4248046875, 17.248237609863), 
    [5] = createVehicle(480, 540.79296875, -1289.3271484375, 17.2421875 ), 
    [6] = createVehicle(415, 535.57421875, -1289.22265625, 17.2421875), 
    [7] = createVehicle(562, 530.060546875, -1289.1123046875, 17.2421875), 
    [8] = createVehicle(541, 542.0224609375, -1276.32421875, 17.2421875), 
    [9] = createVehicle(451, 548.0458984375, -1276.681640625, 17.248237609863 ), 
    [10] = createVehicle(506, 554.1796875, -1274.70703125, 17.248237609863), 
    [11] = createVehicle(558,558.728515625, -1273.3828125, 17.2421875), 
    [12] = createVehicle(559, 514.390625, -1300.3056640625, 17.242187), 
    [13] = createVehicle(565, 511.8505859375, -1306.9794921875, 17.2421875), 
    [14] = createVehicle(402, 512.4658203125, -1313.7265625, 17.2421875 ), 
    [15] = createVehicle(542, 544.9677734375, -1282.751953125, 17.248237609863 ), 
    [16] = createVehicle(562, 551.22265625, -1282.5458984375, 17.248237609863  ), 
    [17] = createVehicle(603, 557.4365234375, -1282.0048828125, 17.248237609863 ), 
    [18] = createVehicle(429, 563.5048828125, -1281.46875, 17.248237609863 ) 
} 
  
  
 -----CREATING THE MARKERS------ 
vehmarkers = { 
[1] = createMarker (559.7255859375, -1289.8505859375, 16.248237609863, "cylinder", 0.96), 
[2] = createMarker(554.44921875, -1289.7578125, 16.248237609863, "cylinder", 0.96), 
[3] = createMarker(548.9931640625, -1289.76171875, 16.248237609863 , "cylinder", 0.96), 
[4] = createMarker(543.8017578125, -1289.751953125, 16.2421875, "cylinder", 0.96), 
[5] = createMarker(539.234375, -1289.666015625, 16.2421875, "cylinder", 0.96), 
[6] = createMarker(534.0244140625, -1289.1962890625, 16.2421875 , "cylinder", 0.96), 
[7] = createMarker(528.0390625, -1289.3095703125, 16.2421875 , "cylinder", 0.96), 
[8] = createMarker(542.8017578125, -1283.4443359375, 16.2421875 , "cylinder", 0.96), 
[9] = createMarker(549.5830078125, -1282.9765625, 16.248237609863 , "cylinder", 0.96), 
[10] = createMarker(555.8544921875, -1282.7373046875, 16.248237609863, "cylinder", 0.96), 
[11] = createMarker(561.4638671875, -1281.9423828125, 16.248237609863 , "cylinder", 0.96), 
[12] = createMarker(556.8466796875, -1273.330078125, 16.2421875 , "cylinder", 0.96), 
[13] = createMarker(552.474609375, -1274.5380859375, 16.248237609863 , "cylinder", 0.96), 
[14] = createMarker(546.3779296875, -1276.5166015625, 16.248237609863, "cylinder", 0.96), 
[15] = createMarker(540.3125, -1276.3251953125, 16.2421875, "cylinder", 0.96) 
} 
  
-----SETTING PARENT TO THE MARKERS----- 
ele = createElement ( "markers" ) 
  
setElementParent(vehmarkers[1], vehcreates[1] ) 
  
addEventHandler("onClientMarkerHit", vehmarkers[1], ---THIS HERE!!!! 
    function ( ) 
        local vehicle = getElementParent ( source ) 
        if ( vehicle ) then 
            outputChatBox ( "This vehicle is a ".. getVehicleName ( vehicle ) .."!" ) 
        end 
    end 
) 
  
  
for i, v in ipairs ( vehmarkers ) do 
    setElementParent ( v, ele ) 
    setElementAlpha(v, 50) 
end 

Link to post
-----CREATE THE VEHICLES----- 
vehcreates = { 
    [1] = createVehicle(589, 561.3701171875, -1289.9091796875, 17.248237609863), 
    [2] = createVehicle(518, 556.1318359375, -1290.0322265625, 17.248237609863 ), 
    [3] = createVehicle(402, 550.7373046875, -1289.525390625, 17.248237609863 ), 
    [4] = createVehicle(603, 545.7001953125, -1289.4248046875, 17.248237609863), 
    [5] = createVehicle(480, 540.79296875, -1289.3271484375, 17.2421875 ), 
    [6] = createVehicle(415, 535.57421875, -1289.22265625, 17.2421875), 
    [7] = createVehicle(562, 530.060546875, -1289.1123046875, 17.2421875), 
    [8] = createVehicle(541, 542.0224609375, -1276.32421875, 17.2421875), 
    [9] = createVehicle(451, 548.0458984375, -1276.681640625, 17.248237609863 ), 
    [10] = createVehicle(506, 554.1796875, -1274.70703125, 17.248237609863), 
    [11] = createVehicle(558,558.728515625, -1273.3828125, 17.2421875), 
    [12] = createVehicle(559, 514.390625, -1300.3056640625, 17.242187), 
    [13] = createVehicle(565, 511.8505859375, -1306.9794921875, 17.2421875), 
    [14] = createVehicle(402, 512.4658203125, -1313.7265625, 17.2421875 ), 
    [15] = createVehicle(542, 544.9677734375, -1282.751953125, 17.248237609863 ), 
    [16] = createVehicle(562, 551.22265625, -1282.5458984375, 17.248237609863  ), 
    [17] = createVehicle(603, 557.4365234375, -1282.0048828125, 17.248237609863 ), 
    [18] = createVehicle(429, 563.5048828125, -1281.46875, 17.248237609863 ) 
} 
  
  
 -----CREATING THE MARKERS------ 
vehmarkers = { 
[1] = createMarker (559.7255859375, -1289.8505859375, 16.248237609863, "cylinder", 0.96), 
[2] = createMarker(554.44921875, -1289.7578125, 16.248237609863, "cylinder", 0.96), 
[3] = createMarker(548.9931640625, -1289.76171875, 16.248237609863 , "cylinder", 0.96), 
[4] = createMarker(543.8017578125, -1289.751953125, 16.2421875, "cylinder", 0.96), 
[5] = createMarker(539.234375, -1289.666015625, 16.2421875, "cylinder", 0.96), 
[6] = createMarker(534.0244140625, -1289.1962890625, 16.2421875 , "cylinder", 0.96), 
[7] = createMarker(528.0390625, -1289.3095703125, 16.2421875 , "cylinder", 0.96), 
[8] = createMarker(542.8017578125, -1283.4443359375, 16.2421875 , "cylinder", 0.96), 
[9] = createMarker(549.5830078125, -1282.9765625, 16.248237609863 , "cylinder", 0.96), 
[10] = createMarker(555.8544921875, -1282.7373046875, 16.248237609863, "cylinder", 0.96), 
[11] = createMarker(561.4638671875, -1281.9423828125, 16.248237609863 , "cylinder", 0.96), 
[12] = createMarker(556.8466796875, -1273.330078125, 16.2421875 , "cylinder", 0.96), 
[13] = createMarker(552.474609375, -1274.5380859375, 16.248237609863 , "cylinder", 0.96), 
[14] = createMarker(546.3779296875, -1276.5166015625, 16.248237609863, "cylinder", 0.96), 
[15] = createMarker(540.3125, -1276.3251953125, 16.2421875, "cylinder", 0.96) 
} 
  
-----SETTING PARENT TO THE MARKERS----- 
ele = createElement ( "markers" ) 
  
setElementParent(vehmarkers[1], vehcreates[1] ) 
  
addEventHandler("onClientMarkerHit", vehmarkers[1], ---THIS HERE!!!! 
    function ( ) 
        local vehicle = getElementParent ( source ) 
        if ( vehicle ) then 
            outputChatBox ( "This vehicle is a ".. getVehicleName ( vehicle ) .."!" ) 
        end 
    end 
) 
  
  
for i, v in ipairs ( vehmarkers ) do 
    setElementParent ( v, ele ) 
    setElementAlpha(v, 50) 
end 

This doesn't work Castillo!

Link to post
-----CREATE THE VEHICLES----- 
vehcreates = { 
    [1] = createVehicle(589, 561.3701171875, -1289.9091796875, 17.248237609863), 
    [2] = createVehicle(518, 556.1318359375, -1290.0322265625, 17.248237609863 ), 
    [3] = createVehicle(402, 550.7373046875, -1289.525390625, 17.248237609863 ), 
    [4] = createVehicle(603, 545.7001953125, -1289.4248046875, 17.248237609863), 
    [5] = createVehicle(480, 540.79296875, -1289.3271484375, 17.2421875 ), 
    [6] = createVehicle(415, 535.57421875, -1289.22265625, 17.2421875), 
    [7] = createVehicle(562, 530.060546875, -1289.1123046875, 17.2421875), 
    [8] = createVehicle(541, 542.0224609375, -1276.32421875, 17.2421875), 
    [9] = createVehicle(451, 548.0458984375, -1276.681640625, 17.248237609863 ), 
    [10] = createVehicle(506, 554.1796875, -1274.70703125, 17.248237609863), 
    [11] = createVehicle(558,558.728515625, -1273.3828125, 17.2421875), 
    [12] = createVehicle(559, 514.390625, -1300.3056640625, 17.242187), 
    [13] = createVehicle(565, 511.8505859375, -1306.9794921875, 17.2421875), 
    [14] = createVehicle(402, 512.4658203125, -1313.7265625, 17.2421875 ), 
    [15] = createVehicle(542, 544.9677734375, -1282.751953125, 17.248237609863 ), 
    [16] = createVehicle(562, 551.22265625, -1282.5458984375, 17.248237609863  ), 
    [17] = createVehicle(603, 557.4365234375, -1282.0048828125, 17.248237609863 ), 
    [18] = createVehicle(429, 563.5048828125, -1281.46875, 17.248237609863 ) 
} 
  
  
 -----CREATING THE MARKERS------ 
vehmarkers = { 
[1] = createMarker (559.7255859375, -1289.8505859375, 16.248237609863, "cylinder", 0.96), 
[2] = createMarker(554.44921875, -1289.7578125, 16.248237609863, "cylinder", 0.96), 
[3] = createMarker(548.9931640625, -1289.76171875, 16.248237609863 , "cylinder", 0.96), 
[4] = createMarker(543.8017578125, -1289.751953125, 16.2421875, "cylinder", 0.96), 
[5] = createMarker(539.234375, -1289.666015625, 16.2421875, "cylinder", 0.96), 
[6] = createMarker(534.0244140625, -1289.1962890625, 16.2421875 , "cylinder", 0.96), 
[7] = createMarker(528.0390625, -1289.3095703125, 16.2421875 , "cylinder", 0.96), 
[8] = createMarker(542.8017578125, -1283.4443359375, 16.2421875 , "cylinder", 0.96), 
[9] = createMarker(549.5830078125, -1282.9765625, 16.248237609863 , "cylinder", 0.96), 
[10] = createMarker(555.8544921875, -1282.7373046875, 16.248237609863, "cylinder", 0.96), 
[11] = createMarker(561.4638671875, -1281.9423828125, 16.248237609863 , "cylinder", 0.96), 
[12] = createMarker(556.8466796875, -1273.330078125, 16.2421875 , "cylinder", 0.96), 
[13] = createMarker(552.474609375, -1274.5380859375, 16.248237609863 , "cylinder", 0.96), 
[14] = createMarker(546.3779296875, -1276.5166015625, 16.248237609863, "cylinder", 0.96), 
[15] = createMarker(540.3125, -1276.3251953125, 16.2421875, "cylinder", 0.96) 
} 
  
local link = { } 
  
-----SETTING PARENT TO THE MARKERS----- 
ele = createElement ( "markers" ) 
for i, v in ipairs ( vehmarkers ) do 
    setElementParent ( v, ele ) 
    setElementAlpha ( v, 50 ) 
    link [ v ] = vehcreates [ i ] 
end 
  
addEventHandler ( "onClientMarkerHit", root, ---THIS HERE!!!! 
    function ( hitElement ) 
        if ( hitElement == localPlayer ) then 
            local vehicle = link [ source ] 
            if ( vehicle ) then 
                outputChatBox ( "This vehicle is a ".. getVehicleName ( vehicle ) .."!" ) 
            end 
        end 
    end 
) 

Some of the vehicles from the table don't match the index of the marker.

Link to post
Is a table where the markers are stored.

Oh right thanks! I have one more question, say I had the createVehicle, how would I setElementData to a number?

Something like;

  
veh = createVehicle(blahblah) 
setElementData(veh, blah, blah) --This would be a number to represent the price! 
  

Link to post

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