Jump to content

tostring?


jkub

Recommended Posts

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
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 by Guest
Link to comment
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...