14.03.2019, 20:13
Hello, I am using y_ini to save the temp vip time and every 60 secounds checking if player has vip time passed.
When i set /setvip [id] [viprank] [day] [hours]
i get random numbers in the file that are so big not even close to what i set.
BEGIN
OnGameModeInit
CheckVIP
AND the main cmd
After i set my vip to be 1 day and 1 hour in the .ini stays VipTime = 1552683918 !!!
Please help me i am new to this
When i set /setvip [id] [viprank] [day] [hours]
i get random numbers in the file that are so big not even close to what i set.
BEGIN
Код:
#define DONATORPATH "/donators/%s.ini" enum pInfo { pPass, pCash, pKills, pDeaths, pVipRank, pVipTime, pAdmin, pBanned } forward LoadDonator_data(playerid, name[], value[]); stock DonatorPath(playerid) { new string[128],playername[MAX_PLAYER_NAME]; GetPlayerName(playerid, playername, sizeof(playername)); format(string,sizeof(string),DONATORPATH,playername); return string; } stock ConvertToSeconds(years = 0, months = 0, days = 0, hours = 0, minutes = 0, seconds = 0) { new time = 0; time += (years * 31536000); time += (months * 2592000); time += (days * 86400); time += (hours * 3600); time += (minutes * 60); time += seconds; return time; } stock ConvertToDaysAndHours(days = 0, hours = 0, minutes = 0, seconds = 0) { while(seconds >= 60) minutes++, seconds -= 60; while(minutes >= 60) hours++, minutes -= 60; while(hours >= 24) days++, hours -= 24; new string[55], fstr[20]; if(days) format(fstr, sizeof(fstr), (hours || minutes || seconds) ? ("%d days, ") : ("%d days"), days), strins(string, fstr, 0); if(hours) format(fstr, sizeof(fstr), (minutes || seconds) ? ("%d hours, ") : ("%d hours"), hours), strins(string, fstr, strlen(string)); if(minutes) format(fstr, sizeof(fstr), (seconds) ? ("%d minutes, ") : ("%d minutes"), minutes), strins(string, fstr, strlen(string)); if(seconds) format(fstr, sizeof(fstr), "%d seconds", seconds), strins(string, fstr, strlen(string)); return string; }
Код:
SetTimer("CheckVIP", 60000, true);
Код:
forward CheckVIP(); public CheckVIP() { for(new i = 0; i < MAX_PLAYERS; i++) { if(!IsPlayerConnected(i)) continue; if(!PlayerInfo[i][pVipTime]) continue; if(PlayerInfo[i][pVipTime] <= gettime()) { PlayerInfo[i][pVipTime] = 0; PlayerInfo[i][pVipRank] = 0; SendClientMessage(i, -1, "Your VIP has expired."); } } return 1; }
Код:
CMD:setvip(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] < 5) return SendClientMessage(playerid, -1, "You are not authorised to use this command."); new giveplayerid, level, days, hours; if(sscanf(params, "uddd", giveplayerid, level, days, hours)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setvip [playerid] [level] [days] [hours]") && SendClientMessage(playerid, COLOR_SIVA, "Available Levels: |0| None |1| Bronze |2| Silver |3| Gold |4| Platinum |5| Moderator"); if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player is not connected."); if(!(0 <= level <= 5)) return SendClientMessage(playerid, COLOR_SIVA, "VIP Level can not be below 0 or above 5."); if(!(0 <= days <= 30)) return SendClientMessage(playerid, COLOR_SIVA, "VIP Days can't be bigger than 30 days."); if(!(0 <= hours <= 23)) return SendClientMessage(playerid, COLOR_SIVA, "VIP Hours can't be bigger than 23 hours."); new string[128], viptime = (gettime() + ConvertToSeconds(.days = days, .hours = hours)); PlayerInfo[giveplayerid][pVipRank] = level; PlayerInfo[giveplayerid][pVipTime] = viptime; new INI:File = INI_Open(DonatorPath(playerid)); INI_SetTag(File, "data"); INI_WriteInt(File, "VipTime", PlayerInfo[giveplayerid][pVipTime]); INI_WriteInt(File, "VipRank", PlayerInfo[giveplayerid][pVipRank]); INI_Close(File); new rank[15]; switch(level) { case 0: rank = "Normal Player"; case 1: rank = "Bronze VIP"; case 2: rank = "Silver VIP"; case 3: rank = "Gold VIP"; case 4: rank = "Platinum VIP"; case 5: rank = "Moderator"; } format(string, sizeof(string), "You have been given a %s status.", rank); SendClientMessage(giveplayerid, -1, string); format(string, sizeof(string), "You have given a %s status.", rank); SendClientMessage(playerid, -1, string); return 1; }
Please help me i am new to this