[HELP] /buy Store Command
#1

Hello.

I know I am new and actually I just began learning what pawno was the other day. The only past scripting I have had is Call of Duty World at War scripting but that is a bit different. I have learned a lot already and I am trying to make my /buy command for my Gamemode.

Here is what I have so far...

PHP код:

#include <a_samp>
#define SHOP_MENU 0
new getinterior;
public 
OnPlayerCommandText(playeridcmdtext[])   
{
    if (
strcmp("/buy"cmdtexttrue10) == 0)
    {
    
getinterior GetPlayerInterior(playerid);     
    if(
IsPlayerInRangeOfPoint(playerid,5.0, -30.8246,-28.4104,1003.5573)) && getinterior == [24/7 interior id])
    {
    
ShowPlayerDialog(playerid,SHOP_MENU,DIALOG_STYLE_LIST,"General Store","Potato Chips $10\n Cookies $8\n Water $3\n Cola $6","Purchase","Cancel");
            return 
1;
        }
        else
        {
      
SendClientMessage(playerid,0xFF0000AA,"You aren't in a General Store store!");
         }
        return 
1;
    }
    return 
0;

What I want is, I want each one of those to offer health points when I select it.

For example: Potato Chips will increase my health by 20 health points.
Water will increase my health by 5 health points.
Cola will increase my health by 10.
Cookies will increase my health by 15.


If someone could do that I will rep them! Also I want to learn what you did so I don't have to ask next time!
So if you could write a small explanation that would be great.

Thanks!
Reply
#2

Use OnDialogResponse

https://sampwiki.blast.hk/wiki/OnDialogResponse
pawn Код:
if(dialogid == SHOP_MENU)
{
     if(response)
     {
              new phealth;
              GetPlayerHealth(phealth);
              case 0:
              {
                       if(phealth > 79)//You need this because if someone has over 80 health like 92, after they eat they will have 112
                       {
                       SetPlayerHealth(playerid,100);
                       SendClientMessage(playerid,0xFF9900AA,"You have bought potato chips");
                       }
                       if(phealth < 81)
                       {
                       SetPlayerHealth(playerid,phealth+20);
                       SendClientMessage(playerid,0xFF9900AA,"You have bought potato chips");
                       }
              }
              //do the rest
Reply
#3

Thank You! +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)