Jump to content

createVehicle


Recommended Posts

Posted

Hello. I made a very simple createVehicle command, i need help with, how can i add to this "blocked" vehicles ?

I dont know what should i do, i have to add table with vehicle id-s and with names? Or how can i block some vehicle which is can not be spawned?

local vehicleSlotID = 0
addCommandHandler("makeveh",function(source,cmd,...)
    if not (...) then return outputChatBox("/"..cmd.." [ID/ VehicleName]",source) end
    local playerX, playerY, playerZ = getElementPosition(source)
    local vehicleName = table.concat({...}, "")
    local vehicleID = getVehicleModelFromName(vehicleName)
    local createdVehicle = createVehicle(vehicleID or vehicleName,playerX,playerY,playerZ)
    vehicleSlotID = vehicleSlotID+1
    warpPedIntoVehicle(source, createdVehicle)
end)

 

Posted

Try this:

local disallowedVehs = {
	[435] = true, [441] = true, [449] = true
}
local vehicleSlotID = 0
addCommandHandler("makeveh",function(source,cmd, vehicle)
	if not vehicle then return outputChatBox("/"..cmd.." [ID/ VehicleName]",source) end
	local playerX, playerY, playerZ = getElementPosition(source)
	local vehID = tonumber(vehicle) and tonumber(vehicle) or getVehicleModelFromName(vehicle)
	
	if vehID and not disallowedVehs[ vehID ] then
		local createdVehicle = createVehicle(vehID,playerX,playerY,playerZ)
		vehicleSlotID = vehicleSlotID+1
		warpPedIntoVehicle(source, createdVehicle)
	end
end)

Not tested, just add the blocked vehicles in the table.

Please do not PM me with scripting related question nor support, use the forums instead.

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