[GameMode] [MySQL R41-4] Login / Register Base Script
#41

Quote:
Originally Posted by user5487
Посмотреть сообщение
where can i see sql log i use xampp
Server folder/logs/plugins/mysql_log.txt
Reply
#42

i set passowrd for DB and its work fine now thx @willbedie for sql_log.txt
Reply
#43

which MySQL version do you use?
Reply
#44

Quote:
Originally Posted by Kincaid
Посмотреть сообщение
which MySQL version do you use?



?
Reply
#45

Quote:
Originally Posted by Kincaid
Посмотреть сообщение
which MySQL version do you use?
Did you completely ignore the title or?
Reply
#46

oh, It's my bad :v. Thanks for your fast response
Reply
#47

I found a bug :O. Stats are not saved.

Here is the code for SavePlayer func.

forward SavePlayer(playerid);
public SavePlayer(playerid)
{
new query[1000];
new
string[800]
;

format(string, sizeof(string), "%s Cash=%d,", string, pdata[playerid][Cash]);

format(string, sizeof(string), "%s Kills=%d,", string, pdata[playerid][Kills]);

format(string, sizeof(string), "%s Deaths=%d,", string, pdata[playerid][Deaths]);

format(string, sizeof(string), "%s Level=%d,", string, pdata[playerid][Level]);

format(string, sizeof(string), "%s Score=%d,", string, pdata[playerid][Score]);

format(string, sizeof(string), "%s XP=%d,", string, pdata[playerid][XP]);

format(string, sizeof(string), "%s Coins=%d,", string, pdata[playerid][Coins]);

mysql_format(Database, query, sizeof(query), "UPDATE `users` SET %s WHERE `Username` = '%s'", string, GetName(playerid));
mysql_tquery(Database, query); //We will execute the query.
return 1;
}

here is a screenshot for table structure: http://prntscr.com/laj7md

- thanks for helping
Reply
#48

It might be you only, check mysql_log.txt and post it here.
Reply
#49

that's weird..
[Thu Oct 25 20:22:44 2018] -------------------------
[Thu Oct 25 20:22:44 2018] Logging Started
[Thu Oct 25 20:22:44 2018] -------------------------
[Thu Oct 25 20:23:20 2018] -------------------------
[Thu Oct 25 20:23:20 2018] Logging Started
[Thu Oct 25 20:23:20 2018] -------------------------
[Thu Oct 25 20:24:42 2018] -------------------------
[Thu Oct 25 20:24:42 2018] Logging Started
[Thu Oct 25 20:24:42 2018] -------------------------
[Thu Oct 25 20:25:36 2018] -------------------------
[Thu Oct 25 20:25:36 2018] Logging Started
[Thu Oct 25 20:25:36 2018] -------------------------
[Thu Oct 25 20:27:37 2018] -------------------------
[Thu Oct 25 20:27:37 2018] Logging Started
[Thu Oct 25 20:27:37 2018] -------------------------
[Thu Oct 25 20:28:43 2018] -------------------------
[Thu Oct 25 20:28:43 2018] Logging Started
[Thu Oct 25 20:28:43 2018] -------------------------
[Thu Oct 25 20:32:29 2018] -------------------------
[Thu Oct 25 20:32:29 2018] Logging Started
[Thu Oct 25 20:32:29 2018] -------------------------
[Thu Oct 25 20:33:15 2018] -------------------------
[Thu Oct 25 20:33:15 2018] Logging Started
[Thu Oct 25 20:33:15 2018] -------------------------
[Thu Oct 25 21:00:29 2018] -------------------------
[Thu Oct 25 21:00:29 2018] Logging Started
[Thu Oct 25 21:00:29 2018] -------------------------
[Thu Oct 25 21:00:54 2018] -------------------------
[Thu Oct 25 21:00:54 2018] Logging Started
[Thu Oct 25 21:00:54 2018] -------------------------
[Thu Oct 25 21:01:04 2018] -------------------------
[Thu Oct 25 21:01:04 2018] Logging Started
[Thu Oct 25 21:01:04 2018] -------------------------
[Thu Oct 25 21:08:16 2018] -------------------------
[Thu Oct 25 21:08:16 2018] Logging Started
[Thu Oct 25 21:08:16 2018] -------------------------
[Thu Oct 25 21:10:29 2018] -------------------------
[Thu Oct 25 21:10:29 2018] Logging Started
[Thu Oct 25 21:10:29 2018] -------------------------
[Thu Oct 25 21:10:36 2018] -------------------------
[Thu Oct 25 21:10:36 2018] Logging Started
[Thu Oct 25 21:10:36 2018] -------------------------
Reply
#50

That has nothing to do with my filterscript and/or with my other scripts.
Reply
#51

- Updated:

V1.1
  • Added BCrypt version (very recommended to use)
  • Fixed some account saving issues
  • Removed AUTO_RECONNECT code OnGameModeInit (MySQL has that option itself without having to do anything)
  • Passwords get hashed and salted, no need to do both separatedly.


Thanks to Bork for suggesting stuff / helping me finish this. Enjoy!

Github
Pastebin


P.S: Here's how a 5 characters password looks like (hashed, salted):

Reply
#52

Good stuff!
Reply
#53

This will not work (no active cache): https://github.com/willbedie/MySQL-L...g.pwn#L92-#L93

You select everything from the row twice + another one to select the password:
https://github.com/willbedie/MySQL-L...g.pwn#L45-#L46
https://github.com/willbedie/MySQL-L...pwn#L126-#L127
https://github.com/willbedie/MySQL-L...g.pwn#L91-#L92

The first query should lookup the database by the name of the player. Any other query should identify records by their registration ID.
Set necessary keys (name of player will always be unique) to improve searching speed.

In `OnPlayerRegister` public function you should retrieve the insert id generated using the cache function: https://github.com/willbedie/MySQL-L...pwn#L111-#L117

Since you have two different scripts, one with bcrypt and the other one with Whirlpool you should have a .sql file for each one of them.
bcrypt output is 60 so why `Password` column to be varchar(129)? It is also a fixed-length so make it char(60).

Set default values for cash, kills and deaths.

When you know an amount (integer value) cannot be negative, declare it as unsigned.

There are different integer types, you should choose wisely: https://dev.mysql.com/doc/refman/8.0...ger-types.html
Reply
#54

Nice Work!
Reply
#55

Good Work
Reply
#56

Maybe im stupid, or I missed something. When player registers on the server, are u sure, that he's data gonna be saved when he will disconnect ? Cuz, I was trying all the ways, and the most common idea I made, that you have to pull he's 'ID' from database after he regs, to save he's data on first time he joins and leaves the server. On second time if you will connect, it's ok, it saves everything. I hope you got it.
Reply
#57

Quote:
Originally Posted by bogushas
Посмотреть сообщение
Maybe im stupid, or I missed something. When player registers on the server, are u sure, that he's data gonna be saved when he will disconnect ? Cuz, I was trying all the ways, and the most common idea I made, that you have to pull he's 'ID' from database after he regs, to save he's data on first time he joins and leaves the server. On second time if you will connect, it's ok, it saves everything. I hope you got it.
It doesn't save if you force-shut down the server, like if you're in windows and close the "samp-server.exe" thing, it won't save the data. You will have to quit the game to save the data.
Reply
#58

Lack recover password, but, the system is good.
Reply
#59

V1.2 (BCrypt)

Код:
[+] Updated with a new command - /changepassword
From now on, you need zcmd to compile the script.
Reply
#60

Not bad but obviously basic. Needs_Rehash function from bcrypt include can be included in case work factor changes as technology progresses. Also the GitHub repo .amx is not updated. Aside from this, could be extended through second password confirmation box, email for recovery (even if this is manual). GPCI hash can also be another useful metric for ban evaders though obviously not foolproof.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)