05.10.2018, 17:43
Hello.
How to update a mysql tabel when the player is offline? I made an automatic faction raport reset system, and and this is the timer defined in OnGameModeInit:
I don't know how to resolve this problem, question its: How to update a mysql table when the players in factions its offline?
How to update a mysql tabel when the player is offline? I made an automatic faction raport reset system, and and this is the timer defined in OnGameModeInit:
PHP код:
public
new query[2048], string[2048], result[256], name[30], id, color, timer, faction, rank, raport1, raport2, raport3, time, status, playerid, statuss, tim;
format(query, sizeof(query), "SELECT * FROM `users` WHERE `FactionID` >= '1'");
new Cache:check = mysql_query(SQL, query); for(new i, j = cache_get_row_count(); i != j; ++i)
{
cache_get_field_content(i, "name", result); format(name, 256, result);
timer = cache_get_field_content_int(i, "RaportTimer"); raport2 = cache_get_field_content_int(i, "FactionRaport2");
faction = cache_get_field_content_int(i, "FactionID"); raport3 = cache_get_field_content_int(i, "FactionRaport3");
rank = cache_get_field_content_int(i, "FactionRank"); time = cache_get_field_content_int(i, "FactionTime");
raport1 = cache_get_field_content_int(i, "FactionRaport1"); id = cache_get_field_content_int(i, "id");
status = cache_get_field_content_int(i, "Status"); playerid = GetPlayerID(name); statuss = status;
if(IsPlayerConnected(playerid) || statuss == 1) // daca este online
{
PlayerInfo[playerid][ResetRaportDate]--; mysql_format(SQL, query, sizeof(query), "UPDATE `users` SET `RaportTimer` = '%d' WHERE `name` = '%s'
AND `id` = '%d'", PlayerInfo[playerid][ResetRaportDate], GPlayerName(playerid), PlayerInfo[playerid][AccountID]); mysql_tquery(SQL, query, "", "");
if(PlayerInfo[playerid][ResetRaportDate] == 0)
{
if(PlayerInfo[playerid][FactionID] == 1 || PlayerInfo[playerid][FactionID] == 2 || PlayerInfo[playerid][FactionID] == 4 || PlayerInfo[playerid]
[FactionID] == 12 || PlayerInfo[playerid][FactionID] == 20 || PlayerInfo[playerid][FactionID] == 21) color = 0x8D8DFFAA;
else if(PlayerInfo[playerid][FactionID] != 1 || PlayerInfo[playerid][FactionID] != 2 || PlayerInfo[playerid][FactionID] != 4 || PlayerInfo[playerid]
[FactionID] != 12 || PlayerInfo[playerid][FactionID] != 20 || PlayerInfo[playerid][FactionID] != 21) color = 0x009ACDFF;
if(PlayerInfo[playerid][FactionRank] == 1)
{
//PS: This is the timer update when the player is online
}
}
else if(!IsPlayerConnected(playerid) || statuss == 0) // daca nu este online
{
tim = timer - 1; mysql_format(SQL, query, sizeof(query), "UPDATE `users` SET `RaportTimer` = '%d' WHERE `name` = '%s' AND `id` = '%d'", tim,
name, id); mysql_tquery(SQL, query, "", "");
if(tim == 0)
{
new d,m,y,h,mi,s; getdate(y,m,d); gettime(h,mi,s);
if(faction == 1 || faction == 2 || faction == 4 || faction == 12 || faction == 20 || faction == 21) color = 0x8D8DFFAA;
else if(faction != 1 || faction != 2 || faction != 4 || faction != 12 || faction != 20 || faction != 21) color = 0x009ACDFF;
if(rank == 1)
{
//PS: This is the timer update when the player is offline
//PS: Here its the problem, when I connect to the server, and are online and I'm looking at the database, I only update myself, the other players
in the factions remain the same timer, but when I disconnect and I'm in the "offline" section, it keeps updating me on the base but others do not
}
}
return 1;
}
return 1;
}
cache_delete(check); return 1;