Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is a comment
- // uncomment the line below if you want to write a filterscript
- //#define FILTERSCRIPT
- #include <a_samp>
- enum E_AMMUNATION_MDATA
- {
- WEAPON_MODELID,
- WEAPON_NAME[35],
- WEAPON_PRICE,
- WEAPON_AMMO,
- WEAPON_ID
- };
- enum E_AMMUNATION_PDATA
- {
- PWEAPON_MODELID,
- PWEAPON_NAME[35],
- PWEAPON_PRICE,
- PWEAPON_AMMO,
- PWEAPON_ID
- };
- new const AmmuMelee[][E_AMMUNATION_MDATA] =
- {
- //Model ID - Name - Price - Ammo - Weapon ID
- {331, "Brass Knuckles", 200, 1, WEAPON_BRASSKNUCKLE},
- {333, "Golf Club", 100, 1, WEAPON_GOLFCLUB},
- {335, "Knife", 250, 1, WEAPON_KNIFE}
- };
- new const AmmuPistol[][E_AMMUNATION_PDATA] =
- {
- //Model ID - Name - Price - Ammo - Weapon ID
- {46, "9mm Pistol", 500, 1, WEAPON_COLT45},
- {347, "Silenced Pistol", 500, 1, WEAPON_SILENCED},
- {348, "Desert Eagle", 500, 1, WEAPON_DEAGLE}
- };
- enum
- {
- CATEGORY_MELEE,
- CATEGORY_PISTOLS
- }
- new AmmuCategory[MAX_PLAYERS];
- public OnPlayerConnect(playerid)
- {
- AmmuCategory[playerid] = -1;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case 1: //DIALOG_AMMUNATION
- {
- if(!response)
- {
- AmmuCategory[playerid] = -1;
- return 1;
- }
- switch(listitem)
- {
- case 0: ShowAmmuMenu(playerid, CATEGORY_MELEE);
- case 1: ShowAmmuMenu(playerid, CATEGORY_PISTOLS);
- }
- }
- case 2: //DIALOG_AMMUNATION_BUY
- {
- if(!response)
- {
- AmmuCategory[playerid] = -1;
- return ShowDialogToPlayer(playerid, DIALOG_AMMUNATION);
- }
- new wepCat = AmmuCategory[playerid];
- switch(wepCat)
- {
- case CATEGORY_MELEE:
- {
- for(new i = 0; i < sizeof(AmmuMelee); i++)
- {
- if(i == listitem)
- {
- if(GetPlayerCash(playerid) < AmmuMelee[i][WEAPON_PRICE])
- {
- SendErrorMessage(playerid, "You don't have enough money.");
- return ShowAmmuMenu(playerid, wepCat);
- }
- RemovePlayerCash(playerid, AmmuMelee[i][WEAPON_PRICE]);
- TransactionLog(-1, playerid, AmmuMelee[i][WEAPON_PRICE], "Ammunation Gun Purchase", 1);
- GivePlayerWeaponEx(playerid, AmmuMelee[i][WEAPON_ID], AmmuMelee[i][WEAPON_AMMO]);
- SCMEX(playerid, -1, "* "ORANGE"Bought "WHITE"%s "ORANGE"with "WHITE"%d "ORANGE"ammo for "GREEN"%s"ORANGE".",
- ReturnWeaponName(AmmuMelee[listitem][WEAPON_ID]), AmmuMelee[listitem][WEAPON_AMMO], formatInt(AmmuMelee[listitem][WEAPON_PRICE]));
- break;
- }
- }
- }
- case CATEGORY_PISTOLS:
- {
- for(new i = 0; i < sizeof(AmmuPistol); i++)
- {
- if(i == listitem)
- {
- if(GetPlayerCash(playerid) < AmmuPistol[i][PWEAPON_PRICE])
- {
- SendErrorMessage(playerid, "You don't have enough money.");
- return ShowAmmuMenu(playerid, wepCat);
- }
- RemovePlayerCash(playerid, AmmuPistol[i][PWEAPON_PRICE]);
- TransactionLog(-1, playerid, AmmuPistol[i][PWEAPON_PRICE], "Ammunation Gun Purchase", 1);
- GivePlayerWeaponEx(playerid, AmmuPistol[i][WEAPON_ID], AmmuPistol[i][PWEAPON_AMMO]);
- SCMEX(playerid, -1, "* "ORANGE"Bought "WHITE"%s "ORANGE"with "WHITE"%d "ORANGE"ammo for "GREEN"%s"ORANGE".",
- ReturnWeaponName(AmmuPistol[listitem][PWEAPON_ID]), AmmuPistol[listitem][PWEAPON_AMMO], formatInt(AmmuPistol[listitem][PWEAPON_PRICE]));
- break;
- }
- }
- }
- }
- ShowAmmuMenu(playerid, wepCat);
- }
- }
- return 1;
- }
- stock ShowAmmuMenu(playerid, category)
- {
- new subString[200];
- AmmuCategory[playerid] = category;
- switch(category)
- {
- case CATEGORY_MELEE:
- {
- new string[sizeof(AmmuMelee) * sizeof(subString)];
- if(string[0] == EOS)
- {
- for(new i; i < sizeof(AmmuMelee); i++)
- {
- format(subString, sizeof(subString), "%i(0.0, 0.0, -50.0, 1.5)\t%s~n~~g~~h~$%i\n", AmmuMelee[i][WEAPON_MODELID], AmmuMelee[i][WEAPON_NAME], AmmuMelee[i][WEAPON_PRICE]);
- strcat(string, subString);
- }
- }
- ShowPlayerDialog(playerid, /*DIALOG_AMMUNATION_BUY*/ 2, /*DIALOG_STYLE_PREVIEW_MODEL*/ 2, "Ammunation", string, "Purchase", "Cancel");
- }
- case CATEGORY_PISTOLS:
- {
- new string[sizeof(AmmuPistol) * sizeof(subString)];
- if(string[0] == EOS)
- {
- for(new i; i < sizeof(AmmuPistol); i++)
- {
- format(subString, sizeof(subString), "%i(0.0, 0.0, -50.0, 1.5)\t%s~n~~g~~h~$%i\n", AmmuPistol[i][PWEAPON_MODELID], AmmuPistol[i][PWEAPON_NAME], AmmuPistol[i][PWEAPON_PRICE]);
- strcat(string, subString);
- }
- }
- ShowPlayerDialog(playerid, /*DIALOG_AMMUNATION_BUY*/ 2, /*DIALOG_STYLE_PREVIEW_MODEL*/ 2, "Ammunation", string, "Purchase", "Cancel");
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment