Making VIP for Temporary time
#1

Can you help me editing my /makevip cmd in such a way that i can make vip temporarily for example
[Usage]:/makevip [playerid] [level] [months]. And ones it reaches the given time it automatically expires.
Heres the code
Код:
CMD:makevip(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 1338 || PlayerInfo[playerid][pShopTech] >= 1)
	{
		new string[128], giveplayerid, level;
		if(sscanf(params, "ud", giveplayerid, level))
		{
			SendClientMessageEx(playerid, COLOR_WHITE, "[Usage]: /makevip [playerid] [level]");
			SendClientMessageEx(playerid, COLOR_MEDIUMBLUE, "Available Levels: |0| None |1| Bronze |2| Silver |3| Gold |4| Platinum |5| Diamond");
			return 1;
		}

		if(IsPlayerConnected(giveplayerid))
		{
			if(giveplayerid != INVALID_PLAYER_ID)
			{
				if(level < 0 || level > 5)
				{
					SendClientMessageEx(playerid, COLOR_GRAD1, "There are only five VIP levels [1 to 5]!");
					return 1;
				}
				PlayerInfo[giveplayerid][pDonateRank] = level;
				PlayerInfo[giveplayerid][pTempVIP] = 0;
				PlayerInfo[giveplayerid][pBuddyInvited] = 0;
				new year, month,day;
				getdate(year, month, day);
				new playerip[32];
				GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
				if(level == 0)
				{
					if (PlayerInfo[playerid][pAdmin] < 1337)
					{
						format(string, sizeof(string), "VIP: %s has suspended %s's VIP Package, Therefore they are not a VIP anymore.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
					format(string, sizeof(string), "VIP: %s has suspended %s's VIP Package, Therefore they are not a VIP anymore.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
					ABroadCast(COLOR_LIGHTRED,string, 1337);
					format(string, sizeof(string), "Your VIP Package has been suspended by Admin %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
					PlayerInfo[giveplayerid][pTokens] = 0;

					format(string, sizeof(string), "VIP: %s has set %s's (IP:%s) VIP level to None (%d). (%d-%d-%d)", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), playerip, level, month,day,year);
					Log("logs/setvip.log", string);
					return 1;
				}
				if(level == 1)
				{	if (PlayerInfo[playerid][pAdmin] < 1337)
					{
						format(string, sizeof(string), "VIP: %s has set %s's VIP level to Bronze (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
					format(string, sizeof(string), "VIP: %s has set %s's VIP level to Bronze (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
					ABroadCast(COLOR_LIGHTRED,string, 1337);
					format(string, sizeof(string), "You have been given a full month Bronze VIP Package by %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_ORANGE, string);

					format(string, sizeof(string), "VIP: %s has set %s's (IP:%s) VIP level to Bronze (%d). (%d-%d-%d)", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), playerip, level, month,day,year);
					Log("logs/setvip.log", string);
					return 1;
				}
				if(level == 2)
				{
				    	if (PlayerInfo[playerid][pAdmin] < 1337)
					{
						format(string, sizeof(string), "VIP: %s has set %s's VIP level to Silver (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
						format(string, sizeof(string), "VIP: %s has set %s's VIP level to Silver (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						ABroadCast(COLOR_LIGHTRED,string, 1337);
						format(string, sizeof(string), "You have been given a full month Silver VIP Package by %s.", GetPlayerNameEx(playerid));
						SendClientMessageEx(giveplayerid, COLOR_ORANGE, string);

					format(string, sizeof(string), "VIP: %s has set %s's (IP:%s) VIP level to Silver (%d). (%d-%d-%d)", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), playerip, level, month,day,year);
					Log("logs/setvip.log", string);
					return 1;
				}
				if(level == 3)
				{
				    if (PlayerInfo[playerid][pAdmin] < 1337)
					{
						format(string, sizeof(string), "VIP: %s has set %s's VIP level to Gold (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
					format(string, sizeof(string), "VIP: %s has set %s's VIP level to Gold (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
					ABroadCast(COLOR_LIGHTRED,string, 1337);
					format(string, sizeof(string), "Your have been given a full month Gold VIP Package by %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_ORANGE, string);

					format(string, sizeof(string), "VIP: %s has set %s's (IP:%s) VIP level to Gold (%d). (%d-%d-%d)", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), playerip, level, month,day,year);
					Log("logs/setvip.log", string);
					return 1;
				}
				if(level == 4)
				{
				    if (PlayerInfo[playerid][pAdmin] < 1337)
					{
						format(string, sizeof(string), "VIP: %s has set %s's VIP level to Platinum (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
					format(string, sizeof(string), "VIP: %s has set %s's VIP level to Platinum (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
					ABroadCast(COLOR_LIGHTRED,string, 1337);
					format(string, sizeof(string), "Your have been given a full month Platinum VIP Package by %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_ORANGE, string);

					// Level 5 Arms Job - Platinum VIP
					PlayerInfo[giveplayerid][pArmsSkill] = 401;

					format(string, sizeof(string), ": %s has set %s's (IP:%s) VIP level to Platinum (%d). (%d-%d-%d)", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), playerip, level, month,day,year);
					Log("logs/setvip.log", string);
					return 1;
				}
				if(level == 5)
				{
					if (PlayerInfo[playerid][pAdmin] < 1337)
					{
						format(string, sizeof(string), "VIP: %s has set %s's VIP level to Diamond (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
					format(string, sizeof(string), "VIP: %s has set %s's VIP level to Diamond (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
					ABroadCast(COLOR_LIGHTRED,string, 1337);
					format(string, sizeof(string), "You have been given a full month Diamond VIP Package by %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_ORANGE, string);

					format(string, sizeof(string), "VIP: %s has set %s's (IP:%s) VIP level to Diamond (%d). (%d-%d-%d)", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), playerip, level, month,day,year);
					Log("logs/setvip.log", string);
					return 1;
				}
			}
		}
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
	}
	return 1;
}
Reply
#2

Quote:
Originally Posted by Roel
Посмотреть сообщение
you should use timestamp for this.
instead of saving the data, save the timestamp
Код:
expiretimestamp = gettime() + TOTAL DAYS HE WILL BE VIP * 24 * 60 * 60;
// remove the TOTAL DAYS HE WILL BE VIP to the days he will be vip.
// save expiretimestamp into the dini as 'vipdate'
Код:
// For exampe at every login you use this:
if(dini_Int(path,"vipdate") < gettime())
{
  // expired
}
Try this that I posted a while ago.
I hope you are able to import this to your script by yourself, because I'm not going to do it.
Reply
#3

Oh thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)