RemovePlayerFromVehicle: Difference between revisions

From Onset Developer Wiki
Kuzkay (talk | contribs)
No edit summary
No edit summary
 
(One intermediate revision by one other user not shown)
Line 8: Line 8:
{{FuncParam|player|Player you want to kick out of a vehicle}}
{{FuncParam|player|Player you want to kick out of a vehicle}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|Returns '''true''' on success.}}


== Example ==
== Example ==
Line 39: Line 39:


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
*[[GetPlayerVehicle]]
*[[GetPlayerVehicleSeat]]
*[[SetPlayerInVehicle]]
*[[RemovePlayerFromVehicle]]

Latest revision as of 18:30, 30 August 2020

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