[MySQL]Orm system help
#1

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.
Reply
#2

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.
Reply
#3

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.
Reply
#4

Is it registering anything into the database?
Reply
#5

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).
Reply
#6

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
Reply
#7

It's just a simple zcmd command like (not tested):
pawn Код:
CMD:sh(playerid, params[])
{
GivePlayerMoney(playerid, 5000);
SetPlayerScore(playerid, 100);
return 1;
}
Reply
#8

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?
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)