GetPlayerIP: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 1: Line 1:
{{Server function}}
{{Server function}}
__NOTOC__
__NOTOC__
This function returns a string containing the IP address of the client.
This function returns a [[string]] containing the IP address of the [[player]].


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getPlayerIP ( client theClient )
string getPlayerIP ( player thePlayer )
</syntaxhighlight>
</syntaxhighlight>


===Required Arguments===
===Required Arguments===
* '''theClient:''' The client [[element]] (player or admin) you want to get the IP of.
* '''thePlayer:''' The [[player]] element you want to get the IP of.


===Returns===
===Returns===
Returns a string containing the requested client's IP, or ''false'' if the client passed to the function is invalid.
Returns a [[string]] containing the requested players's IP, or ''false'' if the player passed to the function is invalid.


==Example==
==Example==
This example prints a player's IP to the chat.
This example prints a player's IP to the chat.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function printIp(thePlayer)
function printIp ( thePlayer )
outputChatBox("IP: "..getPlayerIP(thePlayer), thePlayer)
outputChatBox ( "IP: " .. getPlayerIP ( thePlayer ), thePlayer )
end
end
 
addCommandHandler ( "ip", printIp )
addCommandHandler("ip", printIp)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Player functions}}
{{Player functions}}

Revision as of 14:19, 27 March 2009

This function returns a string containing the IP address of the player.

Syntax

string getPlayerIP ( player thePlayer )

Required Arguments

  • thePlayer: The player element you want to get the IP of.

Returns

Returns a string containing the requested players's IP, or false if the player passed to the function is invalid.

Example

This example prints a player's IP to the chat.

function printIp ( thePlayer )
	outputChatBox ( "IP: " .. getPlayerIP ( thePlayer ), thePlayer )
end
addCommandHandler ( "ip", printIp )

See Also