jkub Posted March 9, 2009 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 )
50p Posted March 10, 2009 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 - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
robhol Posted March 10, 2009 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) Do NOT PM ME for help unless invited. - New MTA Script Editor Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.
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