VIP Token problem
#1

I have a vip shop in my script, which has token points.
Код:
if(dialogid == DIALOG_VIP_SHOP)
	{
		if(response)
		{
			
		new INI: File = INI_Open(UserPath(playerid));
        INI_SetTag(File,"data");
		INI_WriteInt(File, "VIP Tokens", Player[playerid][pTokens]);
        INI_Close(File);
			
			if(listitem == 0)
			{
				if( Player[playerid][pTokens] < 100 )
				{
					SCM(pid, ADMIN_COLOR, " You don't have enough tokens!");
					return 1;
				}
				
				else
				
				{
					SetPVarInt(playerid, Player[playerid][pVip], 1 );
					Player[playerid][pVip] = 1;
					SCM(pid, -1, " {FFFFFF}You have bought the {AE05FC}VIP Level 1{FFFFFF} privilege!");
					return 1;
				}
			}
			if(listitem == 1)
			{
				if( Player[playerid][pTokens] < 200 )
				{
					SCM(pid, ADMIN_COLOR, " You don't have enough tokens!");
					return 1;
				}	
				
				else
				
				{
					SetPVarInt(playerid, Player[playerid][pVip], 2 );
					Player[playerid][pVip] = 2;
					SCM(pid, -1, " {FFFFFF}You have bought the {FF00FF}VIP Level 2{FFFFFF} privilege!");
					return 1;
				}
			}
			if(listitem == 2)
			{
				if( Player[playerid][pTokens] < 300 )
				{
					SCM(pid, ADMIN_COLOR, " You don't have enough tokens!");
					return 1;
				}
				
				else
				
				{
					SetPVarInt(playerid, Player[playerid][pVip], 3 );
					Player[playerid][pVip] = 3;
					SCM(pid, -1, " {FFFFFF}You have bought the {FF1FAD}VIP Level 3{FFFFFF} privilege!");
					return 1;
				}
			}		
			if(listitem == 3)
			{
				if( Player[playerid][pTokens] < 30 )
				{
					SCM(pid, ADMIN_COLOR, " You don't have enough tokens!");
					return 1;			
				}
				
				else
				{
				
					GivePlayerMoney(playerid, 500000);
					SCM(pid, -1, " {FFFFFF}You have bought {09FF00}$500.000{FFFFFF} with tokens!");
					return 1;
				}
			}
			return 1;
		}
	}
From this script, when I try to buy an item from listitem 1 or 2, I get the not enough tokens message and in my user file the tokens are written as 100. However, listitem 0 and listitem 3 do not require tokens to buy. Also, I have these 2 lines in the code
Код:
SetPVarInt(playerid, Player[playerid][pTokens], token);
					token = Player[playerid][pTokens] - 100;
but the token number is not written in the user file, it still remains 100.
Reply
#2

1- You're updating the file BEFORE doing anything.
2- You're not actually removing tokens from the player's variable.
You should do this:
Код:
Player[playerid][pTokens] -= AMOUNT;
3- What the hell is this?
Код:
SetPVarInt(playerid, Player[playerid][pVip], 3 );
Reply
#3

That pvar is the VIP level being set.
Reply
#4

What would I define the AMOUNT as?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)