Jump to content

help with code


Recommended Posts

this work doesn't work why?

function enterPlane(theVehicle, seat, jacked) 
    if (getVehicleType(theVehicle) == "Plane" or "Helicopter") then 
        outputChatBox("Welcome onboard!", source) 
addCommandHandler("test", enterPlane) 

i wanna when someone enter Plane or Helicopter and make command test a message appear for him!

Link to comment
  • Other Languages Moderators

First argument in function-handler is player not vehicle. ( and this arguments: seat, jacked incorrect because seat is not seat it's commandName, jacked is argument when you type in command /test [argument] ). Forgot say, /test command is MTA command, so you need rename it. Also if you want get player's vehicle you need use



outputChatBox("Welcome onboard!", source) 

source is not defined


if (getVehicleType(theVehicle) == "Plane" or "Helicopter") then 

Condition is wrong. Because condition will work with any vehicle type.

For example

function show( s ) 
    if s == '1' or '2' then 
        print 'y' 
        print 'n' 
show '1' --> y 
show '5' --> y 

So it's correct:

local sVehicleType = getVehicleType( theVehicle ) 
if sVehicleType == "Plane" or sVehicleType == "Helicopter" then 

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