Jump to content

how can i check vehicle id?


Stevenn

Recommended Posts

how can I use it like this:

if ( hitElement == localPlayer and source == cMarker and isTruck(lp) ) then  

and

function isTruck(lp) 
if ( getElementModel ( getPedOccupiedVehicle ( localPlayer ) ) == 437 ) then 
return true 
end 
end 

or

if ( hitElement == localPlayer and source == cMarker and ( getElementModel ( getPedOccupiedVehicle ( localPlayer ) ) == 437 ) ) then  

none of them works, bad argument..

Link to comment

If you're saying about your other code about trucks:

if ( hitElement == uPlayer and source == cMarker and isTruck ( uPlayer ) ) then 

isTruck = function ( uPlayer ) 
    if ( getElementModel ( getPedOccupiedVehicle ( uPlayer ) ) == 437 ) then 
        return true; 
    else 
        return false; 
    end 
end 

Link to comment

if you're making a separate function, you should at least check if player is in a vehicle at all, otherwise getElementModel() will error.

isTruck = function ( uPlayer ) 
    if isPedInVehicle(uPlayer) then 
        return getElementModel ( getPedOccupiedVehicle ( uPlayer ) ) == 437 
    else  
        return false  
    end 
end 

Link to comment

It's rly easy to understand. If someone condition return false then this function return false otherwise true.

  
print( false and false and false and false ) -- false 
print( false and true ) -- false 
print( false or true ) -- true 
print( 1 == 1 and true or false ) -- true 
print( 1 == 1 ) -- true 
print( 1 ~= 1 ) -- false 
print( 1 ~= 1 and 0 or 1 ) -- 1 
print( true ~= true and true or false ) -- false 
  

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