GetRandomVehicle
Jump to navigation
Jump to search
Syntax
vehicle getRandomVehicle ( )
Returns
Returns math.random Vehicle From Table if it was Argument true , And vice false
Code
function getRandomVehicle ( ) local Table = { } for i , v in ipairs ( getElementsByType ( "vehicle" ) ) do table.insert ( Table , v ) end if #Table == 0 then error "Server Not Vehicle" return false end return Table[ math.random ( #Table ) ] end
Example
This example Warp player into Random Vehicle
addCommandHandler("WarpVeh", function ( p ) Veh = getRandomVehicle ( ) if Veh then warpPedIntoVehicle ( p , Veh ) end end ) ; -- F8 Say : WarpVeh
Example 2
This example blow Random Vehicle
addCommandHandler("blowVeh", function ( p ) Veh = getRandomVehicle ( ) if Veh then blowVehicle ( Veh ) end end ) ; --F8 Say : blowVeh
Example 3
This example outputChatBox get name Vehicle Random
outputChatBox ( getVehicleName ( getRandomVehicle ( ) ) )
Author: Abdul_KariM
skype : kreee89