30.09.2018, 18:06
(
Последний раз редактировалось akaDragonu; 30.09.2018 в 18:56.
)
Hello.
I have a problem with a timer. I made an automated raport for factions, for each member, for 7 days. The explanation of the system is: if the member does not have the finished report, he / she will be automatically given rank 1 / rank up if he / she has finished, rank 2+ receive a warning / rank up if finished.
Timer for the function `CheckRaport` which I put it on in OnGameModeInit:
And kill timer on in OnGameModeExit:
PS: Should I put these on OnPlayerConnect? I don't know..
The function `CheckRaport(playerid)` called when the timer of 7 days for each member of a faction is gone:
(It's a long one, but it's not finished anyway.)
I also made a test command by updating the `ResetRaportDate` table at the time the command is typed, but no results..:
1. How can I create a 7-day timer correctly?
2. Or how can I solve this problem?
Thank you in advance! I hope I understand, I'm waiting for your answers!
I have a problem with a timer. I made an automated raport for factions, for each member, for 7 days. The explanation of the system is: if the member does not have the finished report, he / she will be automatically given rank 1 / rank up if he / she has finished, rank 2+ receive a warning / rank up if finished.
Timer for the function `CheckRaport` which I put it on in OnGameModeInit:
PHP код:
foreach(new player: Player) if(PlayerInfo[player][FactionID] >= 1 && PlayerInfo[player][FactionRank] >= 1) {
RaportTimer[playerid] = SetTimerEx("CheckRaport", 1000, true, "i", player);
}
PHP код:
foreach(new player: Player) if(PlayerInfo[player][FactionID] >= 1 && PlayerInfo[player][FactionRank] >= 1) {
KillTimer(RaportTimer[player]);
}
The function `CheckRaport(playerid)` called when the timer of 7 days for each member of a faction is gone:
(It's a long one, but it's not finished anyway.)
PHP код:
forward CheckRaport(playerid);
public CheckRaport(playerid)
{
new faction = PlayerInfo[playerid][FactionID], rank = PlayerInfo[playerid][FactionRank], query[256], string[256], date[256], name[30], leader[30], result[256], whorankedup[256], whorankedid, day,month,year,h,mi,s; getdate(year,month,day); gettime(h,mi,s);
format(query, sizeof(query), "SELECT * FROM `users` WHERE `name` = '%s' AND `FactionID` >= 1", GPlayerName(playerid));
new Cache:check = mysql_query(SQL, query); if(cache_get_field_count() > 0)
{
new resetdate[128]; format(resetdate, 128, "%s", getdate(year,month,day));
cache_get_field_content(0, "ResetRaportDate", result); format(date, 256, result);
if(strcmp(date, resetdate, true) == 0)
{
KillTimer(RaportTimer[playerid]);
format(query, 256, "SELECT * FROM `users` WHERE `FactionID` = '%d' AND `FactionRank` = '7'", faction);
new Cache:masta = mysql_query(SQL, query); if(cache_get_row_count() >= 1) {
cache_get_field_content(0, "name", result); format(leader, 30, result);
whorankedid = cache_get_field_content_int(0, "id");
new lead = GetPlayerID(leader);
if(IsPlayerConnected(lead)) {
format(whorankedup, sizeof(whorankedup), "%s", name);
}
else if(!IsPlayerConnected(lead)) {
format(whorankedup, sizeof(whorankedup), "AdmBot");
}
return 1;
}
cache_delete(masta);
if(rank == 1 && faction >= 1)
{
if(PlayerInfo[playerid][FactionRaport][0] >= FactionInfo[faction][Raport1][0] && PlayerInfo[playerid][FactionRaport][1] >= FactionInfo[faction][Raport2][0] && PlayerInfo[playerid][FactionRaport][2] >= FactionInfo[faction][Raport3][0])
{ // daca are raportul de factiune terminat si are rank 1, sa ii dea automat rank 2 + resetarea raportului!!
if(PlayerInfo[playerid][FactionWarns] == 0)
{
new rankname[256];
if(rank+1 == 2) format(rankname, sizeof(rankname), "%s", FactionInfo[PlayerInfo[playerid][FactionID]][RankName2]);
else if(rank+1 == 3) format(rankname, sizeof(rankname), "%s", FactionInfo[PlayerInfo[playerid][FactionID]][RankName3]);
else if(rank+1 == 4) format(rankname, sizeof(rankname), "%s", FactionInfo[PlayerInfo[playerid][FactionID]][RankName4]);
else if(rank+1 == 5) format(rankname, sizeof(rankname), "%s", FactionInfo[PlayerInfo[playerid][FactionID]][RankName5]);
else if(rank+1 == 6) format(rankname, sizeof(rankname), "%s", FactionInfo[PlayerInfo[playerid][FactionID]][RankName6]);
format(string, sizeof(string), "{67AAB1}(Faction) {CECECE}%s's faction rank was changed from %d to %d, by %s. {67AAB1}(auto)", GPlayerName(playerid), rank, rank+1, whorankedup), SendFactionMessage(faction, Grey, string), Factionlog(PlayerInfo[playerid][FactionID], PlayerInfo[playerid][AccountID], PlayerInfo[whorankedid][AccountID], string);
format(string, sizeof(string), "{67AAB1}(Faction) {CECECE}You've been promoted to the rank of %s (%d), by %s. {67AAB1}(auto)", GPlayerName(playerid), rankname, rank, whorankedup), SendClientMessage(playerid, Yellow2, string);
mysql_format(SQL, query, sizeof(query), "UPDATE `users` SET `FactionRank` = '%d' WHERE `name` = '%s'", rank+1, GPlayerName(playerid)); mysql_tquery(SQL, query, "", "");
mysql_format(SQL, query, sizeof(query), "UPDATE `users` SET `ResetRaportDate` = '%02d-%02d-%d %02d:%02d:%02d', `FactionRaport1` = '0', `FactionRaport2` = '0' AND `FactionRaport3` = '0' WHERE `name` = '%s'", day,month,year,h,mi,s, GPlayerName(playerid)); mysql_tquery(SQL, query, "", "");
PlayerInfo[playerid][FactionRank] = 2; PlayerInfo[playerid][ResetDateYear] = year;
PlayerInfo[playerid][FactionRaport][0] = 0; PlayerInfo[playerid][ResetDateMonth] = month;
PlayerInfo[playerid][FactionRaport][1] = 0; PlayerInfo[playerid][ResetDateDay] = day;
PlayerInfo[playerid][FactionRaport][2] = 0;
RaportTimer[playerid] = SetTimerEx("CheckRaport", 1000, true, "i", playerid); return 1;
}
}
else if(PlayerInfo[playerid][FactionRaport][0] < FactionInfo[faction][Raport1][0] && PlayerInfo[playerid][FactionRaport][1] < FactionInfo[faction][Raport2][0] && PlayerInfo[playerid][FactionRaport][2] < FactionInfo[faction][Raport3][0])
{ // daca are raportul de factiune neterminat si are rank 1, sa ii dea automat uninvite din factiune si variabilele raportului pe 0!!
if(PlayerInfo[playerid][FactionWarns] >= 0)
{
format(string, sizeof(string), "Ai fost demis de %s din factiunea din care faceai parte %s (rank %d) dupa %d zile, cu 60 FP. Motiv: Raport incomplet. (auto)", whorankedup, GetFactionName(faction), rank, PlayerInfo[playerid][FactionTime]);
mysql_format(SQL, query, sizeof(query), "INSERT INTO `emails` (`playerid`, `Message`) VALUES('%d','%s')", PlayerInfo[playerid][AccountID], string); mysql_tquery(SQL, query, "", "");
format(string, sizeof(string), "%s was uninvited by %s from faction %s (rank %d) after %d days, with 60 FP. Reason: Raport incomplet.", GPlayerName(playerid), whorankedup, GPlayerName(playerid), GetFactionName(faction), rank, PlayerInfo[playerid][FactionTime]), SendFactionMessage(faction, Grey, string), Factionlog(PlayerInfo[playerid][FactionID], PlayerInfo[playerid][AccountID], PlayerInfo[whorankedid][AccountID], string);
mysql_format(SQL, query, sizeof(query), "INSERT INTO `faction_logs` (`text`,`player`,`leader`) VALUES ('%s', '%d', '%d')", string, PlayerInfo[playerid][AccountID], PlayerInfo[whorankedid][AccountID]); mysql_tquery(SQL, query, "", "");
mysql_format(SQL, query, sizeof(query), "UPDATE `users` SET `FactionID` = '0', `FactionRank` = '0', `Skin` = '250', `FactionSkin` = '-1', `FactionPunish` = '60', `FactionWarns` = '0', `FactionTime` = '0', `FactionJoin` = '0' WHERE `id` = '%d'", PlayerInfo[playerid][AccountID]); mysql_tquery(SQL, query, "", "");
mysql_format(SQL, query, sizeof(query), "UPDATE `users` SET `ResetRaportDate` = '0', `FactionRaport1` = '0', `FactionRaport2` = '0' AND `FactionRaport3` = '0' WHERE `name` = '%s'", GPlayerName(playerid)); mysql_tquery(SQL, query, "", "");
PlayerInfo[playerid][FactionID] = 0; PlayerInfo[playerid][FactionRank] = 0;
PlayerInfo[playerid][FactionWarns] = 0; PlayerInfo[playerid][FactionPunish] = 60;
PlayerInfo[playerid][FactionTime] = 0; PlayerInfo[playerid][Skin] = 250;
PlayerInfo[playerid][FactionSkin] = -1; PlayerInfo[playerid][FactionRaport][0] = 0;
PlayerInfo[playerid][FactionRaport][1] = 0; PlayerInfo[playerid][FactionRaport][2] = 0;
SetPlayerArmourEx(playerid, 0); tazer[playerid] = 0; OnDuty[playerid] = 0; ResetPlayerWeapons(playerid);
SetPlayerSkin(playerid, PlayerInfo[playerid][Skin]); SpawnPlayer(playerid); return 1;
}
}
return 1;
}
}
return 1;
}
cache_delete(check); return 1;
}
PHP код:
CMD:resetraport(playerid, params[])
{
new player, string[256], query[256], d,m,y,h,mi,s; getdate(y,m,d); gettime(h,mi,s);
if(PlayerInfo[playerid][AdminLevel] >= 6)
{
if(sscanf(params, "u", player)) return SendClientMessage(playerid, COLOR_TEAL, "Usage: {CECECE}/resetraport <player id>");
if(PlayerInfo[player][FactionID] >= 1 && PlayerInfo[player][FactionRank] <= 6)
{
format(string, sizeof(string), "Administrator %s reseted %s faction raport.", GPlayerName(playerid), GPlayerName(player)), SendMessageToAdmins(DarkNiceRed, string);
mysql_format(SQL, query, sizeof(query), "UPDATE `users` SET `ResetRaportDate` = '%02d-%02d-%d %02d:%02d:%02d', `FactionRaport1` = '0', `FactionRaport2` = '0' AND `FactionRaport3` = '0' WHERE `name` = '%s'", d,m,y,h,mi,s, GPlayerName(player)); mysql_tquery(SQL, query, "", "");
PlayerInfo[playerid][ResetDateYear] = y; PlayerInfo[playerid][ResetDateMonth] = m; PlayerInfo[playerid][ResetDateDay] = d; return 1;
}
else return SendClientMessage(playerid, Grey, "This player doesn't have a faction!");
}
else return 0;
}
2. Or how can I solve this problem?
Thank you in advance! I hope I understand, I'm waiting for your answers!