Here Is A Weapons Buy Menu I like gives the players option of how much ammo they like to buy not just a price and u buy u get the ammo server script has choosen you can choose your amount
This is my first FilterScript... And It works For me But i have it in my gamemode So u can either adjust it for filterscript or put in your gamemode but dont rush your copy and pasting Atleast take the time make sure you dont give ur self errors by missing something..
Next We will define Out Dialogs Top Of the Script Under Are Includes And Not Above them
Now Lets Get Some Major Stuff In I guess Simple Code :P This Is Our Public Callback For Are Ammunation Dialog Locations
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_WEAPONS && response)
{
switch(listitem)
{
case 0:
{
ShowPlayerDialog(playerid,DIALOG_HANDGUNS,DIALOG_STYLE_LIST,"Hand Guns","9mm Pistol $50\nSilenced 9mm Pistol $150\nDesert Eagle $250","Select","Cancel");
}
case 1:
{
ShowPlayerDialog(playerid,DIALOG_SUBMACHINEGUNS,DIALOG_STYLE_LIST,"Submachine Guns","\nTec-9 $250\nMicro SMG $300\nSMG $400","Select","Cancel");
}
case 2:
{
ShowPlayerDialog(playerid,DIALOG_SHOTGUNS,DIALOG_STYLE_LIST,"Shotguns","\nRegular Shotgun $150\nSawnoff Shotgun $500\nCombat Shotgun $1,250","Select","Cancel");
}
case 3:
{
ShowPlayerDialog(playerid,DIALOG_ASSAULTRIFLES,DIALOG_STYLE_LIST,"Assualt Rifles","\nRegular Rifle $1,000\nSniper Rifle $2,500\nAK47 $2,500\nM4 $3,000","Select","Cancel");
}
case 4:
{
ShowPlayerDialog(playerid,DIALOG_MELEE,DIALOG_STYLE_LIST,"Melee","\nBat $25\nKnife $25\nGolf Club $50\nPool Cue $50\nShovel $50\nNightstick $150\nCane $250\nKatana $250","Select","Cancel");
}
case 5:
{
ShowPlayerDialog(playerid,DIALOG_MISCELLANEOUS,DIALOG_STYLE_LIST,"Miscellaneous","\nHeavy Body Armour $1,000\nModern Body Armour $500\nFlak Vest $250\nAnti-Knife Vest $150\nPepper Spray $100\nCamera $100","Select","Cancel");
}
}
TogglePlayerControllable(playerid,1);
}
if(dialogid == DIALOG_HANDGUNS && response)
{
switch(listitem)
{
case 0:
{
AmmunationAmmoPrice = 08;//0.80 This is here Stores the Ammo Price
AmmunationWeapon = 22; // This Here Stores the Weapon ID
AmmunationWeaponPrice = 50; // This here stores the Weapon Price
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $0.80","Purchase","Cancel"); // Allow the Player to Choose the amount Of Ammo they like to have they will be charge According to ammoprice and x theamount they choosen
}
case 1:
{
AmmunationAmmoPrice = 08;//0.80 This is here Stores the Ammo Price
AmmunationWeapon = 23; // This Here Stores the Weapon ID
AmmunationWeaponPrice = 150; // This here stores the Weapon Price
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $0.80","Purchase","Cancel"); // Allow the Player to Choose the amount Of Ammo they like to have they will be charge According to ammoprice and x theamount they choosen
}
case 2:
{
AmmunationAmmoPrice = 1;//1.50 This is here Stores the Ammo Price
AmmunationWeapon = 24; // This Here Stores the Weapon ID
AmmunationWeaponPrice = 250; // This here stores the Weapon Price
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $1.50","Purchase","Cancel"); // Allow the Player to Choose the amount Of Ammo they like to have they will be charge According to ammoprice and x theamount they choosen
}
}
TogglePlayerControllable(playerid,1);
}
if(dialogid == DIALOG_SUBMACHINEGUNS && response)
{
switch(listitem)
{
case 0:
{
AmmunationAmmoPrice = 1;//1.50
AmmunationWeapon = 32;
AmmunationWeaponPrice = 250;
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $1.50","Purchase","Cancel");
}
case 1:
{
AmmunationAmmoPrice = 1;//1.50
AmmunationWeapon = 28;
AmmunationWeaponPrice = 300;
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $1.50","Purchase","Cancel");
}
case 2:
{
AmmunationAmmoPrice = 1;//1.50
AmmunationWeapon = 29;
AmmunationWeaponPrice = 400;
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $1.50","Purchase","Cancel");
}
}
TogglePlayerControllable(playerid,1);
}
if(dialogid == DIALOG_SHOTGUNS && response)
{
switch(listitem)
{
case 0:
{
AmmunationAmmoPrice = 2;//2.00
AmmunationWeapon = 25;
AmmunationWeaponPrice = 150;
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $2.00","Purchase","Cancel");
}
case 1:
{
AmmunationAmmoPrice = 2;//2.00
AmmunationWeapon = 26;
AmmunationWeaponPrice = 500;
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $2.00","Purchase","Cancel");
}
case 2:
{
AmmunationAmmoPrice = 2;//2.00
AmmunationWeapon = 27;
AmmunationWeaponPrice = 1250;
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $2.00","Purchase","Cancel");
}
}
TogglePlayerControllable(playerid,1);
}
if(dialogid == DIALOG_ASSAULTRIFLES && response)
{
switch(listitem)
{
case 0:
{
AmmunationAmmoPrice = 10;//10.00
AmmunationWeapon = 33;
AmmunationWeaponPrice = 1000;
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $10.00","Purchase","Cancel");
}
case 1:
{
AmmunationAmmoPrice = 50;//50.00
AmmunationWeapon = 34;
AmmunationWeaponPrice = 2500;
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $50.00","Purchase","Cancel");
}
case 2:
{
AmmunationAmmoPrice = 5;//5.50
AmmunationWeapon = 30;
AmmunationWeaponPrice = 2500;
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $5.50","Purchase","Cancel");
}
case 3:
{
AmmunationAmmoPrice = 6;//6.00
AmmunationWeapon = 31;
AmmunationWeaponPrice = 3000;
TogglePlayerControllable(playerid,1);
ShowPlayerDialog(playerid,DIALOG_WEAPONAMMO,DIALOG_STYLE_INPUT,"Ammo Amount","Price Per Bullet $6.00","Purchase","Cancel");
}
}
TogglePlayerControllable(playerid,1);
}
if(dialogid == DIALOG_MELEE && response)
{
switch(listitem)
{
case 0:
{
if(GetPlayerMoney(playerid) < 25) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased A Bat For $25");
GivePlayerWeapon(playerid,5 ,1 );
GivePlayerMoney(playerid, -25);
TogglePlayerControllable(playerid,1);
}
case 1:
{
if(GetPlayerMoney(playerid) < 25) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased A Knife For $25");
GivePlayerWeapon(playerid,4 ,1 );
GivePlayerMoney(playerid, -25);
TogglePlayerControllable(playerid,1);
}
case 2:
{
if(GetPlayerMoney(playerid) < 50) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased A Golf Club For $50");
GivePlayerWeapon(playerid,2 ,1 );
GivePlayerMoney(playerid, -50);
TogglePlayerControllable(playerid,1);
}
case 3:
{
if(GetPlayerMoney(playerid) < 50) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased A Pool Cue For $50");
GivePlayerWeapon(playerid, 7,1 );
GivePlayerMoney(playerid, -50);
TogglePlayerControllable(playerid,1);
}
case 4:
{
if(GetPlayerMoney(playerid) < 50) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased A Shovel For $50");
GivePlayerWeapon(playerid, 6, 1);
GivePlayerMoney(playerid, -50);
TogglePlayerControllable(playerid,1);
}
case 5:
{
if(GetPlayerMoney(playerid) < 150) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased A Nightstick For $150");
GivePlayerWeapon(playerid,3 ,1 );
GivePlayerMoney(playerid, -150);
TogglePlayerControllable(playerid,1);
}
case 6:
{
if(GetPlayerMoney(playerid) < 250) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased A Cane For $250");
GivePlayerWeapon(playerid, 15, 1);
GivePlayerMoney(playerid, -250);
TogglePlayerControllable(playerid,1);
}
case 7:
{
if(GetPlayerMoney(playerid) < 250) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased A Katana For $250");
GivePlayerWeapon(playerid,8 , 1);
GivePlayerMoney(playerid, -250);
TogglePlayerControllable(playerid,1);
}
}
TogglePlayerControllable(playerid,1);
}
if(dialogid == DIALOG_MISCELLANEOUS)
{
if(response)
{
if(listitem == 0)
{
if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased Heavy Body Armour For $1000");
SetPlayerArmour(playerid,100);
GivePlayerMoney(playerid, -1000);
TogglePlayerControllable(playerid,1);
}
if(listitem == 1)
{
if(GetPlayerMoney(playerid) < 500) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased Modern Body Armour For $500");
SetPlayerArmour(playerid,75);
GivePlayerMoney(playerid, -500);
TogglePlayerControllable(playerid,1);
}
if(listitem == 2)
{
if(GetPlayerMoney(playerid) < 250) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased A Flak Vest For $250");
SetPlayerArmour(playerid,50);
GivePlayerMoney(playerid, -250);
TogglePlayerControllable(playerid,1);
}
if(listitem == 3)
{
if(GetPlayerMoney(playerid) < 150) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased Anti-Knife Vest For $150");
SetPlayerArmour(playerid,25);
GivePlayerMoney(playerid, -150);
TogglePlayerControllable(playerid,1);
}
if(listitem == 4)
{
if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased Pepper Spray For $100");
GivePlayerWeapon(playerid, 41, 25);
GivePlayerMoney(playerid, -100);
TogglePlayerControllable(playerid,1);
}
if(listitem == 5)
{
if(GetPlayerMoney(playerid) < 100) return SendClientMessage(playerid,RED,"You dont have that much money"), ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"Ammunation","Hand Guns\nSubmachine Guns\nShotguns\nAssualt Rifles\nMelee\nMiscellaneous","Select","Cancel");
SendClientMessage(playerid,GREEN,"You Purchased A Camera For $100");
GivePlayerWeapon(playerid, 43, 25);
GivePlayerMoney(playerid, -100);
TogglePlayerControllable(playerid,1);
}
}
TogglePlayerControllable(playerid,1);
}
if(dialogid == DIALOG_WEAPONAMMO)
{
if(!response)
{
SendClientMessage(playerid, ORANGE, "Okay You Choosen Not To Purchase "); // This message appears When the player Click on Cancel
TogglePlayerControllable(playerid,1);// Unfreezes the Player Do to I hate Seeing funky walking when in a dialog so this releases the player to freely move
}
else
{
new money; // New Variable To Used For Weap and ammo money
new wstring[128];// New string to Format our Dialog Message
new ammo=strval(inputtext);// A new variable to Store The Players ammo Amount Wishes
if(!IsNumeric(inputtext)) return SendClientMessage(playerid, RED, "Error Numbers Only ");// This here is to check If Player Is Typing Numbers and Not Letters
if(ammo < 1 || ammo > 1000) return SendClientMessage(playerid, ORANGE, "Ammo ammount 1 Thru 1000"); // This Here Limits the Min And Max Ammo Aloud Per Buy
money=ammo*AmmunationAmmoPrice+AmmunationWeaponPrice; // This is to calculate weapon price ammo price and the amount of ammo player wants .. In Other Words It worked ...
if(GetPlayerMoney(playerid) < money) return SendClientMessage(playerid,RED,"You dont have that much money"), TogglePlayerControllable(playerid,1);// This Checks to See if Player Can Afford This Weapon And Ammo Amount if Not Window Closes
GivePlayerWeapon(playerid,AmmunationWeapon,ammo); // This here Gives the Player The Weapon And Ammo they Wanted
GivePlayerMoney(playerid, - money); // This Here gives the player Negative Money the total cost for the weapon and ammo
format(wstring,sizeof(wstring),"You purchased A %d \nWeapon Price $%d \nAmmo Amount %d At $%d Bullet \nTotal $%d",AmmunationWeapon,AmmunationWeaponPrice,ammo,AmmunationAmmoPrice,money); // This Format Everything above weaponid Weaponprice ammoammount ammoprice and Grandtotal Then Sends to the player
ShowPlayerDialog(playerid,DIALOG_AMMUMSG,DIALOG_STYLE_MSGBOX,"Ammunation Receipt",wstring,"Okay","");// This Little Awesome Window Gives you The Green Light That You just Purchased The Weapon and Ammo at ammo price and weapon price
}
}
return 1;
}
Okay So Far thats it for the Buyweapons Menu I hope you enjoy it as I been Wanting something like that for a long time i finally got it as I was calculating retarded but it was really simple i cant believe It took me awhile to figure that out ..... So Anyways Enjoy all...
If I missed Something let me know and If you dont understand any of my jiberish code Pm or respond in this thread
Nice Fs but can be improved with lots of other function , anyways good job keep going.
Err.. that would be amazing.