13.10.2014, 10:01
after I learn about orm and i got download basic account script.
i have some question about orm_destroy. how important that is.
because in the script don't have that fuction. and i worry about that.
Following this code.
as u see in the OnPlayerDisconnect it doesn't destroy ORM instance what happen if i make it happen
when another player join new ORM also create ?
and so. if i use the same code when player disconnect and new player join with the same id number.
the ORM id will create a new one id. isn't it? or it use the old orm id or something else.
you can just explain the easyway with me.
(Just a newbie worry about his script please help
)
i have some question about orm_destroy. how important that is.
because in the script don't have that fuction. and i worry about that.
Following this code.
Код:
enum E_PLAYERS
{
ORM:ORM_ID,
ID,
Name[MAX_PLAYER_NAME],
Password[129],
Money,
bool:IsLoggedIn,
bool:IsRegistered,
LoginAttempts,
LoginTimer
};
new Player[MAX_PLAYERS][E_PLAYERS];
new MysqlRaceCheck[MAX_PLAYERS];
Код:
public OnPlayerConnect(playerid)
{
MysqlRaceCheck[playerid]++;
//reset player data
for(new E_PLAYERS:e; e < E_PLAYERS; ++e)
Player[playerid][e] = 0;
GetPlayerName(playerid, Player[playerid][Name], MAX_PLAYER_NAME);
//create orm instance and register all needed variables
new ORM:ormid = Player[playerid][ORM_ID] = orm_create("players", SQL);
orm_addvar_int(ormid, Player[playerid][ID], "id");
orm_addvar_string(ormid, Player[playerid][Name], MAX_PLAYER_NAME, "username");
orm_addvar_string(ormid, Player[playerid][Password], 129, "password");
orm_addvar_int(ormid, Player[playerid][Money], "money");
orm_setkey(ormid, "username");
//tell the orm system to load all data, assign it to our variables and call our callback when ready
orm_load(ormid, "OnPlayerDataLoaded", "dd", playerid, MysqlRaceCheck[playerid]);
return 1;
}
Код:
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;
}
when another player join new ORM also create ?
and so. if i use the same code when player disconnect and new player join with the same id number.
the ORM id will create a new one id. isn't it? or it use the old orm id or something else.
you can just explain the easyway with me.
(Just a newbie worry about his script please help
)

