Jump to content

getServerIP


'LinKin

Recommended Posts

Hello,

I want to check if the server that runs a script is allowed to use it.

  
addEventHandler("onResourceStart", resourceRoot, 
function() 
    local serverIP = getServerIP() -- If only this existed.. 
    dbC = dbConnect( "mysql", "dbname=frank;host=1.2.3.4", "username", "password", "share=1" ) 
    local query = dbPoll ( dbQuery ( dbC, "SELECT * FROM servers WHERE ip=?", serverIP ), -1 ) 
     if ( query and type ( query ) == "table" ) then 
          outputChatBox("This server can use this script!") 
    else 
          outputChatBox("This server cannot use this script!") 
     end 
end) 
  

But, as far as I know, it's kinda impossible to get the server's IP..

So I'm looking for an alternative way, any suggestions?

Thanks.

Link to comment

you can use this function

--By MJNONFIK 
function getServerIp() 
    callRemote("http://www.nub.hj.cx/getServerIp.php", 
    function(value) 
        if (value ~= "ERROR") then 
            return value 
        end 
    end) 
    return false 
end 

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...