Player.Frags

From GMod Wiki

Jump to: navigation, search
Function
Syntax Player:Frags( )
Description:
Retrieves the number of frags.
Returns: Integer
In Object: Player
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Player.Frags]Player.Frags [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionThis example will print the name of the player with the most frags.
Used onNewerServer.png
Code
// Defining local variables for later use
local BestScore = 0 
local BestPlayer
 
// Looping trough a table of all players where v is an individual player.
for k,v in pairs( player.GetAll() ) do  
	local Frags = v:Frags()       // Getting a player's frags
	if Frags > BestScore then     // If it's higher then the current BestScore then
		BestScore = Frags     // Make it the new BestScore
		BestPlayer = v:Name() // And make the player the new BestPlayer
	end
end
 
if BestScore != 0 then // If anyone had a score higher then 0 then print the results.
	print("The best player is " .. BestPlayer .. " with a score of " .. tostring(BestScore) .. "!") 
end
OutputThe best player is Crazy Quebecer with a score of 23!


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox