RemovePlayerFromVehicle: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|RemovePlayerFromVehicle(player)}} {{FuncParameters}} {{FuncParam|player|__EDIT_ME__}} {{FuncRetur..."
 
Kuzkay (talk | contribs)
No edit summary
Line 1: Line 1:
{{Info|Function|Server|1.0}}
{{Info|Function|Server|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Used to kick players from vehicles/force exit}}


{{FuncSyntax|RemovePlayerFromVehicle(player)}}
{{FuncSyntax|RemovePlayerFromVehicle(player)}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|player|__EDIT_ME__}}
{{FuncParam|player|Player you want to kick out of a vehicle}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|__EDIT_ME__}}


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
 
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)
 
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
__EDIT_ME__

Revision as of 20:19, 13 November 2019

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

__EDIT_ME__