26.12.2015, 08:24
guys how to make timer for auto remove vip?
if(timestamp() >= GetPVarInt(playerid,"VIPExpiration"))
{
SetPVarInt(playerid, "VIP", 0);
SendClientMessage(playerid, 0xFF0000FF, "Your VIP time has expired.");
}
SetPVarInt(playerid,"VIPExpiration", timestamp()+2592000);
new Year, Month, Day;
getdate(Year, Month, Day);
new Days = getdate(), name[MAX_PLAYER_NAME], str[128];
if(PlayerInfo[playerid][pVip] >= 1)
{
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str),"/Asystem/Users/%s.ini",name);
new INI:ini = INI_Open(str);
INI_SetTag(ini,"data");
INI_WriteInt(ini,"Vipdays",PlayerInfo[playerid][pVipdays] -= Day);
INI_Close(ini);
}
if(PlayerInfo[playerid][pVip] >= 1)
{
if(PlayerInfo[playerid][pVipdays] < Days)
{
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str),"/Asystem/Users/%s.ini",name);
new INI:ini = INI_Open(str);
INI_SetTag(ini,"data");
INI_WriteInt(ini,"Vipdays",0);
INI_WriteInt(ini,"Vip",0);
INI_Close(ini);
SendClientMessage(playerid, COLOR_RED, "Your vip has ended!if you want to buy vip , visit our website:");
}
}
CMD:setvip(playerid, params[])
{
new victimname[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], viplvl, id, tmp[128], name[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][pAdmin] >= CmdsOptions[setvip] || IsPlayerAdmin(playerid))
{
if (sscanf(params, "ui", id, viplvl)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setvip [id] [Viplevel]");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[ERROR]:Invalid ID");
if (viplvl > 5 || viplvl < 0) return SendClientMessage(playerid, COLOR_RED,"[ERROR]:Valid Vip Levels: 1-5!");
PlayerInfo[id][pVip] = viplvl;
GetPlayerName(id, victimname, sizeof(victimname));
GetPlayerName(playerid, adminname, sizeof(adminname));
GetPlayerName(id, name, sizeof(name));
format(tmp, sizeof(tmp),"/Asystem/Users/%s.ini",name);
new Year, Month, Day;
getdate(Year, Month, Day);
Day += 30;
new INI:ini = INI_Open(tmp);
INI_SetTag(ini,"data");
INI_WriteInt(ini,"Vipdays",Day);
INI_Close(ini);
new str[128];
format(str,128,"Admin %s v has set %s [ID %d] vip level to %i",adminname, playerid, victimname, id, viplvl);
SendClientMessage(playerid,COLOR_BLUE,str);
new string[128];
format(string,128,"Admin %s (id:%d) has set your vip level to %i",adminname, playerid, viplvl);
SendClientMessage(id,COLOR_BLUE,string);
return 1;
}
else return SendClientMessage(playerid,COLOR_RED,"You do not have permission to use this command!");
}