CreatureEvent Record IP Onlogin (Simple But usefull)

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,875
Reaction score
18
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
 
Last edited:

Denyy

PL RoX
Joined
Sep 4, 2009
Messages
82
Reaction score
0
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.
 

Knight God

Active Member
Joined
Oct 19, 2008
Messages
1,180
Reaction score
20
what is? explication or pics please :S i don't understan
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,897
Reaction score
806
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
 

Fallen

Freelancer
Joined
Aug 21, 2009
Messages
3,714
Reaction score
245
Location
Egypt
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
 

Cykotitan

Experienced G'
Joined
Nov 4, 2008
Messages
16,897
Reaction score
806
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
 
OP
Sync

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,875
Reaction score
18
Location
Canada
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.
 

wesoly136

Member
Joined
Jul 30, 2009
Messages
560
Reaction score
7
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
 

Denyy

PL RoX
Joined
Sep 4, 2009
Messages
82
Reaction score
0
Any1 can make something like in website that shows list of the same IPs?
 

PhoOwned

^_^
Joined
Nov 11, 2010
Messages
375
Reaction score
63
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)))); 
}
 
Joined
Apr 17, 2008
Messages
1,922
Reaction score
181
Location
Venezuela
I prefer to save all IPs where player login and not the last ip where the player connected to the server
 

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,820
Reaction score
356
Location
Germany
Top