pawn Код:
public OnGameModeInit()
{
SetTimer("CheckVIP", 60000, true);
return 1;
}
CMD:setvip(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 99999 && !PlayerInfo[playerid][pShopTech]) 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 SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /setvip [playerid] [level] [days] [hours]") &&
SendClientMessageEx(playerid, COLOR_GRAD3, "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 SendClientMessageEx(playerid, COLOR_GRAD1, "VIP Level can not be below 0 or above 5.");
if(!(0 <= days <= 30)) return SendClientMessageEx(playerid, COLOR_GREY, "VIP Days can't be bigger than 30 days.");
if(!(0 <= hours <= 23)) return SendClientMessageEx(playerid, COLOR_GREY, "VIP Hours can't be bigger than 23 hours.");
new string[128], viptime = (gettime() + ConvertToSeconds(.days = days, .hours = hours));
PlayerInfo[giveplayerid][pDonateRank] = level;
PlayerInfo[giveplayerid][pTempVIP] = viptime;
PlayerInfo[giveplayerid][pBuddyInvited] = 1;
new INI:File = INI_Open("user.ini");
INI_SetTag(File, "data");
INI_WriteInt(File, "TempVIP", PlayerInfo[giveplayerid][pTempVIP]);
INI_WriteInt(File, "DonateRank", PlayerInfo[giveplayerid][pDonateRank]);
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;
}
forward CheckVIP();
public CheckVIP()
{
for(new i = 0; i < MAX_PLAYERS; i++) //foreach is the better option
{
if(!IsPlayerConnected(i)) continue;
if(!PlayerInfo[i][pTempVIP]) continue;
if(PlayerInfo[i][pTempVIP] <= gettime())
{
PlayerInfo[i][pTempVIP] = 0;
PlayerInfo[i][pDonateRank] = 0;
SendClientMessage(i, -1, "Your VIP has expired.");
}
}
return 1;
}
stock ConvertToSeconds(years = 0, months = 0, days = 0, hours = 0, minutes = 0, seconds = 0)
{
new time = 0;
time += (years * 31536000); //Assumptions that each year is 365 days.
time += (months * 2592000); //Assumptions that each month is 30 days.
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;
}
forward LoadDonator_data(playerid, name[], value[]);
public LoadDonator_data(playerid, name[], value[])
{
INI_Int("TempVIP", PlayerInfo[playerid][pTempVIP]);
INI_Int("DonateRank", PlayerInfo[playerid][pDonateRank]);
return 1;
}
You didn't post the rest of your code, so I made up the rest with what I thought you would be wanting.