SA-MP Forums Archive
dialog shop buying even when u decline, - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: dialog shop buying even when u decline, (/showthread.php?tid=125137)



dialog shop buying even when u decline, - ~Dangun! - 02.02.2010

Even when you press decline it's buying the selected thing lol
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  GetPlayerPos(playerid, X,Y,Z);
    GetPlayerFacingAngle(playerid,Angle);
    gINT = GetPlayerInterior(playerid);

    if( dialogid == 1 ) //shop
    {
    switch(listitem)
    {
      case 0:
            {
        if(GetPlayerMoney(playerid) >= 50000)
                {
                    GivePlayerMoney(playerid,-50000);
                    CreateVehicle(520, X+6,Y,Z+1, Angle, random(127), random(127), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid),gINT);
                    TogglePlayerControllable(playerid, true);
                }
                else
                {
                    SendClientMessage(playerid,oranje,"Server: You don't have 50.000!");
                  TogglePlayerControllable(playerid, true);
                }
      }
      case 1:
            {
                if(GetPlayerMoney(playerid) >= 60000)
                {
                    GivePlayerMoney(playerid,-60000);
          CreateVehicle(432, X,Y+4,Z+1, Angle, random(127), random(127), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid),gINT);
                    TogglePlayerControllable(playerid, true);
                }
                else
                {
                    SendClientMessage(playerid,oranje,"Server: You don't have 60.000!");

                  TogglePlayerControllable(playerid, true);
                }
      }
      case 2:
            {
                if(GetPlayerMoney(playerid) >= 75000)
                {
                    GivePlayerMoney(playerid,-75000);
          CreateVehicle(425, X+6,Y,Z+1, Angle, random(127), random(127), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid),gINT);
                    TogglePlayerControllable(playerid, true);
                }
                else
                {
                    SendClientMessage(playerid,oranje,"Server: You don't have 75.000!");

                  TogglePlayerControllable(playerid, true);
                }
      }
      case 3:
            {
                if(GetPlayerMoney(playerid) >= 30000)
                {
            GivePlayerMoney(playerid,-30000);
          CreateVehicle(601, X+6,Y,Z+1, Angle, random(127), random(127), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid),gINT);
                    TogglePlayerControllable(playerid, true);
                }
                else
                {
                    SendClientMessage(playerid,oranje,"Server: You don't have 30.000!");

                  TogglePlayerControllable(playerid, true);
                }
      }
      case 4:
            {
                if(GetPlayerMoney(playerid) >= 10000)
                {
            GivePlayerWeapon(playerid, 35, 10);
          GivePlayerMoney(playerid,-10000);

                  TogglePlayerControllable(playerid, true);
                }
                else
                {
                    SendClientMessage(playerid,oranje,"Server: You don't have 10.000!");

                  TogglePlayerControllable(playerid, true);
                    }
            }
            case 5:
            {
                if(GetPlayerMoney(playerid) >= 7500)
                {
            SetPlayerHealth(playerid, 100);
          GivePlayerMoney(playerid,-7500);

                  TogglePlayerControllable(playerid, true);
                }
                else
                {
                    SendClientMessage(playerid,oranje,"Server: You don't have 7.500!");

                  TogglePlayerControllable(playerid, true);
                    }
            }
            case 6:
            {
                if(GetPlayerMoney(playerid) >= 10000)
                {
            SetPlayerArmour(playerid, 99);
          GivePlayerMoney(playerid,-10000);

                  TogglePlayerControllable(playerid, true);
                }
                else
                {
                    SendClientMessage(playerid,oranje,"Server: You don't have 10.000!");

                  TogglePlayerControllable(playerid, true);
                    return 1;
                }
            }
        }
     }else if( !response ) SendClientMessage(playerid,oranje,"You have closed the V.I.P Shop!");
    return 1;
}



Re: dialog shop buying even when u decline, - Babul - 02.02.2010

you forgot to test for any response:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	GetPlayerPos(playerid, X,Y,Z);
	GetPlayerFacingAngle(playerid,Angle);
	gINT = GetPlayerInterior(playerid);
	if( dialogid == 1 ) //shop
	{
		if(response)
		{
			switch(listitem)
			{
				case 0:
				{
					if(GetPlayerMoney(playerid) >= 50000)
					{
						GivePlayerMoney(playerid,-50000);
						CreateVehicle(520, X+6,Y,Z+1, Angle, random(127), random(127), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid),gINT);
						TogglePlayerControllable(playerid, true);
					}
					else
					{
						SendClientMessage(playerid,oranje,"Server: You don't have 50.000!");
						TogglePlayerControllable(playerid, true);
					}
				}
		 		case 1:
				{
					if(GetPlayerMoney(playerid) >= 60000)
					{
						GivePlayerMoney(playerid,-60000);
						CreateVehicle(432, X,Y+4,Z+1, Angle, random(127), random(127), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid),gINT);
						TogglePlayerControllable(playerid, true);
					}
					else
					{
						SendClientMessage(playerid,oranje,"Server: You don't have 60.000!");
						TogglePlayerControllable(playerid, true);
					}
				}
				case 2:
				{
					if(GetPlayerMoney(playerid) >= 75000)
					{
						GivePlayerMoney(playerid,-75000);
						CreateVehicle(425, X+6,Y,Z+1, Angle, random(127), random(127), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid),gINT);
						TogglePlayerControllable(playerid, true);
					}
					else
					{
						SendClientMessage(playerid,oranje,"Server: You don't have 75.000!");
						TogglePlayerControllable(playerid, true);
					}
				}
				case 3:
				{
					if(GetPlayerMoney(playerid) >= 30000)
					{
						GivePlayerMoney(playerid,-30000);
						CreateVehicle(601, X+6,Y,Z+1, Angle, random(127), random(127), -1); LinkVehicleToInterior(GetPlayerVehicleID(playerid),gINT);
						TogglePlayerControllable(playerid, true);
					}
					else
					{
						SendClientMessage(playerid,oranje,"Server: You don't have 30.000!");
						TogglePlayerControllable(playerid, true);
					}
				}
				case 4:
				{
					if(GetPlayerMoney(playerid) >= 10000)
					{
						GivePlayerWeapon(playerid, 35, 10);
						GivePlayerMoney(playerid,-10000);
						TogglePlayerControllable(playerid, true);
					}
					else
					{
						SendClientMessage(playerid,oranje,"Server: You don't have 10.000!");
						TogglePlayerControllable(playerid, true);
					}
				}
				case 5:
				{
					if(GetPlayerMoney(playerid) >= 7500)
					{
						SetPlayerHealth(playerid, 100);
						GivePlayerMoney(playerid,-7500);
						TogglePlayerControllable(playerid, true);
					}
					else
					{
						SendClientMessage(playerid,oranje,"Server: You don't have 7.500!");
						TogglePlayerControllable(playerid, true);
					}
				}
				case 6:
				{
					if(GetPlayerMoney(playerid) >= 10000)
					{
						SetPlayerArmour(playerid, 99);
						GivePlayerMoney(playerid,-10000);
						TogglePlayerControllable(playerid, true);
					}
					else
					{
						SendClientMessage(playerid,oranje,"Server: You don't have 10.000!");
						TogglePlayerControllable(playerid, true);
					}
				}
			}
		}
		else
		{
			SendClientMessage(playerid,oranje,"You have closed the V.I.P Shop!");
		}
	}
	return 1;
}