jkub Posted March 9, 2009 Share Posted March 9, 2009 How would I use tostring to getsomeone elses ip? from what I understand Ive did this addCommandHandler ( "getip", function ( command, target ) target = tostring("") local targetName = getClientName ( target ) targetIP = getClientIP (target) outputChatBox ( targetName.. "'s IP is " ..targetIP, getRootElement() ) end ) Link to comment
50p Posted March 10, 2009 Share Posted March 10, 2009 (edited) addCommandHandler ( "getip", function ( playerWhoUsedCommand, command, targetName ) local targetPlayer = getPlayerFromNick( targetName ) if targetPlayer then local targetIP = getClientIP( targetPlayer ) outputChatBox( targetName.. "'s IP is " ..targetIP, getRootElement() ) end end ) Edited March 10, 2009 by Guest Link to comment
robhol Posted March 10, 2009 Share Posted March 10, 2009 Unfortunately MTA doesn't have a function getClient(Player)FromName or something similar, so you have to loop through all the players and find out if player with such name is connected... addCommandHandler ( "getip", function ( playerWhoUsedCommand, command, targetName ) for _, targetPlayer in pairs( getElementsByType( "player" ) ) do if getClientName( targetPlayer ) == targetName then local targetIP = getClientIP( targetPlayer ) outputChatBox( targetName.. "'s IP is " ..targetIP, getRootElement() ) end end end ) Wtf! Yes, it does! getPlayerFromNick(nick) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now