20.10.2015, 18:03
Hello, which is the safest and best option?
OPTION 1:
Every time there is a value to a particular variable the player should be updated.
Exemple:
OPTION 2:
All value modified save to disconnect the player.
Exemple:
OPTION 1:
Every time there is a value to a particular variable the player should be updated.
Exemple:
Код HTML:
pInfo[playerid][pPhoneNumber] = 58823; VPUpdate(playerid, pPhoneNumberu); pInfo[playerid][pPhoneBook] = 1; VPUpdate(playerid, pPhoneBooku); pInfo[playerid][pScore] = 1; VPUpdate(playerid, pScoreu);
Код HTML:
forward VPUpdate(id, update); public VPUpdate(id, update) { new query[254]; if(IsPlayerConnected(id)) { switch(update) { case pAdminu: { mysql_format(MySQLCon, query, sizeof(query), "UPDATE players SET Admin='%d' WHERE user='%s'", pInfo[id][pAdmin], GetName(id)); } case pHelperu: { mysql_format(MySQLCon, query, sizeof(query), "UPDATE players SET Helper='%d' WHERE user='%s'", pInfo[id][pHelper], GetName(id)); } case pMoneyu: { mysql_format(MySQLCon, query, sizeof(query), "UPDATE players SET Money='%d' WHERE user='%s'", pInfo[id][pMoney], GetName(id)); } case pScoreu: { mysql_format(MySQLCon, query, sizeof(query), "UPDATE players SET Score='%d' WHERE user='%s'", pInfo[id][pScore], GetName(id)); } case pStatusu: { mysql_format(MySQLCon, query, sizeof(query), "UPDATE players SET Status='%d' WHERE user='%s'", pInfo[id][pStatus], GetName(id)); } //.......................................... } mysql_pquery(MySQLCon, query); } return 1; }
All value modified save to disconnect the player.
Exemple:
Код HTML:
public OnPlayerDisconnect(playerid, reason) { mysql_format(MySQLCon, query, sizeof(query), "UPDATE `players` SET `Admin`=%d, `Vip`=%d, `Money`=%d, `Score`=%d, `TrustedLevel`=%d, `Deaths`=%d, `Kills`=%d, `X`=%f, `Y`=%f, `Z`=%f, `FacingAngle`=%f, `Interior`=%d,`VW`=0,`SkinID`=%d WHERE `ID`=%d AND `user`='%e'", pInfo[playerid][pAdmin], pInfo[playerid][pVip], GetPlayerMoney(playerid), GetPlayerScore(playerid), pInfo[playerid][pTrustedLevel], pInfo[playerid][pDeaths], pInfo[playerid][pKills], pPos[0], pPos[1], pPos[2], FacingAngle, GetPlayerInterior(playerid), pInfo[playerid][pSkinID], pInfo[playerid][pID], PlayerName(playerid)); mysql_tquery(MySQLCon, query, "", ""); return 1; }