[MySQL]Orm system help -
x96664 - 09.01.2014
Hi guys, I decided to learn how to use the orm system which
this MySQL plugin has. I read the tutorial provided by AndreT and still couldn't get how to save player data.
I took the following code from the example scripts (by Pain123/maddinat0r), you can find them on the plugin page:
pawn Код:
enum E_PLAYERS
{
ORM:ORM_ID,
ID,
Name[MAX_PLAYER_NAME],
Password[129],
Money
};
new Player[MAX_PLAYERS][E_PLAYERS];
public OnPlayerDisconnect(playerid,reason)
{
MysqlRaceCheck[playerid]++;
if(Player[playerid][IsLoggedIn] && Player[playerid][ID] > 0)
orm_save(Player[playerid][ORM_ID]); //if Player[playerid][ID] has a valid value, orm_save sends an UPDATE query, else an INSERT query
return 1;
}
So it doesn't save the money, either score or whatever else. I was told that the plugin creates the queries for me and I just need to use
orm_update and
orm_save like this:
pawn Код:
orm_update(playerid, pInfo[playerid][ID];
I still find using cache much easier than orm. If someone can explain me how to save the player data I will be really thankful.
Re: [MySQL]Orm system help -
sammp - 09.01.2014
Have you got under OnPlayerConnect something like this:
orm_addvar_int(ormid, Player[playerid][Name], "Username"):
orm_setkey(ormid, "Username");
You need that, make sure you've got it.
Re: [MySQL]Orm system help -
x96664 - 09.01.2014
Quote:
Originally Posted by sammp
Have you got under OnPlayerConnect something like this:
orm_addvar_int(ormid, Player[playerid][Name], "Username"):
orm_setkey(ormid, "Username");
You need that, make sure you've got it.
|
There you can see the whole script. And it does.
Re: [MySQL]Orm system help -
sammp - 09.01.2014
Is it registering anything into the database?
Re: [MySQL]Orm system help -
x96664 - 09.01.2014
Quote:
Originally Posted by sammp
Is it registering anything into the database?
|
Yeah it saves my password and name and Im able to login, but it doesn't save my money or score (I used a command to add them).
Re: [MySQL]Orm system help -
sammp - 09.01.2014
Command code please? You could use mysql_tquery, I use that and ORM functions as i ain't familiar with ORM as much as I am tqueries
Re: [MySQL]Orm system help -
x96664 - 10.01.2014
It's just a simple zcmd command like (not tested):
pawn Код:
CMD:sh(playerid, params[])
{
GivePlayerMoney(playerid, 5000);
SetPlayerScore(playerid, 100);
return 1;
}
Re: [MySQL]Orm system help -
maddinat0r - 10.01.2014
So your problem is, that the data isn't saved / orm_save does nothing? Is the loading code / login system working?
EDIT:
Did you also checked your mysql log file (mysql_log.html, open this file with your browser) for errors?
Re: [MySQL]Orm system help -
x96664 - 11.01.2014
Quote:
Originally Posted by maddinat0r
So your problem is, that the data isn't saved / orm_save does nothing? Is the loading code / login system working?
EDIT:
Did you also checked your mysql log file (mysql_log.html, open this file with your browser) for errors?
|
The login system works, i.e. it saves my nickname and password also the log file is clean.