Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* -----------------------------------------------------------------------------------------------
- .##......##.########....###....########...#######..##....##.....######..##.....##..#######..########.
- .##..##..##.##.........##.##...##.....##.##.....##.###...##....##....##.##.....##.##.....##.##.....##
- .##..##..##.##........##...##..##.....##.##.....##.####..##....##.......##.....##.##.....##.##.....##
- .##..##..##.######...##.....##.########..##.....##.##.##.##.....######..#########.##.....##.########.
- .##..##..##.##.......#########.##........##.....##.##..####..........##.##.....##.##.....##.##.......
- .##..##..##.##.......##.....##.##........##.....##.##...###....##....##.##.....##.##.....##.##.......
- ..###..###..########.##.....##.##.........#######..##....##.....######..##.....##..#######..##.......
- .########..##....##
- .##.....##..##..##.
- .##.....##...####..
- .########.....##...
- .##.....##....##...
- .##.....##....##...
- .########.....##...
- .##.....##....###.....######..##....##.##........########.##.....##.########.########.
- .##.....##...##.##...##....##.##...##..##....##..##.......##.....##.##.......##.....##
- .##.....##..##...##..##.......##..##...##....##..##.......##.....##.##.......##.....##
- .#########.##.....##.##.......#####....##....##..######...##.....##.######...########.
- .##.....##.#########.##.......##..##...#########.##........##...##..##.......##...##..
- .##.....##.##.....##.##....##.##...##........##..##.........##.##...##.......##....##.
- .##.....##.##.....##..######..##....##.......##..########....###....########.##.....##
- ------------------------------------------------------------------------------------------------ */
- #define FILTERSCRIPT
- #define VERSION_WEP_SHOP "1.0" // Version Script.
- #define WEAPONS_DIALOG 137 // Dialog ID for Weapon Shop (You can change this value if your script already defined this dialog ID).
- #define MAX_WEAPS_SELL 28 // You must correct this value with enumeration on WeaponData. (Ex: I already have 28 weapons, and you must change value to 29 if you add a weapon in enum).
- //-----------------------------------------------------------------------------------------------//
- #include <a_samp>
- #include <colors>
- #include <sscanf>
- #include <zcmd>
- //-----------------------------------------------------------------------------------------------//
- new WeaponData[MAX_WEAPS_SELL][3] =
- {
- {2,250,1}, // Golf Club
- {3,350,1}, // Nite Stick
- {4,450,1}, // Knife
- {5,550,1}, // Baseball Bat
- {6,650,1}, // Shovel
- {7,750,1}, // Pool Cue
- {8,850,1}, // Katana
- {16,15000,10}, // Grenade
- {17,5000,10}, // Tear Gas
- {18,20000,10}, // Molotov
- {22,1500,250}, // 9MM
- {23,2000,250}, // Silenced Pistol
- {24,3500,250}, // Desert Eagle
- {25,3700,200}, // Shotgun
- {26,3750,200}, // Sawn-off Shotgun
- {27,3800,200}, // Combat Shotgun
- {28,2500,750}, // Micro SMG
- {29,3000,750}, // MP5
- {30,4000,1000}, // AK-47
- {31,5000,1000}, // M4A1
- {32,2500,750}, // TEC-9
- {33,6500,200}, // Country Rifle
- {34,7000,200}, // Sniper Rifle
- {41,5500,1000}, // Spray Can
- {42,6500,1000}, // Fire Extinguisher
- {43,2000,72}, // Camera
- {46,500,1}, // Parachute
- {0,200,100} // Health and Armour (I'm using ID 0 because ID 0 is fist (unused).
- }; // Format array: {Weapon ID, Weapon Price, Ammo} Further Information look at GetPlayerWeaponNameFromModel(weaponid);
- new weaponstring[890]; // I know this array is too big.
- //-----------------------------------------------------------------------------------------------//
- public OnFilterScriptInit()
- {
- for(new w = 0; w < MAX_WEAPS_SELL; w++)
- {
- format(weaponstring,sizeof(weaponstring),"%s\n%d. %s - %d Ammo - $%d",weaponstring,w+1,GetWeaponNameFromModel(w),WeaponData[w][2],WeaponData[w][1]);
- }
- //-------------------------------------------------------------------------------------------//
- print("\n--------------------------------------");
- print(" Weapon Shop v"#VERSION_WEP_SHOP" by: hack4ever a.k.a. sheenIDGS");
- print(" STATUS: LOADED.");
- print(" WARNING: DON'T REMOVE ANY CREDITS !!!!.");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" Weapon Shop v"#VERSION_WEP_SHOP" by: hack4ever a.k.a. sheenIDGS");
- print(" STATUS: UNLOADED.");
- print(" WARNING: DON'T REMOVE ANY CREDITS !!!!.");
- print("--------------------------------------\n");
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- new string[128]; new value = strval(inputtext); new weap = GetPVarInt(playerid, "WeapNumber");
- //-------------------------------------------------------------------------------------------//
- if(dialogid == WEAPONS_DIALOG)
- {
- if(response)
- {
- if(value <= 0 || value > MAX_WEAPS_SELL)
- {
- SendClientMessage(playerid, COLOR_RED, "ERROR: Wrong input number weapon!");
- return 1;
- }
- if(WeaponData[value-1][0] == 0)
- {
- if(GetPlayerMoney(playerid) >= WeaponData[value-1][1])
- {
- GivePlayerMoney(playerid, 0-WeaponData[value-1][1]);
- SetPlayerHealth(playerid, 100.0);
- SetPlayerArmour(playerid, 100.0);
- format(string,sizeof(string),"SUCCESS: You have spent $%d for refill \"%s\".", WeaponData[value-1][1], GetWeaponNameFromModel(value-1));
- SendClientMessage(playerid, COLOR_GREEN, string);
- }
- if(GetPlayerMoney(playerid) < WeaponData[value-1][1])
- {
- format(string,sizeof(string),"ERROR: You need $%d to refill \"%s\".", WeaponData[value-1][1], GetWeaponNameFromModel(value-1));
- SendClientMessage(playerid, COLOR_RED, string);
- }
- return 1;
- }
- if(WeaponData[value-1][2] == 1)
- {
- if(GetPlayerMoney(playerid) >= WeaponData[value-1][1])
- {
- GivePlayerMoney(playerid, 0-WeaponData[value-1][1]);
- GivePlayerWeapon(playerid, WeaponData[value-1][0], WeaponData[value-1][2]);
- format(string,sizeof(string),"SUCCESS: You have spent $%d for bought \"%s\".", WeaponData[value-1][1], GetWeaponNameFromModel(value-1));
- SendClientMessage(playerid, COLOR_GREEN, string);
- }
- if(GetPlayerMoney(playerid) < WeaponData[value-1][1])
- {
- format(string,sizeof(string),"ERROR: You need $%d to buy \"%s\"", WeaponData[value-1][1], GetWeaponNameFromModel(value-1));
- SendClientMessage(playerid, COLOR_RED, string);
- }
- return 1;
- }
- format(string,sizeof(string),"You will buy \"%s\" with %d ammo and the prize is $%d per packet.\nPlease input belom how many packets do you want.", GetWeaponNameFromModel(value-1), WeaponData[value-1][2], WeaponData[value-1][1]);
- ShowPlayerDialog(playerid, WEAPONS_DIALOG+1, DIALOG_STYLE_INPUT, "Weapon Shop | created by : hack4ever", string, "Bring it On", "Cancel");
- SetPVarInt(playerid, "WeapNumber", value-1);
- }
- }
- if(dialogid == WEAPONS_DIALOG+1)
- {
- if(response)
- {
- if(value < 0 || value == 0)
- {
- SendClientMessage(playerid, COLOR_RED, "ERROR: Wrong amount.");
- return 1;
- }
- if(value > 100)
- {
- SendClientMessage(playerid, COLOR_RED, "ERROR: You can't buy more than 100 packets for 1 transaction!");
- return 1;
- }
- if(WeaponData[weap][1]*value > GetPlayerMoney(playerid))
- {
- format(string,sizeof(string),"ERROR: You need $%d to buy \"%s\" for %d packets.", WeaponData[weap][1]*value, GetWeaponNameFromModel(weap), value);
- SendClientMessage(playerid, COLOR_RED, string);
- return 1;
- }
- GivePlayerWeapon(playerid, WeaponData[weap][0], WeaponData[weap][2]*value);
- GivePlayerMoney(playerid, 0-WeaponData[weap][1]*value);
- format(string,sizeof(string),"SUCCESS: You have spent $%d for bought \"%s\" with %d packets. (Ammo : %d)", WeaponData[weap][1]*value, GetWeaponNameFromModel(weap), value, WeaponData[weap][2]*value);
- SendClientMessage(playerid, COLOR_GREEN, string);
- }
- }
- return 1;
- }
- stock GetWeaponNameFromModel(weaponid)
- {
- new weapon[32];
- GetWeaponName(WeaponData[weaponid][0],weapon,32);
- if(WeaponData[weaponid][0] == 18) { weapon = "Molotov Cocktail"; }
- if(WeaponData[weaponid][0] == 0) { weapon = "Health and Armour"; }
- return weapon;
- }
- // I'm using stock IsAtWeaponShop for check is player in ammu-nation
- stock IsAtWeaponShop(playerid)
- {
- if(IsPlayerConnected(playerid))
- {
- if(IsPlayerInRangeOfPoint(playerid, 50.0, 296.0515,-105.3873,1001.5156) || IsPlayerInRangeOfPoint(playerid, 50.0, 291.1880,-84.7032,1001.5156) || IsPlayerInRangeOfPoint(playerid, 50.0, 291.5020,-39.4228,1001.5156))
- {
- return 1;
- }
- else if(IsPlayerInRangeOfPoint(playerid, 50.0, 317.4479,-162.2596,999.5938) || IsPlayerInRangeOfPoint(playerid, 50.0, 314.5552,-137.3875,999.6016))
- {
- return 1;
- }
- }
- return 0;
- }
- //-----------------------------------------------------------------------------------------------//
- CMD:weaponlist(playerid, params[])
- {
- #pragma unused params
- ShowPlayerDialog(playerid, WEAPONS_DIALOG+2, DIALOG_STYLE_MSGBOX, "Weapon Shop List", weaponstring, "O", "K");
- return 1;
- }
- CMD:buygun(playerid, params[])
- {
- #pragma unused params
- if(!IsAtWeaponShop(playerid)) SendClientMessage(playerid, COLOR_RED, "You must at weapon shop!");
- else
- {
- ShowPlayerDialog(playerid, WEAPONS_DIALOG, DIALOG_STYLE_INPUT, "Weapon Shop", weaponstring, "Buy", "Cancel");
- }
- return 1;
- }
- CMD:buyweap(playerid, params[])
- {
- new weap,pack,weapon,string[100];
- if(!IsAtWeaponShop(playerid)) return SendClientMessage(playerid, COLOR_RED, "You must at weapon shop!");
- if(sscanf(params,"dd",weapon,pack))
- {
- SendClientMessage(playerid, COLOR_WHITE, "USAGE: /buyweap [weapon_number] [ammount_packet]");
- SendClientMessage(playerid, COLOR_WHITE, "Look weapon number at /weaponlist (except for melee and for refill, packet is only 1 per transaction).");
- return 1;
- }
- weap = weapon-1;
- if(weapon < 1 || weapon > MAX_WEAPS_SELL) return SendClientMessage(playerid, COLOR_RED, "ERROR: Wrong input weapon number! Look at /weaponlist");
- if(pack > 100 || pack < 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: You must input ammount of packet (More than 0 packet and less than 100 packets)!");
- if(WeaponData[weap][0] == 0)
- {
- pack = 1;
- if(GetPlayerMoney(playerid) < WeaponData[weap][1])
- {
- format(string,sizeof(string),"ERROR: You need $%d to refill \"%s\".", WeaponData[weap][1], GetWeaponNameFromModel(weap));
- SendClientMessage(playerid, COLOR_RED, string);
- }
- else if(GetPlayerMoney(playerid) >= WeaponData[weap][1])
- {
- GivePlayerMoney(playerid, 0-WeaponData[weap][1]);
- SetPlayerHealth(playerid, 100.0);
- SetPlayerArmour(playerid, 100.0);
- format(string,sizeof(string),"SUCCESS: You have spent $%d for refill \"%s\".", WeaponData[weap][1], GetWeaponNameFromModel(weap));
- SendClientMessage(playerid, COLOR_GREEN, string);
- }
- return 1;
- }
- if(WeaponData[weap][0] != 0)
- {
- if(GetPlayerMoney(playerid) < WeaponData[weap][1]*pack)
- {
- if(WeaponData[weap][2] == 1)
- {
- pack = 1;
- format(string,sizeof(string),"ERROR: You need $%d to buy \"%s\"", WeaponData[weap][1], GetWeaponNameFromModel(weap));
- SendClientMessage(playerid, COLOR_RED, string);
- }
- else
- {
- if(pack == 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: You didn't input your packet!");
- format(string,sizeof(string),"ERROR: You need $%d to buy \"%s\" for %d packets.", WeaponData[weap][1]*pack, GetWeaponNameFromModel(weap),pack);
- SendClientMessage(playerid, COLOR_RED, string);
- }
- return 1;
- }
- else if(GetPlayerMoney(playerid) >= WeaponData[weap][1]*pack)
- {
- if(WeaponData[weap][2] == 1)
- {
- pack = 1;
- GivePlayerWeapon(playerid, WeaponData[weap][0], WeaponData[weap][2]);
- GivePlayerMoney(playerid, 0-WeaponData[weap][1]);
- format(string,sizeof(string),"SUCCESS: You have spent $%d for bought \"%s\".", WeaponData[weap][1], GetWeaponNameFromModel(weap));
- SendClientMessage(playerid, COLOR_GREEN, string);
- }
- else
- {
- if(pack == 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: You didn't input your packet!");
- GivePlayerWeapon(playerid, WeaponData[weap][0], WeaponData[weap][2]*pack);
- GivePlayerMoney(playerid, 0-WeaponData[weap][1]*pack);
- format(string,sizeof(string),"SUCCESS: You have spent $%d for bought \"%s\" with %d packets. (Ammo : %d)", WeaponData[weap][1]*pack, GetWeaponNameFromModel(weap), pack, WeaponData[weap][2]*pack);
- SendClientMessage(playerid, COLOR_GREEN, string);
- }
- return 1;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement