GetClientIP: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
m (Changed "DeprecatedWithAlt" template to "Deprecated")
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
This function returns a string containing the IP of the client.
{{Server function}}
{{Deprecated|getPlayerIP|}}
 
This function returns a string containing the IP address of the client.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getClientName ( client theClient )
string getClientIP ( client theClient )
</syntaxhighlight>
</syntaxhighlight>


Line 16: Line 19:
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">
addCommandHandler ( "ip", "printIP" )
function printIP ( thePlayer, command )
function printIP ( thePlayer, key )
outputChatBox ( getClientName ( thePlayer ) .. "'s IP is: " .. getClientIP ( thePlayer ) )
  outputChatBox ( getClientName ( thePlayer ) .. "'s IP is: " .. getClientIP ( thePlayer ) )
end
end
addCommandHandler ( "ip", printIP )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Client functions}}
{{Client functions}}

Latest revision as of 16:21, 13 February 2015

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use getPlayerIP instead.


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

Syntax

string getClientIP ( client theClient )

Required Arguments

  • theClient: The client element (player or admin) you want to get the IP of.

Returns

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

Example

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

function printIP ( thePlayer, command )
	outputChatBox ( getClientName ( thePlayer ) .. "'s IP is: " .. getClientIP ( thePlayer ) )
end
addCommandHandler ( "ip", printIP )

See Also

BEFORE VERSION 1.0 :