Sign in to follow this  
Smallo

Help with Vehicle Cmd

Recommended Posts

i am trying to make a code so when i type /carhelp a message goes into the chatbox and says

"Type /(vehiclename)-off To Turn The Custom Model Off"

"Or Type /(vehiclename)-on To Turn The Custom Model On"

ofcourse i am trying to use the GetVehicleName function and the GetVehicleId Function but seem to be having no luck at all. If anyone could help me to get this working it would be greatly appreciated.

heres the script

  
function carhelp ( ) 
local id = getVehicleID ( ) 
if id = 451 then 
       local vehiclename = getVehicleName ( ) 
       outputChatBox ( "Type /" .. vehiclename .. "-off To Turn The Custom Model Off",  0, 255, 0, true ) 
       outputChatBox ( "Type /" .. vehiclename .. "-on To Turn The Custom Model On",  0, 255, 0, true )  
          else 
       outputChatBox ( "This Vehicle Does Not Have A Custom Model." ,255,0,0 ) 
end 
end 
  
addCommandHandler ( "carhelp", carhelp ) 
  

and my Meta.xml

  
<meta> 
    <info author="Smallo" name="carhelp" version="1" type="script" /> 
    <script src="carhelp.lua" type="client" /> 
</meta>  
  

Share this post


Link to post
Guest

try

function carhelp ( )

local id = getVehicleID ( )

if id = 451 then

local vehiclename = getVehicleName ( )

outputChatBox ( "Type /" .. vehiclename "-off To Turn The Custom Model Off , 0, 255, 0, true )

outputChatBox ( "Type /" .. vehiclename "-on To Turn The Custom Model On , 0, 255, 0, true )

else

outputChatBox ( "This Vehicle Does Not Have A Custom Model." ,255,0,0 )

end

end

addCommandHandler ( "carhelp", carhelp )

or

function carhelp ( )

local id = getVehicleID ( )

if id = 451 then

local vehiclename = getVehicleName ( )

outputChatBox ( "Type /" .. vehiclename .. "-off To Turn The Custom Model Off , 0, 255, 0, true )

outputChatBox ( "Type /" .. vehiclename .. "-on To Turn The Custom Model On , 0, 255, 0, true )

else

outputChatBox ( "This Vehicle Does Not Have A Custom Model." ,255,0,0 )

end

end

addCommandHandler ( "carhelp", carhelp )

Share this post


Link to post

no offence but all you did was remove 2 of these "

which didn't solve the problem just made more thanks for your help anyways.

it think the problem is with GetVehicleId because it says when i am not in car 451 but when i am in car 451 is just doesnt say anything when i type.

Share this post


Link to post

smallo try this

function carhelp ( player )

local id = getVehicleID (getPlayerOccupiedVehicle ( player ))

if id = 451 then

local vehiclename = getVehicleName (getPlayerOccupiedVehicle ( player ) )

outputChatBox ( "Type /" .. vehiclename .. "-off To Turn The Custom Model Off", player , 255, 0, 0,true )

outputChatBox ( "Type /" .. vehiclename .. "-on To Turn The Custom Model On", player , 255, 0, 0, true )

else

outputChatBox ( "This Vehicle Does Not Have A Custom Model." , player ,255 ,0 ,0 )

end

end

addCommandHandler ( "carhelp", carhelp )

Share this post


Link to post

Also,

  
 if id = 451 then 
  

should be

  
 if id == 451 then 
  

Share this post


Link to post

i just tested this and it works fine..

function carhelp ( player )

local veh = getPlayerOccupiedVehicle ( player )

if ( veh ) then

local id = getVehicleID ( veh )

if ( id == 451 ) then

local vehiclename = getVehicleName ( veh )

outputChatBox ( "Type /" .. vehiclename .. "-off To Turn The Custom Model Off", player , 255, 0, 0,true )

outputChatBox ( "Type /" .. vehiclename .. "-on To Turn The Custom Model On", player , 255, 0, 0, true )

else

outputChatBox ( "This Vehicle Does Not Have A Custom Model." , player ,255 ,0 ,0 )

end

else

outputChatBox ( "You Are Not In A Car." , player ,255 ,0 ,0 )

end

end

addCommandHandler ( "carhelp", carhelp )

Share this post


Link to post

kool thank-you but it still doesnt seem to work in my server :P its saying im not in a car all the time.

Share this post


Link to post

yes i restarted the script and there were no errors in the debug! i dont know whats wrong. should it be a client script or a server script??

Share this post


Link to post

sh!t just found the problem i had it running as a client script when it should only be a server script it works now thanks for all your help and troubles!plan to see it in our server soon

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.