[HELP] /buy Store Command - 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: [HELP] /buy Store Command (
/showthread.php?tid=317295)
[HELP] /buy Store Command -
ryan39 - 10.02.2012
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(playerid, cmdtext[])
{
if (strcmp("/buy", cmdtext, true, 10) == 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!
Re: [HELP] /buy Store Command -
Tanush123 - 10.02.2012
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
Re: [HELP] /buy Store Command -
ryan39 - 10.02.2012
Thank You! +rep