Stevenn Posted April 15, 2012 Share Posted April 15, 2012 hey, im trying to use local lp = getLocalPlayer() if getElementModel(getPedOccupiedVehicle(lp)) == 437 but it gives me: bad argument @ 'getElementModel' Link to comment
drk Posted April 15, 2012 Share Posted April 15, 2012 if ( getElementModel ( getPedOccupiedVehicle ( localPlayer ) ) == 437 ) then It works. Link to comment
Stevenn Posted April 15, 2012 Author Share Posted April 15, 2012 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
drk Posted April 15, 2012 Share Posted April 15, 2012 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
Aibo Posted April 15, 2012 Share Posted April 15, 2012 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
Kenix Posted April 15, 2012 Share Posted April 15, 2012 function isTruck ( uPlayer ) return isElement( uPlayer ) and isPedInVehicle( uPlayer ) and getElementModel( getPedOccupiedVehicle( uPlayer ) ) == 437 end Link to comment
Aibo Posted April 15, 2012 Share Posted April 15, 2012 you're not really making it easy for people to understand, are you? Link to comment
Kenix Posted April 15, 2012 Share Posted April 15, 2012 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
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