sckatchof Posted March 11, 2012 Share Posted March 11, 2012 hi guys i have a small problem the script work but i have some errors : lien 12 "getElementData server side : local vehicleMarker1 = createMarker( x, y, z, 'cylinder', 1, 255, 255, 255, 150 ) function vehicleMarkerHit ( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" and not isPedInVehicle (hitElement) then getElementData ( hitElement, "Job", "Taxi Driver", true ) local vehicle = createVehicle ( 420, x, y, z, 0, 0, 0 ) warpPedIntoVehicle(hitElement, vehicle) end end addEventHandler( "onMarkerHit", vehicleMarker1 , vehicleMarkerHit ) Link to comment
X-SHADOW Posted March 11, 2012 Share Posted March 11, 2012 so the probelm is not set the element or the event wrong or what ? i dont see any error with getElementData Link to comment
sckatchof Posted March 11, 2012 Author Share Posted March 11, 2012 (edited) so the probelm is not set the element or the event wrong or what ?i dont see any error with getElementData that is my problem ==> WARING : Myscript.lua:12: bad argument @'getElementData' [expected bool at argument 3, got string 'Taxi Driver' Edited March 11, 2012 by Guest Link to comment
IncreEngine Posted March 11, 2012 Share Posted March 11, 2012 getElementData ( hitElement, "Job", true ) Show your setElementData code. Link to comment
sckatchof Posted March 11, 2012 Author Share Posted March 11, 2012 getElementData ( hitElement, "Job", true ) Show your setElementData code. Thanks for help but it wok for all jobs i have make many job like pilot or limo driver . local vehicleMarker1 = createMarker( x, y, z, 'cylinder', 1, 255, 255, 255, 150 ) local Taxijob = "Taxi Driver" function vehicleMarkerHit ( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" and not isPedInVehicle (hitElement) then getElementData ( hitElement, "Job", Taxijob, true ) local vehicle = createVehicle ( 420, x, y, z, 0, 0, 0 ) warpPedIntoVehicle(hitElement, vehicle) end end addEventHandler( "onMarkerHit", vehicleMarker1 , vehicleMarkerHit ) Link to comment
drk Posted March 11, 2012 Share Posted March 11, 2012 LOL? So easy to see the problem. getElementData wrong arguments. local vehicleMarker1 = createMarker( x, y, z, 'cylinder', 1, 255, 255, 255, 150 ) function vehicleMarkerHit ( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" and not isPedInVehicle (hitElement) then if ( getElementData ( hitElement, "Job" ) == "Taxi Driver" ) then -- Maybe this is what you want local vehicle = createVehicle ( 420, x, y, z, 0, 0, 0 ) warpPedIntoVehicle(hitElement, vehicle) end end end addEventHandler( "onMarkerHit", vehicleMarker1 , vehicleMarkerHit ) Link to comment
GanJaRuleZ Posted March 11, 2012 Share Posted March 11, 2012 You can make like this : local vehicleMarker1 = createMarker( x, y, z, 'cylinder', 1, 255, 255, 255, 150 ) local Taxijob = "Taxi Driver" function vehicleMarkerHit ( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" and not isPedInVehicle (hitElement) then local job = getElementData ( hitElement, "Job", true ) if ( job == "Taxi Driver" ) then local vehicle = createVehicle ( 420, x, y, z, 0, 0, 0 ) warpPedIntoVehicle(hitElement, vehicle) elseif ( job == 'Limo Driver") then --etc etc end end addEventHandler( "onMarkerHit", vehicleMarker1 , vehicleMarkerHit ) Link to comment
drk Posted March 11, 2012 Share Posted March 11, 2012 LOL? Why create a variable with string "Taxi Driver" ? And why you need to do local job = getElementData ( hitElement, "Job", true ) if ( job == "Taxi Driver" ) then Mine is better: if ( getElementData ( hitElement, "Job", true ) == "Taxi Driver" ) then Link to comment
GanJaRuleZ Posted March 11, 2012 Share Posted March 11, 2012 Actually , i copied the script , and changed just that 2 lines , but mine is better in big scaled.. Just think out : Somewhere 50 jobs , for every line do "if ( getElementData ( hitElement, "Job", true ) == "Taxi Driver"" instead of ' if ( job == "Taxi Driver" ) then" .. Think logic. Link to comment
drk Posted March 11, 2012 Share Posted March 11, 2012 But why need create a variable with a string "Taxi Driver" ? Link to comment
sckatchof Posted March 11, 2012 Author Share Posted March 11, 2012 thanks guys it work Link to comment
GanJaRuleZ Posted March 11, 2012 Share Posted March 11, 2012 Np , @Draken , i forgot about it 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