Jump to content

Some help


sckatchof

Recommended Posts

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
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 by Guest
Link to comment
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

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

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

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

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

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