SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 17/09/2017, 01:27 PM   #1
OverflowJ
Little Clucker
 
Join Date: Sep 2017
Posts: 21
Reputation: 7
Default [SQLite] Advanced IP Logger V.2 (dialogs + unlimited IP saving for users)

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.

Last edited by OverflowJ; 21/09/2017 at 03:43 PM.
OverflowJ is offline   Reply With Quote
Old 18/09/2017, 11:28 PM   #2
Modather
Little Clucker
 
Join Date: Sep 2017
Posts: 4
Reputation: 0
Default Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons)

+rep, Well done Overflow!
Modather is offline   Reply With Quote
Old 19/09/2017, 05:35 AM   #3
oMa37
Gangsta
 
Join Date: Feb 2016
Posts: 968
Reputation: 155
Default Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons)

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.

Last edited by oMa37; 19/09/2017 at 02:11 PM.
oMa37 is offline   Reply With Quote
Old 19/09/2017, 06:19 AM   #4
DonaldDuck
Banned
 
Join Date: Jun 2017
Location: Phillipines
Posts: 258
Reputation: 91
Default Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons)

good job.
DonaldDuck is offline   Reply With Quote
Old 19/09/2017, 06:34 AM   #5
iLearner
Gangsta
 
iLearner's Avatar
 
Join Date: Apr 2017
Posts: 578
Reputation: 134
Default Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons)

So this saves only first 50 IPS only? Or does it replace? If so what's the process.
iLearner is offline   Reply With Quote
Old 19/09/2017, 01:45 PM   #6
OverflowJ
Little Clucker
 
Join Date: Sep 2017
Posts: 21
Reputation: 7
Default Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons)

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..
OverflowJ is offline   Reply With Quote
Old 19/09/2017, 02:09 PM   #7
oMa37
Gangsta
 
Join Date: Feb 2016
Posts: 968
Reputation: 155
Default Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons)

PHP Code:
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.
oMa37 is offline   Reply With Quote
Old 19/09/2017, 02:12 PM   #8
OverflowJ
Little Clucker
 
Join Date: Sep 2017
Posts: 21
Reputation: 7
Default Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons)

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..
OverflowJ is offline   Reply With Quote
Old 19/09/2017, 02:12 PM   #9
oi2871999
Little Clucker
 
Join Date: Aug 2015
Posts: 5
Reputation: 0
Default Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons)

Quote:
Originally Posted by Modather View Post
+rep, Well done Overflow.i.
Good job
oi2871999 is offline   Reply With Quote
Old 19/09/2017, 04:03 PM   #10
OverflowJ
Little Clucker
 
Join Date: Sep 2017
Posts: 21
Reputation: 7
Default Re: [SQLite] Advanced IP Logger (dialogs + save up to 50 ips per user with next buttons)

@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.
OverflowJ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS] EBank [Advanced Bank System (Dialogs)] aircombat Filterscripts 71 28/03/2016 11:03 PM
[Tutorial] How to make a register system ( Dialogs, SQLite and rBits ) Lorenc_ Tutorials 137 25/04/2015 01:26 AM
[FilterScript] [FS] ERegLog ( Advanced Register/Login System [Dialogs] ) aircombat Filterscripts 29 09/11/2014 10:30 PM
[FilterScript] Advanced weaponaries system with dialogs Equuuuin0X Filterscripts 3 26/01/2014 07:04 PM


All times are GMT. The time now is 04:17 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.