PDA

View Full Version : Help Please Confused On Counting..


Buzzbomb
23/11/2012, 04:48 AM
I Made a dialog for Ammunation for buy weapons well its a list of weapons not explain all of them but one should help if i select 9mm Pistol It throw up another Dialog For Input Asking me how much ammo I want Im gonna charge $0.50 A Bullet So IF I type in 200 bullets And I click Submit It would count them bullets and add it all together and Call on Another Dialog to give me the Grand Total cost for the Gun and The ammo together So I Select Purchase I want to pay for that amount and it

GivePlayerWeapon(playerid,wepid,inputtext);
GivePlayerMoney(playerid, -amount);

Gun Cost $50
Ammo $0.50

How Would I go About Scripting That .. Please Help me...

Virus.
23/11/2012, 07:34 AM
after u show the ammo dialog, accept the ammo in a variable. Then add a new float variable and it contains the money. For eg-

new ammo=strval(inputtext);//under the dialog response of the ammo dialog
new Float:money;
money=ammo*0.5;
new str[80];
format(str,sizeof(str),"Total money : %f ",money);
ShowPlayerDialog(str);



Done!!

Buzzbomb
23/11/2012, 10:52 AM
its Close But No There more to It Someone Help Please...

Buzzbomb
23/11/2012, 08:28 PM
Stop reading my Thread If you dont have an answer...

Buzzbomb
03/12/2012, 09:13 PM
Okay I got this So far it works but producing $210.000000 How do I make it show just $210

So I can Then Store the Price and The Ammo in a Varible So i can
GivePlayerWeapon(playerid,Wepid,bammo); and GivePlayerMoney(playerid, -tcost);



if(dialogid == DIALOG_9MMAMMO)
{
if(!response)
{
SendClientMessage(playerid, ORANGE, "Okay You Choosen Not To Purchase ");
TogglePlayerControllable(playerid,1);
}
else
{
new total[128],Float:money,str[80];
new ammo=strval(inputtext);
if(!strval(inputtext)) return SendClientMessage(playerid, RED, "Error Numbers Only ");
if(ammo < 1 || ammo > 10000) return SendClientMessage(playerid, ORANGE, "Ammo ammount 1 Thru 10000");
money=ammo*0.80+50;
format(str,sizeof(str),"%f ",money);
format(total,sizeof(total), "9mm $50 \n Ammo $0.80 \nGrand Total $%s", str);
ShowPlayerDialog(playerid, DIALOG_CONFIRM, DIALOG_STYLE_PASSWORD, "Confirm Purchase",total, "Purchase", "Cancel");
}
}
if(dialogid == DIALOG_CONFIRM)
{
if(!response)
{
SendClientMessage(playerid, ORANGE, "Okay You Choosen Not To Purchase ");
TogglePlayerControllable(playerid,1);
}
else
{

GivePlayerWeapon(playerid,Wepid,bammo);
GivePlayerMoney(playerid, -tcost);
}
}