Junior Member
|
09-08-2019
, 12:56
Re: [Help/Req] Shop Plugin/Sma
|
#4
|
I've made what you requested, and I added two things that could help: Only alive users can use the shop, and they can only use it one time per round.
PHP Code:
#include <amxmodx> #include <cstrike> #include <engine> #include <fun> #include <hamsandwich>
#define MAX_PLAYERS 32+1
enum _:PluginInfo { PluginName, PluginVersion, PluginCreator };
new const GetInfo[PluginInfo][] = { "Shop", "0.1", "SKAtZ" };
enum _:Data { _name[32], _price };
new const ShopItems[][Data] = { {"HE Bomb", 400}, {"Bunnyhop", 4000}, {"Double Jump", 3000}, {"Silent Walk", 2000}, {"Respawn", 5000} };
new bool: BunnyHop[MAX_PLAYERS] = false; new bool: DoubleJump[MAX_PLAYERS] = false; new bool: Respawn[MAX_PLAYERS] = false; new bool: Shop[MAX_PLAYERS] = false; new jumpnum[MAX_PLAYERS] = 0; new bool:dojump[MAX_PLAYERS] = false;
public plugin_init() { //Regist plugin register_plugin (GetInfo[PluginName], GetInfo[PluginVersion], GetInfo[PluginCreator]); //Regist commands register_clcmd ("say /shop", "_shop"); //Regist functions RegisterHam (Ham_Spawn,"player","_spawn",1); // Spawn RegisterHam (Ham_Killed, "player","_death"); // Death }
public _spawn(id) if(is_user_alive(id)) { if(!Respawn[id]) { BunnyHop[id] = false;// Remove BunnyHop DoubleJump[id] = false;// Remove Double Jump Shop[id] = false;// User can use shop again set_user_footsteps(id, 0);// Remove Silent Walk } Respawn[id] = false; }
public _death(victim, killer, shouldgib) { if(Respawn[victim]) set_task(3.0, "_respawn", victim); }
public _respawn(id) { if(is_user_connected(id) && !is_user_alive(id)) { ExecuteHamB(Ham_CS_RoundRespawn, id); client_print(id, print_chat, "You were respawned"); } }
public client_putinserver(id) { jumpnum[id] = 0; dojump[id] = false; }
public client_disconnect(id) { if(task_exists(id)) remove_task(id); jumpnum[id] = 0; dojump[id] = false; }
public _shop(id) { new menu = menu_create("Shop", "_shop_handler"); new money = cs_get_user_money(id); static item[128]; for(new i = 0; i < sizeof ShopItems; i++) { formatex(item, charsmax(item), "\r%i$ %s%s", ShopItems[i][_price], ShopItems[i][_price] > money ? "\d" : "\y", ShopItems[i][_name]); menu_additem(menu, item); } menu_setprop(menu, MPROP_BACKNAME,"Back"); menu_setprop(menu, MPROP_NEXTNAME,"Next"); menu_setprop(menu, MPROP_EXITNAME,"Exit"); menu_setprop(menu, MPROP_EXIT, MEXIT_ALL); menu_display(id, menu, 0); }
public _shop_handler(id, menu, item) { if(item == MENU_EXIT) { menu_destroy(menu); return PLUGIN_HANDLED; } if(Shop[id] || !is_user_alive(id)) { client_print(id, print_chat, "You must be alive or haven't used the shop this round to access it."); menu_destroy(menu); return PLUGIN_HANDLED; } new money = cs_get_user_money(id); if(ShopItems[item][_price] > money) { client_print(id, print_chat, "You don't have enough money to buy %s.",ShopItems[item][_name]); _shop(id); return PLUGIN_HANDLED; } else { client_print(id, print_chat, "You bought %s.",ShopItems[item][_name]); cs_set_user_money(id, money - ShopItems[item][_price]); Shop[id] = true; switch(item) { case 0: give_item(id, "weapon_hegrenade"); case 1: BunnyHop[id] = true; case 2: DoubleJump[id] = true; case 3: set_user_footsteps(id, 1); case 4: Respawn[id] = true; } } return PLUGIN_HANDLED; }
public client_PreThink(id) { if(!is_user_alive(id)) return PLUGIN_CONTINUE; //Credits to twistedeuphoria if(DoubleJump[id]) { new nbut = get_user_button(id); new obut = get_user_oldbutton(id); if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP)) { if(jumpnum[id] < 1) { dojump[id] = true; jumpnum[id]++; return PLUGIN_CONTINUE; } } if((nbut & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND)) { jumpnum[id] = 0; return PLUGIN_CONTINUE; } return PLUGIN_CONTINUE; } //Credits to CheesyPeteza if(BunnyHop[id]) { entity_set_float(id, EV_FL_fuser2, 0.0); if(entity_get_int(id, EV_INT_button) & 2) { new flags = entity_get_int(id, EV_INT_flags); if(flags & FL_WATERJUMP) return PLUGIN_CONTINUE; if(entity_get_int(id, EV_INT_waterlevel) >= 2) return PLUGIN_CONTINUE; if(!(flags & FL_ONGROUND)) return PLUGIN_CONTINUE; new Float:velocity[3]; entity_get_vector(id, EV_VEC_velocity, velocity); velocity[2] += 250.0; entity_set_vector(id, EV_VEC_velocity, velocity); entity_set_int(id, EV_INT_gaitsequence, 6); } } return PLUGIN_CONTINUE; }
public client_PostThink(id) { if(!is_user_alive(id)) return PLUGIN_CONTINUE; //Credits to twistedeuphoria if(DoubleJump[id] && dojump[id] == true) { new Float:velocity[3]; entity_get_vector(id,EV_VEC_velocity,velocity); velocity[2] = random_float(265.0,285.0); entity_set_vector(id,EV_VEC_velocity,velocity); dojump[id] = false; return PLUGIN_CONTINUE; } return PLUGIN_CONTINUE; }
I didn't test it, so any bug or something wrong please report. Hope I could help you!
PS. Sorry if there are english errors, I'm not a good speaker eheh
Last edited by skatz_ws; 09-08-2019 at 13:01.
|
|