function spawnvehicle ( thePlayer, commandname, target, vehicleid )
local vehicleid = tonumber ( vehicleid )
if ( not vehicleid ) then
outputChatBox ( "Invalid VehicleID was given", thePlayer )
else
local targetp = getPlayerFromName ( target )
if ( not targetp ) then -- If the target is not online.
targetp = thePlayer -- Set the "targetp" variable to the player who used the command.
end
local x, y, z = getElementPosition ( targetp )
local spawnedvehicle = createVehicle ( vehicleid, x + 2, y + 2, z + 1 )
if ( not spawnedvehicle ) then
outputChatBox ( "Invalid VehicleID was given", thePlayer )
end
end
end
addCommandHandler ( "spawnvehicle", spawnvehicle )
Read comments.