RemovePlayerFromVehicle

From Onset Developer Wiki
RemovePlayerFromVehicle

Type: Function
Context: Server
Introduced: v1.0

Description

Used to kick players from vehicles/force exit

Syntax

RemovePlayerFromVehicle(player)

Parameters

  • player
    Player you want to kick out of a vehicle

Return Value

  • Returns true on success.

Example

function cmd_eject(player, otherplayer)
	
	if (otherplayer == nil) then
		return AddPlayerChat(player, "Usage: /eject <player>")
	end

	otherplayer = tonumber(otherplayer)

	if (not IsValidPlayer(otherplayer)) then
		return AddPlayerChat(player, "Selected player does not exist")
	end

	if (GetPlayerVehicle(otherplayer) == 0) then
		return AddPlayerChat(player, "Selected player is not in a vehicle")
	end

	local x, y, z = GetPlayerLocation(otherplayer)
	SetPlayerLocation(otherplayer, x, y, z + 300)

	AddPlayerChat(player, "You have ejected "..GetPlayerName(otherplayer).."("..otherplayer..") from their vehicle")
end
AddCommand("eject", cmd_eject)

See also