SA-MP Forums Archive
Vip with limited time - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Vip with limited time (/showthread.php?tid=504887)



Vip with limited time - ChristianIvann09 - 06.04.2014

I have an Auto G-VIP refund at my server. I want it will only work in 1 month

like /maketempvip

Код:
CMD:setvip(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminDuty] == 0) return SendClientMessage(playerid, -1, "You must be on Admin Duty to use this Command!");
	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: /setvip [playerid] [level]");
			SendClientMessageEx(playerid, COLOR_GRAD3, "Available Levels: |0| None |1| Bronze |2| Silver |3| Gold |4| Platinum |5| Moderator");
			return 1;
		}

		if(IsPlayerConnected(giveplayerid))
		{
			if(giveplayerid != INVALID_PLAYER_ID)
			{
				if(level < 0 || level > 5)
				{
					SendClientMessageEx(playerid, COLOR_GRAD1, "VIP Level can not be below 0 or above 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), "AdmCmd: %s has set %s's VIP level to None (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
					format(string, sizeof(string), "AdmCmd: %s has set %s's VIP level to None (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
					ABroadCast(COLOR_LIGHTRED,string, 1337);
					format(string, sizeof(string), "Your VIP level has been set to None by Admin %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
					PlayerInfo[giveplayerid][pTokens] = 0;

					format(string, sizeof(string), "AdmCmd: %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), "AdmCmd: %s has set %s's VIP level to Bronze (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
					format(string, sizeof(string), "AdmCmd: %s has set %s's VIP level to Bronze (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
					ABroadCast(COLOR_LIGHTRED,string, 1337);
					format(string, sizeof(string), "Your VIP level has been set to Bronze by Admin %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_WHITE, string);

					format(string, sizeof(string), "AdmCmd: %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), "AdmCmd: %s has set %s's VIP level to Silver (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
					format(string, sizeof(string), "AdmCmd: %s has set %s's VIP level to Silver (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
					ABroadCast(COLOR_LIGHTRED,string, 1337);
					format(string, sizeof(string), "Your VIP level has been set to Silver by Admin %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_WHITE, string);

					format(string, sizeof(string), "AdmCmd: %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), "AdmCmd: %s has set %s's VIP level to Gold (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
					format(string, sizeof(string), "AdmCmd: %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 VIP level has been set to Gold by Admin %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_WHITE, string);

					format(string, sizeof(string), "AdmCmd: %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), "AdmCmd: %s has set %s's VIP level to Platinum (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
					format(string, sizeof(string), "AdmCmd: %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 VIP level has been set to Platinum by Admin %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_WHITE, string);

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

					format(string, sizeof(string), "AdmCmd: %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), "AdmCmd: %s has set %s's VIP level to Moderator (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
						SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
					}
					format(string, sizeof(string), "AdmCmd: %s has set %s's VIP level to Moderator (%d).", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), level);
					ABroadCast(COLOR_LIGHTRED,string, 1337);
					format(string, sizeof(string), "Your VIP level has been set to Moderator by Admin %s.", GetPlayerNameEx(playerid));
					SendClientMessageEx(giveplayerid, COLOR_WHITE, string);

					format(string, sizeof(string), "AdmCmd: %s has set %s's (IP:%s) VIP level to Moderator (%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;
}
Thank you


Re: Vip with limited time - ]Rafaellos[ - 06.04.2014

An easy way to do it is when you make someone VIP, you calculate the date that is going to get remove it, save it in his data and every time he login you check if it's the expiration date to remove his VIP status.


Re: Vip with limited time - ChristianIvann09 - 06.04.2014

Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
An easy way to do it is when you make someone VIP, you calculate the date that is going to get remove it, save it in his data and every time he login you check if it's the expiration date to remove his VIP status.
Im just a beginnner scripter can you do it for me?


Re: Vip with limited time - xXShadowXx - 06.04.2014

pawn Код:
#define IsPlayerVip(%0)             (gettime() < pVipExpiry[%0])
#define ExtendPlayerVip(%0,%1)      if(pVipExpiry[%0] > gettime()) pVipExpiry[%0] += (86400 * %1); else pVipExpiry[%0] = (gettime() + (86400 * %1))

new pVipExpiry[MAX_PLAYERS];
Use ExtendPlayerVip(playerid,days); in your /makevip command.
Use if(IsPlayerVip(playerid)) in your vip commands, it returns 1 if the player is vip or 0 if not.

Don't forget to store the expiry date somewhere, and load / save it.


Re: Vip with limited time - ChristianIvann09 - 06.04.2014

Quote:
Originally Posted by xXShadowXx
Посмотреть сообщение
pawn Код:
#define IsPlayerVip(%0)             (gettime() < pVipExpiry[%0])
#define ExtendPlayerVip(%0,%1)      if(pVipExpiry[%0] > gettime()) pVipExpiry[%0] += (86400 * %1); else pVipExpiry[%0] = (gettime() + (86400 * %1))

new pVipExpiry[MAX_PLAYERS];
Use ExtendPlayerVip(playerid,days); in your /makevip command.
Use if(IsPlayerVip(playerid)) in your vip commands, it returns 1 if the player is vip or 0 if not.

Don't forget to store the expiry date somewhere, and load / save it.
I understand this but what do you mean in

Store the expiry date somewhere?

Where do i store it?