[FilterScript] [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons)
#1

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.
Reply
#2

+rep, Well done Overflow!
Reply
#3

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.
Reply
#4

good job.
Reply
#5

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

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

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.
Reply
#8

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..
Reply
#9

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

@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.
Reply
#11

Worst indentation ever.. but other than that, amazing script
Reply
#12

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:

Reply
#13

Links are down if somebody have them. Plz post here
Reply
#14

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

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


Forum Jump:


Users browsing this thread: 3 Guest(s)