14.03.2019, 20:36
Quote:
Ohhh, i thought the timestamp will be readable numbers.
Can you give me an example how to use the ConvertToDaysAndHours to save in y_ini? Thanks btw i am learning! |
pawn Код:
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", ConvertToSeconds(0, 0, days, hours, 0, 0);
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;
}