SA-MP Forums Archive
Is this possible ? After a cmd done, You can't repeat that CMD.. - 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: Is this possible ? After a cmd done, You can't repeat that CMD.. (/showthread.php?tid=567498)



Is this possible ? After a cmd done, You can't repeat that CMD.. - ChuckyBabe - 14.03.2015

The title says, is that possible for example, he typed /buyvip.. After he get his FREE VIP then he cannot repeat it again for entire life of his account.. I mean if he typed it again .. There will be a word that saying ... You already got your FREE VIP.. Here's my code..

Код:
CMD:buyvip(playerid, params[])
{
	{
	ShowPlayerDialogEx(playerid, BUYVIP, DIALOG_STYLE_LIST, "Buy Personal Donator Package", "Bronze Donator - {00FF00}Free\n{FFFFFF}Silver Donator - {00FF00}Free\n{FFFFFF}Gold Donator - {00FF00}Free", "Select", "Cancel");
	}
	return 1;
}
Код:
if(dialogid == BUYVIP)
    {
        if(response)
	    {
   			if(listitem == 0)
      		{
        		PlayerInfo[playerid][pDonator] = 1;
    			SendClientMessage(playerid, COLOR_YELLOW,"Server : You bought a free 31 days Bronze Donator Package!");
                new adminmessss[128];
				format(adminmessss, sizeof(adminmessss), "AdmCmd: %s has just get his/her free Bronze Donator Package!.", GetPlayerNameEx(playerid));
				ABroadCast(COLOR_LIGHTRED,adminmessss,1);
			  }
   			if(listitem == 1)
      		{

			PlayerInfo[playerid][pDonator] = 2;
    		SendClientMessage(playerid, COLOR_YELLOW,"Server : You have bought a free 31 days Silver Donator Package.");
            new vipmesss[128];
			format(vipmesss, sizeof(vipmesss), "AdmCmd: %s has just get his/her free Silver Donator Package!", GetPlayerNameEx(playerid));
			ABroadCast(COLOR_LIGHTRED,vipmesss,1);
			}
			if (listitem == 2)
			{
			
			PlayerInfo[playerid][pDonator] = 3;
			SendClientMessage(playerid, COLOR_YELLOW,"Server : You have bought a free 31 days Gold Donator Package.");
			new goldmess[128];
			format(goldmess, sizeof(goldmess), "AdmCmd: %s has just get his/her free Gold Donator Package!", GetPlayerNameEx(playerid));
			ABroadCast(COLOR_LIGHTRED,goldmess,1);
			}
		}
	}
+1 Reputation for who helps me.!


Re : Is this possible ? After a cmd done, You can't repeat that CMD.. - Golimad - 14.03.2015

Yes it is possible, by adding / saving / loading an additional bool variable.

new bool:Something[MAX_PLAYERS];
When he buys a vip :
Something[playerid] = true;
when he tries to access the cmd : check if(Something[playerid]==true) return sendclientmessage(playerid, -1, "already bought vip");

save and load it, done.


Re: Is this possible ? After a cmd done, You can't repeat that CMD.. - BGTrucker - 14.03.2015

LOL if its about a VIP system,you just check if he already bought VIP lol.Whats so hard?


Re: Is this possible ? After a cmd done, You can't repeat that CMD.. - Patrik356b - 14.03.2015

Код:
CMD:buyvip(playerid, params[])
{
	if(PlayerInfo[playerid][pDonator] >= 1)
	{
		SendClientMessage(playerid, COLOR_YELLOW, "    You are already a VIP-Player!.");
		return 1;
	}

	ShowPlayerDialogEx(playerid, BUYVIP, DIALOG_STYLE_LIST, "Buy Personal Donator Package", "Bronze Donator - {00FF00}Free\n{FFFFFF}Silver Donator - {00FF00}Free\n{FFFFFF}Gold Donator - {00FF00}Free", "Select", "Cancel");
	
	return 1;
}



Re: Is this possible ? After a cmd done, You can't repeat that CMD.. - Abagail - 14.03.2015

@Patrik,

he wants it so they can't type it again ever... Not if they have VIP already...

Basically do something like this, #OP:
pawn Код:
CMD:buyvip(playerid, params[])
{
    if(PlayerInfo[playerid][pDonateGotten] >= 1)
    {
        SendClientMessage(playerid, COLOR_YELLOW, "    You are already a VIP-Player!.");
        return 1;
    }

    ShowPlayerDialogEx(playerid, BUYVIP, DIALOG_STYLE_LIST, "Buy Personal Donator Package", "Bronze Donator - {00FF00}Free\n{FFFFFF}Silver Donator - {00FF00}Free\n{FFFFFF}Gold Donator - {00FF00}Free", "Select", "Cancel");
    return 1;
}
Then...
pawn Код:
if(dialogid == BUYVIP)
    {
        if(response)
        {
            if(listitem == 0)
            {
                PlayerInfo[playerid][pDonator] = 1;
                        PlayerInfo[playerid][pDonateGotten] = 1;
                SendClientMessage(playerid, COLOR_YELLOW,"Server : You bought a free 31 days Bronze Donator Package!");
                new adminmessss[128];
                format(adminmessss, sizeof(adminmessss), "AdmCmd: %s has just get his/her free Bronze Donator Package!.", GetPlayerNameEx(playerid));
                ABroadCast(COLOR_LIGHTRED,adminmessss,1);
              }
            if(listitem == 1)
            {

            PlayerInfo[playerid][pDonator] = 2;
                        PlayerInfo[playerid][pDonateGotten] = 1;
            SendClientMessage(playerid, COLOR_YELLOW,"Server : You have bought a free 31 days Silver Donator Package.");
            new vipmesss[128];
            format(vipmesss, sizeof(vipmesss), "AdmCmd: %s has just get his/her free Silver Donator Package!", GetPlayerNameEx(playerid));
            ABroadCast(COLOR_LIGHTRED,vipmesss,1);
            }
            if (listitem == 2)
            {
           
            PlayerInfo[playerid][pDonator] = 3;
                        PlayerInfo[playerid][pDonateGotten] = 1;
            SendClientMessage(playerid, COLOR_YELLOW,"Server : You have bought a free 31 days Gold Donator Package.");
            new goldmess[128];
            format(goldmess, sizeof(goldmess), "AdmCmd: %s has just get his/her free Gold Donator Package!", GetPlayerNameEx(playerid));
            ABroadCast(COLOR_LIGHTRED,goldmess,1);
            }
        }
    }
Make sure you incorporate the DonateGotten variable into your loading / saving system.


Re: Is this possible ? After a cmd done, You can't repeat that CMD.. - ChuckyBabe - 15.03.2015

Thanks Abagail +1