• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

CreatureEvent Record IP Onlogin (Simple But usefull)

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,901
Reaction score
26
Location
Canada
What i've created is a simple script to record a players IP in a collum in the database each login. (Might have already been created, But i am not sure.)

Code:
ALTER TABLE players ADD ip varchar(255) NOT NULL

XML:
<event type="login" name="recordIp" event="script" value="recordIp.lua"/>

Lua:
function onLogin(cid)
local tmp = {playerName = getPlayerName(cid), ip = getPlayerIp(cid)}
db.executeQuery("UPDATE `players` SET `ip` = '" .. doConvertIntegerToIp(tmp.ip) .. "' WHERE name = '"..tmp.playerName.."';")
	return true
end

148p2tz.png
 
Last edited:
That's nice but how i can cheack that some1 is login from the same IP :> i know there commands /mc but i mean if some1 loged off.
 
There's already a column called lastip, don't see what's the problem with converting the IP to regular digits and reversing.
also you should be updating the player's row using the indexed column (id) in the WHERE clause, but you're using name without ' LIMIT 1' instead.

don't get me wrong, just saying
make the size 17
i think you meant 15
 
There's already a column called lastip, don't see what's the problem with converting the IP to regular digits and reversing.
also you should be updating the player's row using the indexed column (id) in the WHERE clause, but you're using name without ' LIMIT 1' instead.

don't get me wrong, just saying

i think you meant 15
Theres no need to reverse here, tfs already reverse it and query the database
 
bigint? no. that wont work. if it contains anything other than numbers it wont work! and it does, dots

Lua:
function onLogin(cid)
	db.executeQuery("UPDATE players SET ip='" .. doConvertIntegerToIp(getPlayerIp(cid)) .. "' WHERE id=" .. getPlayerGUID(cid))
	return true
end
 
My mistake, i was reading what you posted yesterday and changing it about stoned as shit, and i replaced it with an incorrect one. I put it back to varchar(255) which works perfectly in the format i wanted it to be in.
 
That's nice but how i can cheack that some1 is login from the same IP :> i know there commands /mc but i mean if some1 loged off.

Google:
Code:
SELECT p1.* FROM players AS p1, players AS p2 WHERE p1.ip = p2.ip AND p1.id != p2.id
 
Um... check websites developement :p
http://otland.net/f118/standalone-simple-database-manager-gms-admins-126105/
You enter player name, it show him on list, you press on IP and you see online and offline players from his IP, simple?
It use 'lastip' column, no need LUA script. Very hard PHP reverse scripts ;)
PHP:
function IP_OTStoSTRING($ip) 
{ 
    return implode('.', array_reverse(explode('.', long2ip($ip)))); 
} 

function IP_STRINGtoOTS($ip) 
{ 
    return ip2long(implode('.', array_reverse(explode('.', $ip)))); 
}
 
I prefer to save all IPs where player login and not the last ip where the player connected to the server
 
Back
Top