AlliedModders Donor
Join Date: Mar 2016
Location: Germany
|
01-24-2020
, 13:20
Re: money shop
|
#6
|
PHP Code:
#include <amxmodx> #include <fun> #include <cstrike> #include <hamsandwich> #define CC_COLORS_TYPE CC_COLORS_SHORT #include <cromchat>
#define PLUGIN "Shop" #define VERSION "1.0" #define AUTHOR "NapoleoN#"
#define TASKGRAV 15643 #define TASKSPEED 6451 #define TASKINV 2156 #define TASKGOD 89641
new const szMenuItems[][] = { "Grenades \r(2 grenades)", "Gravity \r(30 sec)", "Speed \r(30 sec)", "TMP \r(CT Only)", "Immortality\r (20 sec)", "Health \r(+150HP)", "Kevlar+Helmet \r(100AP)", "Respawn \r(Dead only)", "Invisibility \r(30 sec)", "Full Health \r(100HP)", "Big Surprise \r(Random) (UNAVAIBLE)" };
new iMenuPrices[] = { 400, 600, 400, 300, 800, 500, 200, 700, 700, 100, 7500 };
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_clcmd("say /shop", "ShowShop"); register_event("CurWeapon", "WeaponChange", "be", "1=1"); }
public WeaponChange(id) // Used to maintain the maxspeed when player switches weapons. { if(task_exists(id + TASKSPEED)) { set_user_maxspeed(id, 400.0); } }
public client_disconnect(id) { if(task_exists(id + TASKGRAV)) remove_task(id + TASKGRAV); if(task_exists(id + TASKSPEED)) remove_task(id + TASKSPEED); if(task_exists(id + TASKINV)) remove_task(id + TASKINV); if(task_exists(id + TASKGOD)) remove_task(id + TASKGOD); }
public ShowShop(id) { if(is_user_alive(id)) { new szTemp[250]; new menu = menu_create("\yhS | DeathRun \rShop Menu", "ShopHandler"); for(new i; i < sizeof(szMenuItems); i++) { formatex(szTemp, charsmax(szTemp), "%s \y%i hS$", szMenuItems[i], iMenuPrices[i]); menu_additem(menu, szTemp); } menu_display(id, menu); } }
public ShopHandler(id, menu, item) { switch(item) { case 0: { give_item(id, "weapon_hegrenade"); give_item(id, "weapon_flashbang"); CromChat(id, "!g[hS Shop] !nYou have bought Grenades Pack") } case 1: { if(!task_exists(id + TASKGRAV)) { new Float:fGravity = 650.0 / 800.0; set_user_gravity(id, Float:fGravity); set_task(30.0, "ResetGravity", id + TASKGRAV); CromChat(id, "!g[hS Shop] !nYou have purchased Gravity for 30 seconds") } else { CromChat(id, "!g[hS Shop] !nYou already have Gravity") } } case 2: { if(!task_exists(id + TASKSPEED)) { set_user_maxspeed(id, 400.0); set_task(30.0, "ResetSpeed", id + TASKSPEED); CromChat(id, "!g[hS Shop] !nYou have purchased speed for 30 seconds") } else { CromChat(id, "!g[hS Shop] !nYou already have speed") } } case 3: { if(cs_get_user_team(id) == CS_TEAM_CT) { give_item(id, "weapon_tmp"); cs_set_user_bpammo(id, CSW_TMP, 90); CromChat(id, "!g[hS Shop] !nYou have purchased TMP") } else { CromChat(id, "!g[hS Shop] !tTerrorists !ncannot buy this item") } } case 4: { if(!task_exists(id + TASKGOD)) { set_user_godmode(id, 1); set_task(20.0, "ResetGodmode", id + TASKGOD); CromChat(id, "!g[hS Shop] !nYou have purchased Immortality for 20 seconds") } else { CromChat(id, "!g[hS Shop] !nYou already have Immortality") } } case 5: { set_user_health(id, (get_user_health(id) + 150)) CromChat(id, "!g[hS Shop] !nYou have purchased Health !t+150 HP") } case 6: { set_user_armor(id, 100); CromChat(id, "!g[hS Shop] !nYou have purchased Armor + Helmet !t+100 AP") } case 7: { if(!is_user_alive(id)) { ExecuteHamB(Ham_CS_RoundRespawn, id); CromChat(id, "!g[hS Shop] !nYou have purchased Respawn") } else { CromChat(id, "!g[hS Shop] !nYou are not dead, you can't buy Respawn if you're alive") } } case 8: { if(!task_exists(id + TASKINV)) { set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 50); set_task(30.0, "ResetInvis", id + TASKINV); CromChat(id, "!g[hS Shop] !nYou have purchased Invisibility for 30 seconds") } else { CromChat(id, "!g[hS Shop] !nYou already have Invisibility") } } case 9: { set_user_health(id, 100); CromChat(id, "!g[hS Shop] !nYou have purchased Full Health !t+100 HP") } case 10: { CromChat(id, "!g[hS Shop] !nThis item is unavaible yet") } } (cs_get_user_money(id) >= iMenuPrices[item] ? cs_set_user_money(id, cs_get_user_money(id) - iMenuPrices[item]) : CromChat(id, "!g[hS Shop]!n You have insufficient funds to buy this.")); menu_destroy(menu) }
public ResetGravity(id) { id -= TASKGRAV; if(is_user_connected(id) && task_exists(id + TASKGRAV)) { set_user_gravity(id); } }
public ResetSpeed(id) { id -= TASKSPEED; if(is_user_connected(id) && task_exists(id + TASKSPEED)) { set_user_maxspeed(id); } }
public ResetGodmode(id) { id -= TASKGOD; if(is_user_connected(id) && task_exists(id + TASKGOD)) { set_user_godmode(id); } }
public ResetInvis(id) { id -= TASKINV; if(is_user_connected(id) && task_exists(id + TASKSPEED)) { set_user_rendering(id); } }
okay i did some changes and here are the bugs
1. when speed is finished, player can't move anymore!
2. when i dont have enough cash, it still gives me the items!
3. at Big Surpirse, hopefully OciXCrom can help because i saw Roll the Dice (rtd) and maybe it can be added here, i dont want to add /rtd to server, for all the players, only when someone buys form shop Big Surprise, to get random such as in rtd plugin! if it work and its not that hard to make, if not then leave it so until i got some new ideas!
thanks amigo!
__________________
a simple act of caring creates an endless ripple.
Last edited by Nutu_; 01-24-2020 at 13:27.
|
|