SA-MP Forums Archive
[FilterScript] [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) (/showthread.php?tid=641552)



[SQLite] Advanced IP Logger V.2 (dialogs + unlimited IP saving for users) - OverflowJ - 17.09.2017

Greetings everyone, I'm a new scripter,,


Explanation
I've been scripting this system, and it's kinda good as it seems. When a user join with a certain IP twice, his ip log will update automatically (Date, Time, and If he logged in or not).. but if the same username joined the server with a different IP, this ip will be saved in his userlog.. so when you try the command on him, it will pop up a dialog with all of his IP's...

Here's a fast snap:





Commands
/iplog username (it will show you the ip log of a certain user)
/cleariplog username (it will erase the ip log of a certain user)



Notes
I've made a registeration system based on sqlite as well, just for testing.. you can remove it, and put the stocks, dialogs and the commands in your script..


The log can save up to 50 ip! Yes, there are next buttons! when there are more than 10 ips, you can swip to the next dialog, next ips.. (50 ips, 5 pages maximum) can be increased..


The log is constantly showed ACCORDING to unix timestamp (ordered descendingly, so the newest gets showed at first)


This is new.. it may have some bugs but I'd be glad if you appoint me to fix them


Download Link (V.2 - Recommended)
https://pastebin.com/zQN5c4ZV

V.2 Change Log:

Edited the next Buttons, it's now unlimited.. Thanks to oMa37 for telling me how to do it, optimizely!
Fixed the indentation, it's now pretty cool and looking much better, thanks to Jlalt indentation fixer!
Total IP's are now being showen when you try /iplog on any username, here is a small snap:



Download Link (V.1)
https://pastebin.com/tGum8Fkm


Credits: Zeex for zcmd include, maddinat0r for sscanf include, Omar & Metho for testing with me, and Jlalt for telling me to do this.


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - Modather - 18.09.2017

+rep, Well done Overflow!


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - oMa37 - 19.09.2017

I have not looked at the code that much, but the first thing I saw was the next button for pages.
That's not how you do next pages .. it can be easily done with just one dialog, especially using My/SQL.


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - DonaldDuck - 19.09.2017

good job.


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - iLearner - 19.09.2017

So this saves only first 50 IPS only? Or does it replace? If so what's the process.


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - OverflowJ - 19.09.2017

Thanks Modather, and DonaldDuck, I truly appreciate your kind comments.

@oMa37, Well it's working efficiently my way (Loops, Multiple Dialogs), but I'd be glad if you told me this more optimized and abbreviated way and If I could do it your way, I'd do a next version sooner, with a credits given to you for your kind judgement ^^

@iLearner, Listen mate, If 'iLearner' joined the server twice with the same IP, it will just update the same ROW (time, logged in or not), but no new rows would be created.. but If 'iLearner' joined the server twice with different IPS, it will make two rows, one with your first up, and the other with your second ip.. the operation is working up to 50 ips, I can make it more, but I found it pretty much enough.. also, I've created /cleariplog [username], just because if somehow your 50 ips were reached..


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - oMa37 - 19.09.2017

PHP код:
new PageList[MAX_PLAYERS];
enum {
    
DIALOG_TEST
};
public 
OnPlayerConnect(playerid) {
    
PageList[playerid] = 0;
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[]) {
    switch(
dialogid) {
        case 
DIALOG_TEST: {
            if(!
response) {
                
PageList[playerid]--;
                if(
PageList[playerid] < 0) {
                    
PageList[playerid] = 0;
                    
// Show the first page again or do whatever you want.
                    
return 1;
                }
            }
            else 
PageList[playerid]++;
            
format(Querysizeof(Query), "SELECT `ip`, `time`, `loggedin` FROM `ips` WHERE `username` = '%s' ORDER BY datetime(unix) DESC LIMIT %i, 10"TARGET_NAMEListPage[playerid] * 10);
            
// We're using x10 because you're showing only 10 rows per page. As you can see above we made it to increase the ListPage[playerid] variable + 1 whenever
            // the player click button 1 (which in your case, Next button). 1 x 10 = 10, 2 x 10 = 20 and so on.
            
Result db_query(DatabaseQuery);
            
// Make sure to reset the ListPage[playerid] to 0 when there are no rows found and before showing the dialog in your command.
            // ListPage[playerid] = 0;
        
}
    }
    return 
0;

This is just an example, didn't test it but it should work, if not inform me.
By the way, your code indentation is so horrible. There are many things you need to optimize.


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - OverflowJ - 19.09.2017

Ok let me test it and I will tell you the updates,

Well my code indentation isn't giving me warnings and that's why I left it that way xD, to be honest it's abit hard on me to do it though, but I will fix it with the next version..


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - oi2871999 - 19.09.2017

Quote:
Originally Posted by Modather
Посмотреть сообщение
+rep, Well done Overflow.i.
Good job


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - OverflowJ - 19.09.2017

@oMa37, I've edited it a little bit, and it's now working efficiently, I will just make sure everything is working properly and post the newer version, thank you again and I will make sure to give you credits.


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - Chaprnks - 20.09.2017

Worst indentation ever.. but other than that, amazing script


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - OverflowJ - 20.09.2017

Thank you alot, @Chaprnks and oi2871999!

Version 2 is released, https://pastebin.com/zQN5c4ZV


Edited the next Buttons, it's now unlimited.. Thanks to oMa37 for telling me how to do it, optimizely!
Fixed the indentation, it's now pretty cool and looking much better, thanks to Jlalt's indentation fixer!
Total IP's are now being showen when you try /iplog on any username, here is a small snap:




Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - GameOvr - 06.10.2018

Links are down if somebody have them. Plz post here


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - GameOvr - 07.10.2018

Still waiting guys, If anyone have the v2 of this plz pst here


Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons) - TheToretto - 28.10.2018

Just make one by yourself no? I can help you with that if you don't know how to.