Skip to content

Player Class

PiterMcFlebor edited this page Oct 6, 2020 · 2 revisions

Client-side

Init

local player = Player(
    source    -- number, the player server id, this can be -1 for self player or >0
)

Example

--
-- Getting the player position and name
--
local player = Player(-1)

print('Player name', player:GetName())
print('Player position', tostring(player:GetPosition()))

Server-side

Init

local player = Player(
    source    -- number, the player server id
)

Example

--
-- Getting the player position and vehicle
-- then deleting the vehicle
--
local player = Player(source)
local playerPosition = player:GetPosition()
if player:IsInVehicle() then
    local playerVehicle = player:GetVehicleSitting()
    playerVehicle:Delete()
else
    local playerVehicle = player:GetLastVehicle()
    playerVehicle:Delete()
end

Clone this wiki locally