Jump to content

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
        ---
    else
        vehS + 1
        theveh = createVehicle(vehName,x+5,y,z)    
        setElementData(theveh,"vehID",vehS) 

    end
end
addCommandHandler("cv",createVeh)

 

Link to comment
  • Discord Moderators

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)
      		return
      	end
    	outputChatBox("Invalid vehID",p)
    end
  end
end
addCommandHandler("getcar", getCar, 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...