mysql save -
MerryDeer - 05.09.2016
Hi,
What best way, for example i want to create all days players how much they have score, so i will have to everyday use 'insert into' doing cikle all my players in database and create? for ex:
Code:
/myscore [2016-09-05]
/myscore [2016-09-04]
Re: mysql save -
JordanZaundd - 05.09.2016
It's hard to understand what you're trying to say, but from what I gather you are looking to know how to store the date and score into MySQL using "INSERT INTO"?
PHP Code:
new year, month, day;
getdate(year, month, day);
new date[16];
format(date, sizeof(date), "[%i-%i-%i]", year, month, day);
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new query[256];
mysql_format(connectionHandle, query, sizeof(query), "INSERT INTO `playerscores` (`PlayerName`, `Score`, `Date`) VALUES (`%s`, `%i`, `%s`);", name, GetPlayerScore(playerid), date);
mysql_query(connectionHandle, query);
Re: mysql save -
MerryDeer - 05.09.2016
Yea. But imaginage i have 10000 players in database, i have to use insert into 10000 times? everytime on new day?
Re: mysql save -
JordanZaundd - 05.09.2016
Do you want to UPDATE the player's score every day or store the score separately using INSERT? If you want to replace the existing score, then you'd do something like:
PHP Code:
new query[256], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
mysql_format(connectionHandle, query, sizeof(query), "UPDATE `playerscores` SET `Score` = %i WHERE `PlayerName` = %s", GetPlayerScore(playerid), name);
mysql_query(connectionHandle, query);
Re: mysql save -
Sew_Sumi - 05.09.2016
I don't think you are explaining this at all clear enough, and there'll be a better way to handle this.
Re: mysql save -
MerryDeer - 05.09.2016
I don't know what you don't understand.. Like i want to make log, player can view. Every day log.
Re: mysql save -
Sew_Sumi - 05.09.2016
You could do that by making the log, each time they play, not every day process 10000 dormant accounts...
Re: mysql save -
MerryDeer - 05.09.2016
Yes, but how to save information how create that rows, tables. I know like make log last top20, but if there is thousands? ok i create variable
#define MAX_LOGS 1500
#define MAX_LOG_LENGHT 100
new LOGS[ MAX_PLAYERS ][ MAX_LOGS ][ MAX_LOG_LENGHT ];
So i need to save that variable all 1500, can i create that many rows?
Re: mysql save -
Sew_Sumi - 05.09.2016
Yes you can create that many rows, that is what SQL is for.
Creating variables though is not what you need. You can simply write the info directly to the DB...
You'd only create the variables if you were actually storing it all, in the script itself.
Re: mysql save -
MerryDeer - 05.09.2016
Yes, but in command everytime call database i think it can harm server