Good methods for user accounts? [SQLite help needed also]
#1

What's some of the best methods for creating user accounts and storing data.

I've been using a method I saw in a godfather gamemode, but it looks pretty crap and very inefficient.

I made another gamemode and for the user accounts I used dini.

Im just wondering are there any better methods?

Thanks.
Reply
#2

djson, use search.
Reply
#3

Quote:
Originally Posted by Y_Leѕѕ
The YSI method is very different from all these - instead of being name based it's ID based and uses an index to look up your user file. This means you can have multiple nicknames associated with your account - if you change your name you don't need to reset your account, you just associate the new one with the old one. It also uses ID based files so there's no worries about invalid characters. And as I said it uses a set if index files for fast ID lookup.
But the YSI method is a include, isn't it?
Sow, is there a script that already uses the YSI method?

Thanks (:
Reply
#4

Quote:
Originally Posted by Y_Leѕѕ
No, that's why it's an include.
No I mean a script that uses your include, so I can learn how to script with it.
Reply
#5

Which one would be best for quick ip lookups?

For example, I want to make a ban system, which will work with the account system.

So if a player is banned I want to make a command to check any other names banned on that ip address and range, and check the ip addresses used by a player.

Am I right in thinking I'd need a database for this rather than it all in sepperate files?
Reply
#6

Quote:
Originally Posted by Nameless303
Quote:
Originally Posted by Y_Leѕѕ
No, that's why it's an include.
No I mean a script that uses your include, so I can learn how to script with it.
As far as I'm aware, it's built into the include.

Correct me if I'm wrong.
Reply
#7

Quote:
Originally Posted by Y_Leѕѕ
You couldn't really use an account system for checking banned IPs as they could change their name and you have no way (in any user system) to associate that name with a banned account to check the IPs.
what I mean is I need to log players names and ip addresses, and I'll make a command to gather the data.

So if I need to search for names on one ip address or one ip range, or search for ip addresses associated with a certain user.

I'm not sure how to set that up.

For the account system I'll check out YSI or if that's complicated I may try dudb.


What about gathering something like hard drive serial number for banning a player, would make it near impossible to evade.

I've heard they do this on xbox360 with some games. Is it possible in pawno and samp?
Reply
#8

Its not possible for SA:MP. I herd storing files/IP's on a MYSQL database it very efficient.
Reply
#9

Quote:
Originally Posted by Y_Leѕѕ
The YSI method is very different from all these - instead of being name based it's ID based and uses an index to look up your user file. This means you can have multiple nicknames associated with your account - if you change your name you don't need to reset your account, you just associate the new one with the old one. It also uses ID based files so there's no worries about invalid characters. And as I said it uses a set if index files for fast ID lookup.
Sorry but as much as I love YSI I hated the way user accounts were handled, it was a pain in the ass to hit the index file when I could just goto the folder and find the file by users name.
Reply
#10

The best way is definitely storing data in SQL database.
Reply
#11

Quote:
Originally Posted by cyber_punk
Quote:
Originally Posted by Y_Leѕѕ
The YSI method is very different from all these - instead of being name based it's ID based and uses an index to look up your user file. This means you can have multiple nicknames associated with your account - if you change your name you don't need to reset your account, you just associate the new one with the old one. It also uses ID based files so there's no worries about invalid characters. And as I said it uses a set if index files for fast ID lookup.
Sorry but as much as I love YSI I hated the way user accounts were handled, it was a pain in the ass to hit the index file when I could just goto the folder and find the file by users name.
But that way assumes that:

a) You only have one name per account, which YSI doesn't restrict, others do. I went for the IRC style users where you can have multiple names per account.

b) Names have no special characters.

Edit: See my next post, there's nothing actually tying you to this file layout (or indeed files) in the front and of the YSI user system, so you could do it any other way.

Quote:
Originally Posted by $ЂЯĢ
The best way is definitely storing data in SQL database.
Do you have any sort of empirical evidence for that? A well structured file system can rival a generic database - bespoke code is always better than generic code because it can be highly tailored.
Reply
#12

Quote:
Originally Posted by $ЂЯĢ
The best way is definitely storing data in SQL database.
MySQL / SQLite?
I myself prefer SQLite, even the sa-mp package came up with an include..
Reply
#13

Sorry, forgot to reply to this one.

Quote:
Originally Posted by Outbreak
what I mean is I need to log players names and ip addresses, and I'll make a command to gather the data.

So if I need to search for names on one ip address or one ip range, or search for ip addresses associated with a certain user.

I'm not sure how to set that up.
As I said that would be separate to any account system as they could change their name, thus loosing all relation to the ban data. There are a number of ban systems already you may wish to look into.

Quote:
Originally Posted by Outbreak
For the account system I'll check out YSI or if that's complicated I may try dudb.
pawn Код:
#include <YSI>

#define LOAD:%1(%2) \
    forward LoginDat_%1(%2); \
    public LoginDat_%1(%2)


main()
{
}

// Save data
// The player's playerid and their globally unique ID.
public OnPlayerLogout(playerid, yid)
{
    // Set the unique identifier for the mode.
    // This is so all your data is easily found and loaded
    Player_SetTag("my_mode");
   
    // Save the data for the player
    Player_WriteInt("kills", gPlayerKills[playerid]);
    Player_WriteInt("deaths", gPlayerDeaths[playerid]);
     
    // Random other data
    Player_WriteString("some_string", "hello");
    Player_WriteFloat("some_float", 2.0);
}

// Load data
// Note that this macro doesn't actually exist in the current version of YSI,
// but I've included it above for simplicity.
LOAD:my_mode(playerid, identifier[], text[])
{
    // Check which data is being loaded and store it.
    // You can use some advanced string methods here such
    // as a modified zcmd if you like.
    if (!strcmp(identifier, "kills")) gPlayerKills[playerid] += strval(text);
    else if (!strcmp(identifier, "deaths")) gPlayerDeaths[playerid] += strval(text);
    else if (!strcmp(identifier, "some_string")) // Do something with "hello"
    else if (!strcmp(identifier, "some_float")) // Do something with floatstr("2.0")
    return 1;
}
IMHO this is vastly simpler than other methods, and it's abstracted to such a point where the underlying save system doesn't matter - it could be the YSI file system, a DUDB file system, a database or anything else. If that's not clear there's plenty more documentation here:

https://sampwiki.blast.hk/wiki/YSI:Players

Also it should be noted that this method of loading and saving data is vastly faster than DINI like methods which opens a file, searches for the data in the whole file, reads, writes or appends it (writing may involve copying the entire file) and closes the file to return, only to do the whole process again for the next piece of information. Writing in YSI buffers a load of data to be written at once and reading loads the entire file at once, passing you any data associated with your mode.

Quote:
Originally Posted by Outbreak
What about gathering something like hard drive serial number for banning a player, would make it near impossible to evade.

I've heard they do this on xbox360 with some games. Is it possible in pawno and samp?
Not without modifying the client.
Reply
#14

I think for the good and fast storing of players accounts needs at list INI files system.. Will be better to use INI plugin with C++ functionality instead of PAWN. imho
Reply
#15

Y_Less, it seems that whenever someone disagrees with you or doesn't like what you have created, you get offended. Then you try to reason with them to get them to use your creation.

Chill out man.
Reply
#16

Quote:
Originally Posted by Awaran[Enemy-Plus
; ]
Y_Less, it seems that whenever someone disagrees with you or doesn't like what you have created, you get offended. Then you try to reason with them to get them to use your creation.

Chill out man.
Or he was trying to explain the flexability of his creation, advising alternative ways of using it?

Don't jump down peoples throats, i created this topic for help and advice, not for nerds such as yourself to cry.

If you've got nothing to useful to add, just move on...


Quote:
Originally Posted by Y_Leѕѕ
As I said that would be separate to any account system as they could change their name, thus loosing all relation to the ban data. There are a number of ban systems already you may wish to look into.
I was thinking of a database of some kind storing all accounts, then another storing all IP addresses and the names associated with them. Making it easy to search an IP address or IP range and get the list of names which have entered the server with the specific IP or IP range.

Then if someone is suspected of ban evading, its easier to check and catch them.

I get a lot of players unregistered, get banned, come back with the same name, different IP address. So i'd want to put the banned name in a database, along with the IP address. This would be part of the ban sytem.

Is it possible? Whats the best method for this?
Reply
#17

Quote:
Originally Posted by Awaran[Enemy-Plus
; ]
Y_Less, it seems that whenever someone disagrees with you or doesn't like what you have created, you get offended. Then you try to reason with them to get them to use your creation.

Chill out man.
I get offended by this statement, not by people disagreeing with me.

The point of this topic was to discuss the best ways of doing a user system, which is what I believe my method is. In line with this view I have presented my argument and backed it up with evidence, although admittedly most of it depends on your point of view - YSI is faster than DINI, you can't deny that as I can prove it, but wether you prefer the syntax is entirely up to you, I do so I come at it from that direction, you're free to disagree.

If someone doesn't agree, as they're free to do, then I will attempt to persuade them, yes, I'm not going to deny this. The easiest way is by addressing concerns raised and showing why they're non issues. In the case of cyber_punk's concern about the directory layout, there is no real solution - that is how it is, and I do see his point (I considered it when writing the system), in that case all I could (and did) do was explain WHY it was like that.

Quote:
Originally Posted by MX_Master
I think for the good and fast storing of players accounts needs at list INI files system.. Will be better to use INI plugin with C++ functionality instead of PAWN. imho
This I agree with entirely, and have considered before. I have never said were I stand on the DB/file issue as although custom code is almost always (if not always when written properly) faster, PAWN is slower than C so timings need to be done. But yes, if the file reading was mostly done in a plugin, I'm almost certain (but again, I have no empirical evidence) that it would be faster.

Edit: I do not pretend that YSI is the answer to everything, I know of quite a few problems, but I designed it from experience of the most common problems people had. The reason I keep mentioning it is because people still have these common problems (that's what makes them common).

Quote:
Originally Posted by Outbreak
Or he was trying to explain the flexability of his creation, advising alternative ways of using it?

Don't jump down peoples throats, i created this topic for help and advice, not for nerds such as yourself to cry.

If you've got nothing to useful to add, just move on...
Thank you.

Quote:
Originally Posted by Outbreak
I was thinking of a database of some kind storing all accounts, then another storing all IP addresses and the names associated with them. Making it easy to search an IP address or IP range and get the list of names which have entered the server with the specific IP or IP range.

Then if someone is suspected of ban evading, its easier to check and catch them.

I get a lot of players unregistered, get banned, come back with the same name, different IP address. So i'd want to put the banned name in a database, along with the IP address. This would be part of the ban sytem.

Is it possible? Whats the best method for this?
I'd agree with the database for this (or that's how I'd do it), they're designed specifically for relations like this.
Reply
#18

So how would i setup a Mysql database?

I've downloaded the sa-mp plugin 0.15

Not sure what i need to do from there. From what i gather, i'll need a mysql hosting server. I signed up to two free ones, but they're giving me more problems than is time worthy.

Trying to setup a database, the site kept crashing, the same happened with the second one i tried.

So, if i can get mysql database hosting from my server providor, how would i go about setting up the databases, then creating the login and registering code?

If someone could provide a link to a site where i could learn this stuff I'd appreiciate it.
Reply
#19

If you're having these problems I'd just use SQLite, it's built into the server so you don't need to do anything.
Reply
#20

Earlier I also used a SQLite database to store the accounts of players. However, after I occured some problems in recording data, I decided to return to the old but proven method of storage - INI files. The problem of incorrect recording of data was only on the operating system LINUX. No such problem on WINDOWS.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)