Scripting/Squirrel/Functions/Players/Score
From VC-MP Wiki
This instance variable returns or sets player's score.
Syntax
int player.Score player.Score = newScore
Example 1. Returning
This command gives the player with highest score when someone types '/c mostdangerous'.
function onPlayerCommand( player, cmd, text ) { if ( cmd == "mostdangerous" ) { local highestScore = 0, mostDangerous; for ( local i = 0; i < GetMaxPlayers(); i++ ) { local p = FindPlayer( text ); if ( p ) { if ( p.Score > highestScore ) { mostDangerous = p; highestScore = p.Score; } } } if ( highestScore == 0 ) MessagePlayer( "Nobody has a positive score, so everybody is a loser!", player ); else MessagePlayer( "The most dangerous player is " + mostDangerous.Name + " with a score of " + mostDangerous.Score + ".", player ); } }
Notes
The functions MessagePlayer, FindPlayer, player.Name, GetMaxPlayers and call onPlayerCommand were used in in this example. More info about them in corresponding pages.
Example 2. Setting
This example increases player score if they kill someone.
function onPlayerKill( killer, killed, weapon ) { killer.Score++; }
Notes
The call onPlayerKill was used in in this example. More info about it in the corresponding page.
Related Functions
- FindPlayer
- Player.Angle
- Player.Armour
- Player.Cash
- Player.Class
- Player.DrivebyAbility
- Player.GetSpectating
- Player.GetSyncBlockedTo
- Player.Health
- Player.ID
- Player.IP
- Player.IsAdmin
- Player.IsFrozen
- Player.IsIgnoredBy
- Player.IsMuted
- Player.IsPassenger
- Player.IsSpawned
- Player.IsSyncBlocked
- Player.IsWeaponSyncBlocked
- Player.Keys
- Player.Name
- Player.Ping
- Player.Pos
- Player.RemoveLocalMarker
- Player.RemoveMarker
- Player.ResetGameSettings
- Player.Score
- Player.Seat
- Player.SetAnim
- Player.SetDrunkLevel
- Player.SetIgnoredBy
- Player.SetInterior
- Player.SetLocalMarker
- Player.SetMarker
- Player.SetSyncBlockedTo
- Player.WantedLevel
- Player.SetWeapon
- Player.Skin
- Player.SpawnPos
- Player.Team
- Player.Vehicle
- Player.Weapon
- Player.ShootInAir
- Player.StuntMode
- Player.Spikes
