Player
Defined in: server/api.d.ts:7
A connected M2O player.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Player(
id):Player
Defined in: server/api.d.ts:12
Creates a script wrapper for an existing connected player with this ID; it does not create a player.
Parameters
Section titled “Parameters”number
Network entity identifier.
Returns
Section titled “Returns”Player
Methods
Section titled “Methods”addMoney()
Section titled “addMoney()”addMoney(
amount):void
Defined in: server/api.d.ts:97
Adds cash to this player’s native inventory and HUD counter.
Parameters
Section titled “Parameters”amount
Section titled “amount”number
Cash amount in dollars to add.
Returns
Section titled “Returns”void
clearAnimStyle()
Section titled “clearAnimStyle()”clearAnimStyle():
void
Defined in: server/api.d.ts:179
Removes this player’s animation-style override.
Returns
Section titled “Returns”void
clearCollectedPinups()
Section titled “clearCollectedPinups()”clearCollectedPinups():
void
Defined in: server/api.d.ts:302
Forgets every pinup collectible this player has taken, putting all of them back in the world on their client.
Returns
Section titled “Returns”void
clearHandModels()
Section titled “clearHandModels()”clearHandModels():
void
Defined in: server/api.d.ts:218
Clears this player’s left-hand, right-hand, and mouth prop models.
Returns
Section titled “Returns”void
emit()
Section titled “emit()”emit(
eventName,payloadJson?):void
Defined in: server/api.d.ts:4293
Emits a named script event to this player’s client connection.
Parameters
Section titled “Parameters”eventName
Section titled “eventName”string
Client event name.
payloadJson?
Section titled “payloadJson?”string
Optional JSON payload forwarded verbatim to the owning client.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”getAmmo()
Section titled “getAmmo()”getAmmo(
weaponId):CarriedWeapon|null
Defined in: server/api.d.ts:283
Returns the reserve and loaded ammunition of one carried weapon, as last reported by this player’s client.
Parameters
Section titled “Parameters”weaponId
Section titled “weaponId”number
weapons.tbl row identifier.
Returns
Section titled “Returns”CarriedWeapon | null
The weapon’s counts, or null when the player does not carry it.
getAnimStyle()
Section titled “getAnimStyle()”getAnimStyle():
number
Defined in: server/api.d.ts:199
Returns the most recently replicated animation-set identifier.
Returns
Section titled “Returns”number
The applied animation-set ID, or zero when no override is active.
getCurrentWeapon()
Section titled “getCurrentWeapon()”getCurrentWeapon():
number
Defined in: server/api.d.ts:270
Returns the most recently replicated held-weapon identifier.
Returns
Section titled “Returns”number
The current weapons.tbl row ID; 1 represents fists.
getHealth()
Section titled “getHealth()”getHealth():
number
Defined in: server/api.d.ts:60
Returns the most recently owner-reported health value.
Returns
Section titled “Returns”number
Current replicated health, including native damage.
getIP()
Section titled “getIP()”getIP():
string
Defined in: server/api.d.ts:4299
Returns this player’s current remote network address.
Returns
Section titled “Returns”string
Address string, or an empty string when the player or peer is unavailable.
Inherited from
Section titled “Inherited from”getMoney()
Section titled “getMoney()”getMoney():
number
Defined in: server/api.d.ts:109
Returns the most recently owner-reported cash balance.
Returns
Section titled “Returns”number
Current balance in dollars, including native in-game spending.
getMovementState()
Section titled “getMovementState()”getMovementState():
"idle"|"walking"|"running"|"stopping"
Defined in: server/api.d.ts:85
Returns the player’s current replicated on-foot gait.
Returns
Section titled “Returns”"idle" | "walking" | "running" | "stopping"
One of idle, walking, running, or stopping.
getNametagColor()
Section titled “getNametagColor()”getNametagColor():
number
Defined in: server/api.d.ts:4280
Reads this player’s nametag color.
Returns
Section titled “Returns”number
Packed 0xAARRGGBB color; opaque white when untinted.
Inherited from
Section titled “Inherited from”getNametagText()
Section titled “getNametagText()”getNametagText():
string
Defined in: server/api.d.ts:4274
Reads this player’s nametag text override.
Returns
Section titled “Returns”string
The override, or an empty string when the player’s own name is drawn.
Inherited from
Section titled “Inherited from”getTeam()
Section titled “getTeam()”getTeam():
number
Defined in: server/api.d.ts:160
Returns the team this player belongs to.
Returns
Section titled “Returns”number
The team id, or 0 when the player is on no team.
getVehicle()
Section titled “getVehicle()”getVehicle():
Vehicle|null
Defined in: server/api.d.ts:115
Returns the vehicle currently occupied by this player in any seat.
Returns
Section titled “Returns”Vehicle | null
The current vehicle handle, or null when the player is not in a vehicle.
getWeapons()
Section titled “getWeapons()”getWeapons():
CarriedWeapon[]
Defined in: server/api.d.ts:276
Returns every weapon this player carries with its reserve and loaded ammunition, as last reported by their client. Values are current to within one client frame, and stay readable in playerDisconnect.
Returns
Section titled “Returns”One entry per carried weapon; empty before the client’s first report.
giveAmmo()
Section titled “giveAmmo()”giveAmmo(
weaponId,amount):void
Defined in: server/api.d.ts:233
Changes reserve ammunition for one of this player’s weapons.
Parameters
Section titled “Parameters”weaponId
Section titled “weaponId”number
weapons.tbl row identifier.
amount
Section titled “amount”number
Reserve ammunition delta; negative values remove ammunition.
Returns
Section titled “Returns”void
giveWeapon()
Section titled “giveWeapon()”giveWeapon(
weaponId,ammo,equip):void
Defined in: server/api.d.ts:226
Adds a valid weapon to this player’s native inventory.
Parameters
Section titled “Parameters”weaponId
Section titled “weaponId”number
weapons.tbl row identifier.
number
Initial reserve ammunition amount.
boolean
Whether the weapon should become the current weapon immediately.
Returns
Section titled “Returns”void
isCrouching()
Section titled “isCrouching()”isCrouching():
boolean
Defined in: server/api.d.ts:91
Checks the player’s most recently replicated crouch state.
Returns
Section titled “Returns”boolean
True when the player is crouching.
isDead()
Section titled “isDead()”isDead():
boolean
Defined in: server/api.d.ts:79
Checks the player’s most recently reported death state.
Returns
Section titled “Returns”boolean
True when the player is dead.
isNametagHealthVisible()
Section titled “isNametagHealthVisible()”isNametagHealthVisible():
boolean
Defined in: server/api.d.ts:4268
Checks whether the health bar under this player’s nametag is shown.
Returns
Section titled “Returns”boolean
True unless the health bar was hidden; false also when this game has no nametags.
Inherited from
Section titled “Inherited from”BasePlayer.isNametagHealthVisible
isNametagVisible()
Section titled “isNametagVisible()”isNametagVisible():
boolean
Defined in: server/api.d.ts:4262
Checks whether this player’s nametag is shown to other players.
Returns
Section titled “Returns”boolean
True unless the nametag was hidden; false also when this game has no nametags.
Inherited from
Section titled “Inherited from”isPinupCollected()
Section titled “isPinupCollected()”isPinupCollected(
pinupId):boolean
Defined in: server/api.d.ts:297
Checks whether this player has taken a pinup collectible.
Parameters
Section titled “Parameters”pinupId
Section titled “pinupId”number
Pinups.tbl collectible identifier.
Returns
Section titled “Returns”boolean
True when the collectible is in this player’s collected set.
kick()
Section titled “kick()”kick(
reason?):void
Defined in: server/api.d.ts:4286
Disconnects this player from the server.
Parameters
Section titled “Parameters”reason?
Section titled “reason?”string
Optional reason shown to the disconnected player; omitting it uses the generic kicked reason.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”kill()
Section titled “kill()”kill():
void
Defined in: server/api.d.ts:65
Instantly kills this player on the owning client.
Returns
Section titled “Returns”void
modelToHands()
Section titled “modelToHands()”modelToHands(
enabled,leftModelId,rightModelId):void
Defined in: server/api.d.ts:207
Shows or clears visual prop models in this player’s hands. Hand slots are shared with the equipped weapon.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
False clears both hand slots; true applies the supplied models.
leftModelId
Section titled “leftModelId”number
weapons.tbl prop-row ID for the left hand; an unknown ID clears the slot.
rightModelId
Section titled “rightModelId”number
weapons.tbl prop-row ID for the right hand; an unknown ID clears the slot.
Returns
Section titled “Returns”void
modelToMouth()
Section titled “modelToMouth()”modelToMouth(
modelId):void
Defined in: server/api.d.ts:213
Shows a visual prop model in this player’s mouth.
Parameters
Section titled “Parameters”modelId
Section titled “modelId”number
weapons.tbl prop-row ID; an unknown ID clears the mouth slot.
Returns
Section titled “Returns”void
playAnim()
Section titled “playAnim()”playAnim(
name,loop,useAnimSet?):boolean
Defined in: server/api.d.ts:188
Plays a named animation clip on this player’s ped on every client. The owning client’s controls lock automatically while the animation holds the body; end a looping clip with stopAnim. If a one-shot leaves the controls locked, call stopAnim, or Controls.setEnabled(true) from a client script.
Parameters
Section titled “Parameters”string
Engine animation clip name, at most 62 characters (e.g. “sc_eat_hot_out”, or “CC_TAUNT01-A” with useAnimSet).
boolean
True to repeat the clip until stopAnim is called; false to play it once.
useAnimSet?
Section titled “useAnimSet?”boolean
False (default) plays the clip by its exact name; true looks it up in the ped’s current animation set, as set-member clips such as CC_TAUNT01-A require.
Returns
Section titled “Returns”boolean
True when the request was broadcast; false when the clip name is empty or longer than 62 characters.
putInVehicle()
Section titled “putInVehicle()”putInVehicle(
vehicle,seat?):boolean
Defined in: server/api.d.ts:123
Instantly warps this player into a vehicle seat without the enter animation, leaving any current vehicle first.
Parameters
Section titled “Parameters”vehicle
Section titled “vehicle”number | Vehicle
Vehicle handle or network entity ID.
number
Seat index where 0 is the driver seat; defaults to 0.
Returns
Section titled “Returns”boolean
True when the player was seated; false when the vehicle is unknown or destroyed, the seat is out of range or held by another player, or the player is dead.
removeAllWeapons()
Section titled “removeAllWeapons()”removeAllWeapons():
void
Defined in: server/api.d.ts:252
Removes all weapons from this player and switches to fists.
Returns
Section titled “Returns”void
removeFromVehicle()
Section titled “removeFromVehicle()”removeFromVehicle(
animated?):boolean
Defined in: server/api.d.ts:130
Takes this player out of their current vehicle. The default is an instant warp; with animated the player climbs out normally, the car radio and in-car audio stop, and vehiclePlayerExited fires when the animation completes rather than immediately.
Parameters
Section titled “Parameters”animated?
Section titled “animated?”boolean
Play the native get-out animation instead of warping; defaults to false.
Returns
Section titled “Returns”boolean
True when the player was removed, or when the animated exit was started; false when the player is not in a vehicle.
removeMoney()
Section titled “removeMoney()”removeMoney(
amount):void
Defined in: server/api.d.ts:103
Removes cash from this player’s native inventory.
Parameters
Section titled “Parameters”amount
Section titled “amount”number
Cash amount in dollars to remove; removal is clamped to the available balance.
Returns
Section titled “Returns”void
removeWeapon()
Section titled “removeWeapon()”removeWeapon(
weaponId):void
Defined in: server/api.d.ts:247
Removes one weapon from this player’s inventory and switches to fists when necessary.
Parameters
Section titled “Parameters”weaponId
Section titled “weaponId”number
weapons.tbl row identifier to remove.
Returns
Section titled “Returns”void
restoreHealth()
Section titled “restoreHealth()”restoreHealth():
void
Defined in: server/api.d.ts:54
Restores this player to full native health.
Returns
Section titled “Returns”void
setAnimStyle()
Section titled “setAnimStyle()”setAnimStyle(
category,style):boolean
Defined in: server/api.d.ts:174
Overrides this player’s walk and idle animation style.
Parameters
Section titled “Parameters”category
Section titled “category”"common" | "weapon" | "panic" | "melee"
Animation-style registry category.
string
Registered style name within the selected category.
Returns
Section titled “Returns”boolean
True when the category and style were found and applied.
setCurrentWeapon()
Section titled “setCurrentWeapon()”setCurrentWeapon(
weaponId):void
Defined in: server/api.d.ts:258
Equips one of this player’s owned weapons.
Parameters
Section titled “Parameters”weaponId
Section titled “weaponId”number
Owned weapons.tbl row identifier to equip.
Returns
Section titled “Returns”void
setHealth()
Section titled “setHealth()”setHealth(
health):void
Defined in: server/api.d.ts:49
Sets this player’s health on the owning client.
Parameters
Section titled “Parameters”health
Section titled “health”number
Target health value, clamped to the pedestrian’s native maximum.
Returns
Section titled “Returns”void
setInvincible()
Section titled “setInvincible()”setInvincible(
enabled):void
Defined in: server/api.d.ts:166
Makes this player immune to every damage source: bullets, melee, explosions, fire, vehicle impacts, run-overs and falls, including while seated in a burning or exploding vehicle. Hit reactions and knockdowns still play, and kill() still kills. Resets to false on reconnect.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
True to make the player immune to all damage, false to restore it.
Returns
Section titled “Returns”void
setModel()
Section titled “setModel()”setModel(
modelIndex):void
Defined in: server/api.d.ts:136
Changes this player’s body model and replicates the new skin.
Parameters
Section titled “Parameters”modelIndex
Section titled “modelIndex”number
Index in the shared player-model registry.
Returns
Section titled “Returns”void
setModelColor()
Section titled “setModelColor()”setModelColor(
colorId):void
Defined in: server/api.d.ts:147
Recolors this player’s current outfit without reloading the model; unsupported variants are ignored.
Parameters
Section titled “Parameters”colorId
Section titled “colorId”number
Per-model palette variant; -1 restores the default.
Returns
Section titled “Returns”void
setNametagColor()
Section titled “setNametagColor()”setNametagColor(
color):void
Defined in: server/api.d.ts:4323
Tints the text on this player’s nametag.
Parameters
Section titled “Parameters”number
Packed 0xAARRGGBB color.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setNametagHealthVisible()
Section titled “setNametagHealthVisible()”setNametagHealthVisible(
visible):void
Defined in: server/api.d.ts:4311
Shows or hides the health bar under this player’s nametag, leaving the name itself alone.
Parameters
Section titled “Parameters”visible
Section titled “visible”boolean
True to show the health bar under this player’s name, false to hide it.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”BasePlayer.setNametagHealthVisible
setNametagText()
Section titled “setNametagText()”setNametagText(
text?):void
Defined in: server/api.d.ts:4317
Overrides the text drawn on this player’s nametag.
Parameters
Section titled “Parameters”string
Text to show instead of the player’s name, cut to 64 bytes; empty or omitted restores the name.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setNametagVisible()
Section titled “setNametagVisible()”setNametagVisible(
visible):void
Defined in: server/api.d.ts:4305
Shows or hides the name over this player’s head for every other player. The health bar has its own switch, and each player can still hide all nametags locally.
Parameters
Section titled “Parameters”visible
Section titled “visible”boolean
True to show this player’s nametag to everyone, false to hide it.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setPinupCollected()
Section titled “setPinupCollected()”setPinupCollected(
pinupId,collected):void
Defined in: server/api.d.ts:290
Sets whether this player has taken a pinup collectible. The world entity is hidden or restored on this player’s client immediately, without waiting for the area to stream again.
Parameters
Section titled “Parameters”pinupId
Section titled “pinupId”number
Pinups.tbl collectible identifier.
collected
Section titled “collected”boolean
True to mark the collectible taken and hide it; false to restore it to the world.
Returns
Section titled “Returns”void
setRandomModel()
Section titled “setRandomModel()”setRandomModel():
void
Defined in: server/api.d.ts:141
Selects and applies a random model from the Mafia II player model directory.
Returns
Section titled “Returns”void
setTeam()
Section titled “setTeam()”setTeam(
team):boolean
Defined in: server/api.d.ts:154
Puts this player on a team, which decides who may damage them.
Parameters
Section titled “Parameters”number
Team id from Team.create, or 0 to leave every team.
Returns
Section titled “Returns”boolean
True when the team exists and was applied.
setUnlimitedAmmo()
Section titled “setUnlimitedAmmo()”setUnlimitedAmmo(
enabled):void
Defined in: server/api.d.ts:264
Enables or disables unlimited ammunition for this player.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Whether this player’s ammunition is infinite.
Returns
Section titled “Returns”void
setVirtualWorld()
Section titled “setVirtualWorld()”setVirtualWorld(
world):void
Defined in: server/api.d.ts:4154
Moves this entity into another virtual world.
Parameters
Section titled “Parameters”number
Virtual-world identifier used to partition replication and visibility.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setVisibleTo()
Section titled “setVisibleTo()”setVisibleTo(
player):void
Defined in: server/api.d.ts:4160
Restricts replication of this entity to one owning connection while preserving normal range and visibility checks.
Parameters
Section titled “Parameters”player
Section titled “player”Entity | null
Player-owned entity whose connection should exclusively receive this entity, or null to clear the restriction.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”setWeaponAmmo()
Section titled “setWeaponAmmo()”setWeaponAmmo(
weaponId,total,clip):void
Defined in: server/api.d.ts:241
Sets absolute ammunition counts for one of this player’s weapons.
Parameters
Section titled “Parameters”weaponId
Section titled “weaponId”number
weapons.tbl row identifier.
number
Absolute reserve ammunition amount.
number
Absolute loaded-clip amount; a negative value preserves the current clip.
Returns
Section titled “Returns”void
spawn()
Section titled “spawn()”spawn(
x,y,z):void
Defined in: server/api.d.ts:73
Respawns this player at a world-space position.
Parameters
Section titled “Parameters”number
Respawn world-space X coordinate.
number
Respawn world-space Y coordinate.
number
Respawn world-space Z coordinate.
Returns
Section titled “Returns”void
stopAnim()
Section titled “stopAnim()”stopAnim():
void
Defined in: server/api.d.ts:193
Stops this player’s scripted animation on every client and re-enables the owning client’s controls.
Returns
Section titled “Returns”void
toString()
Section titled “toString()”toString():
string
Defined in: server/api.d.ts:43
Returns a readable representation of this player.
Returns
Section titled “Returns”string
The player ID and nickname formatted for logging or debugging.
Inherited from
Section titled “Inherited from”Properties
Section titled “Properties”collectedPinups
Section titled “collectedPinups”
readonlycollectedPinups:number[]
Defined in: server/api.d.ts:37
Pinups.tbl identifiers of every collectible this player has taken.
discordId
Section titled “discordId”
readonlydiscordId:string
Defined in: server/api.d.ts:4235
Authenticated Discord identifier, or an empty string when unavailable.
Inherited from
Section titled “Inherited from”epicId
Section titled “epicId”
readonlyepicId:string
Defined in: server/api.d.ts:4230
Epic Games account identifier the client reported, not verified by the server, or an empty string when unavailable.
Inherited from
Section titled “Inherited from”hardwareId
Section titled “hardwareId”
readonlyhardwareId:string
Defined in: server/api.d.ts:4240
Framework hardware identifier, or an empty string when unavailable.
Inherited from
Section titled “Inherited from”
readonlyid:number
Defined in: server/api.d.ts:4122
Immutable network entity identifier.
Inherited from
Section titled “Inherited from”invincible
Section titled “invincible”
readonlyinvincible:boolean
Defined in: server/api.d.ts:32
True while setInvincible has made this player immune to damage.
readonlyip:string
Defined in: server/api.d.ts:4250
Current remote network address, or an empty string when unavailable.
Inherited from
Section titled “Inherited from”
readonlymodel:number
Defined in: server/api.d.ts:22
Current shared player-model registry index, or -1 when unset or unknown.
modelColor
Section titled “modelColor”
readonlymodelColor:number
Defined in: server/api.d.ts:27
Current per-model palette variant, or -1 for the default.
nickname
Section titled “nickname”
readonlynickname:string
Defined in: server/api.d.ts:17
Current connected-player nickname.
readonlyping:number
Defined in: server/api.d.ts:4245
Current round-trip latency in milliseconds, or -1 when unavailable.
Inherited from
Section titled “Inherited from”position
Section titled “position”position:
Vector3
Defined in: server/api.d.ts:4132
Authoritative world-space position; assignment forces replicated state.
Inherited from
Section titled “Inherited from”rotation
Section titled “rotation”rotation:
Vector3|Quaternion
Defined in: server/api.d.ts:4137
Authoritative rotation; reads return a quaternion and assignments accept a quaternion or Euler angles in degrees.
Inherited from
Section titled “Inherited from”
readonlystate:StateBag
Defined in: server/api.d.ts:4142
Arbitrary key/value state carried by this entity. The server writes it and every client that can see the entity receives it; see StateBag.
Inherited from
Section titled “Inherited from”steamId
Section titled “steamId”
readonlysteamId:string
Defined in: server/api.d.ts:4225
Authenticated Steam identifier, or an empty string when unavailable.
Inherited from
Section titled “Inherited from”virtualWorld
Section titled “virtualWorld”
readonlyvirtualWorld:number
Defined in: server/api.d.ts:4127
Current virtual-world identifier.
