RemovePlayerFromVehicle

From Onset Developer Wiki
Revision as of 16:59, 16 December 2019 by 28days (talk | contribs)
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

  • __EDIT_ME__

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

Template:PlayerFunctions