Lloyd Logan Posted January 13, 2014 Share Posted January 13, 2014 (edited) Yeah as the title says, this code doesn't do anything club = setElementData(vehcreates[1],"club",true) 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 ) } function onmarker() outputChatBox("This vehicle is a " .. club .. "!") end addEventHandler("onClientMarkerHit", vehcreates[1], onmarker) Maybe i'm missing somethingout! Edited January 13, 2014 by Guest Link to comment
K4stic Posted January 13, 2014 Share Posted January 13, 2014 club = setElementData(vehcreates[1],"club",true) You must add it under the table as you use it so add it under and no over the table Link to comment
Lloyd Logan Posted January 13, 2014 Author Share Posted January 13, 2014 club = setElementData(vehcreates[1],"club",true) You must add it under the table as you use it so add it under and no over the table It was originally under the table, but didn't work like that! Link to comment
Moderators IIYAMA Posted January 13, 2014 Moderators Share Posted January 13, 2014 This event triggers only when a player hit's it. function onmarker(player) local vehicle = getPedOccupiedVehicle (player) if vehicle and getElementData( vehicle,"club") then outputChatBox("This vehicle is a " .. tostring(vehicle) .. "!") -- user data.... end end addEventHandler("onClientMarkerHit", root, onmarker) addEventHandler("onClientMarkerHit", root, onmarker) Is the marker....... club = setElementData(vehcreates[1],"club",true) AND YES IT MUST BE UNDER THE TABLE...... You can't do something with an element that doesn't exist yet........ Link to comment
Lloyd Logan Posted January 13, 2014 Author Share Posted January 13, 2014 I think you're getting me wrong, what I am trying to do is; -----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 ) } addEventHandler("onClientMarkerHit", vehcreates[1], ---THIS BIT HERE?! function () outputChatBox("This vehicle is a " ..club.. "!") end ) club = setElementData(vehcreates[1],"club",true) buccaneer = setElementData(vehcreates[2],"buccaneer",true) buffalo = setElementData(vehcreates[3],"buffalo",true) phoenix = setElementData(vehcreates[4],"phoenix",true) comet = setElementData(vehcreates[5],"comet",true) cheetah = setElementData(vehcreates[6],"cheetah",true) elgy = setElementData(vehcreates[7],"elgy",true) bullet = setElementData(vehcreates[8],"bullet",true) turismo = setElementData(vehcreates[9],"turismo",true) supergt = setElementData(vehcreates[10],"supergt",true) uranus = setElementData(vehcreates[11],"uranus",true) jester = setElementData(vehcreates[12],"jester",true) flash = setElementData(vehcreates[13],"flash",true) buffalotwo = setElementData(vehcreates[14],"buffalotwo",true) clover = setElementData(vehcreates[15],"clover",true) elgytwo = setElementData(vehcreates[16],"elgytwo",true) phoenixtwo = setElementData(vehcreates[17],"phoenixtwo",true) banshee = setElementData(vehcreates[18],"banshee",true) -----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" ) for i, v in ipairs ( vehmarkers ) do setElementParent ( v, ele ) setElementAlpha(v, 50) end Link to comment
DNL291 Posted January 13, 2014 Share Posted January 13, 2014 (edited) Try: -----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 ) } addEventHandler("onClientMarkerHit", vehmarkers[1], function () local vehName = getElementData(vehcreates[1], "vehicle-1") outputChatBox("This vehicle is a " ..getVehicleName(vehName).. "!") end ) for i, v in ipairs(vehcreates) do setElementData(v, "vehicle-"..tostring(i), v) end -----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" ) for i, v in ipairs ( vehmarkers ) do setElementParent ( v, ele ) setElementAlpha(v, 50) end Or you can just do this: addEventHandler("onClientMarkerHit", vehmarkers[1], function () outputChatBox("This vehicle is a " ..getVehicleName(vehcreates[1]).. "!") end) Edited January 13, 2014 by Guest Link to comment
Moderators IIYAMA Posted January 13, 2014 Moderators Share Posted January 13, 2014 No I don't get what you mean.... Why don't you just do: https://wiki.multitheftauto.com/wiki/GetVehicleName Instead of wasting your ram. And go read this: onClientMarkerHit Clientside event This event is triggered when a player enters a marker created using createMarker. Parameters player hitPlayer, bool matchingDimension hitPlayer: The player that hit the marker matchingDimension: true if the player is in the same dimension as the marker he hit Source The source of this event is the marker that got hit by the player. Example This code will output a message to the chatbox whenever any player walks into any marker. function MarkerHit ( hitPlayer, matchingDimension ) outputChatBox ( getPlayerName(hitPlayer) .. " entered a marker" ) end addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now