Sign in to follow this  

vehicle ID

Recommended Posts

Hello, how can i make something thins?


I want set id for each vehicle which is spawned. Then i can create /getcar command. I dont want to save this forever.


local vehS = 0

function createVeh(player,CMD,veh)

local vehName = getVehicleIDFromName(veh)
local x, y, z = getElementPosition(player)

    if vehName == false then
        vehS + 1
        theveh = createVehicle(vehName,x+5,y,z)    



Share this post

Link to post

Okay, so you asked a question, but you already have the answer as well, what do you expect from us..?

  • Like 2

Share this post

Link to post

So, what you want  from us?To create a getcar command?If so, here it is:

function getCar(c,p,id)
  if not id then outputChatBox("Please enter a valid vehID",p) return end
    for k,v in ipairs(getElementsByType("vehicle")) do
    	if getElementData(v, "vehID") == id then
      		setElementPosition(v, Vector3(getElementPosition(p)))
      		outputChatBox("Here it is!",p)
    	outputChatBox("Invalid vehID",p)
addCommandHandler("getcar", getCar, false,false)


Share this post

Link to post

No. :D So i tried to create  the "cv" command, but when i create the vehicle, the  "vehS + 1 not changing, so something wrong with that, i need help with that.

so the car id is always 0 or 1..

Edited by TheMOG

Share this post

Link to post

ahh, vehS = vehS + 1

The problem was, that u didnt saved the last number.

Edited by Pirulax

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.