Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* i will update everyday the code ofc i dont have server to test it but i will build every thing without any error so make sure if you test it leave me message, Discord: CheezPuff#7720 or Steam: CheezPuff (Ariel)*/
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <fun>
- #include <hamsandwich>
- #include <fakemeta>
- #include <nvault>
- #define MAX_PLAYERS 32
- #define PREVIEW_TIME 5.0 // זמן הצפייה בסכין בשניות
- enum _:eKnife {
- KNIFE_MODEL[64],
- KNIFE_NAME[32],
- KNIFE_PRICE,
- KNIFE_LEVEL_REQ,
- Float:KNIFE_CASH_BONUS,
- Float:KNIFE_SLAG_AMOUNT,
- KNIFE_HEALTH_BONUS,
- KNIFE_ARMOR_BONUS,
- KNIFE_DAMAGE_BONUS
- }
- new const g_Knives[][eKnife] = {
- // מודל הסכין, שם הסכין, מחיר, דרישת רמה, בונוס מזומנים, כמות סלאג, בונוס בריאות, בונוס שריון, בונוס נזק
- // Model location, name Knife, price, req level, bonus cash, bonus slag, bonus health, bonus armor, bonus damage
- {"models/v_knife.mdl", "Normal Boxer", 0, 0, 0.0, 0.0, 0, 0, 0},
- {"models/knives/v_knife1.mdl", "Special Knife 1", 25000, 5, 0.1, 0.05, 5, 5, 5},
- {"models/knives/v_knife2.mdl", "Special Knife 2", 50000, 10, 0.2, 0.10, 10, 10, 10},
- {"models/knives/v_knife3.mdl", "Special Knife 3", 100000, 15, 0.3, 0.15, 15, 15, 15},
- {"models/knives/v_knife4.mdl", "Epic Knife", 200000, 20, 0.4, 0.20, 20, 20, 20},
- {"models/knives/v_knife5.mdl", "Legendary Knife", 500000, 30, 0.5, 0.25, 30, 30, 30}
- };
- new g_iPlayerCash[MAX_PLAYERS + 1];
- new g_iPlayerLevel[MAX_PLAYERS + 1];
- new g_iPlayerXP[MAX_PLAYERS + 1];
- new g_iPlayerEquippedKnife[MAX_PLAYERS + 1];
- new g_szPlayerOwnedKnives[MAX_PLAYERS + 1][256];
- new g_iPlayerPreviewingKnife[MAX_PLAYERS + 1];
- new g_iPlayerDamageBonus[MAX_PLAYERS + 1];
- new g_vault;
- public plugin_precache() {
- for (new i = 0; i < sizeof g_Knives; i++) {
- precache_model(g_Knives[i][KNIFE_MODEL]);
- }
- }
- public plugin_init() {
- register_plugin("Jailbreak Knives Shop 29/07/2024", "1.0", "CheezPuff - Ariel");
- register_clcmd("say /knife", "CmdKnifeShop");
- register_clcmd("say_team /knife", "CmdKnifeShop");
- register_event("DeathMsg", "event_player_kill", "a");
- register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
- RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage");
- register_forward(FM_PlayerPostThink, "fw_PlayerPostThink");
- g_vault = nvault_open("knife_shop_vault");
- }
- public plugin_end() {
- nvault_close(g_vault);
- }
- public plugin_natives() {
- register_native("get_player_knife_cash", "native_get_player_knife_cash");
- register_native("set_player_knife_cash", "native_set_player_knife_cash");
- register_native("get_player_knife_level", "native_get_player_knife_level");
- register_native("set_player_knife_level", "native_set_player_knife_level");
- }
- public fw_PlayerPostThink(id) {
- if (!is_user_alive(id)) return FMRES_IGNORED;
- new knife = get_user_weapon(id) == CSW_KNIFE ? 1 : 0;
- if (knife) {
- new knife_id = g_iPlayerPreviewingKnife[id] != -1 ? g_iPlayerPreviewingKnife[id] : g_iPlayerEquippedKnife[id];
- set_pev(id, pev_viewmodel2, g_Knives[knife_id][KNIFE_MODEL]);
- }
- return FMRES_IGNORED;
- }
- public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) {
- if (!is_user_connected(attacker) || get_user_weapon(attacker) != CSW_KNIFE) {
- return HAM_IGNORED;
- }
- new knife_id = g_iPlayerEquippedKnife[attacker];
- new Float:new_damage = damage + float(g_Knives[knife_id][KNIFE_DAMAGE_BONUS]);
- SetHamParamFloat(4, new_damage);
- return HAM_HANDLED;
- }
- public event_round_start() {
- for (new id = 1; id <= MAX_PLAYERS; id++) {
- if (is_user_connected(id) && is_user_alive(id)) {
- apply_knife_abilities(id);
- }
- }
- }
- public apply_knife_abilities(id) {
- new knife_id = g_iPlayerEquippedKnife[id];
- // health bonus
- new health = get_user_health(id);
- set_user_health(id, health + g_Knives[knife_id][KNIFE_HEALTH_BONUS]);
- // armor bonus
- new armor = get_user_armor(id);
- set_user_armor(id, armor + g_Knives[knife_id][KNIFE_ARMOR_BONUS]);
- // damage bonus for later use
- g_iPlayerDamageBonus[id] = g_Knives[knife_id][KNIFE_DAMAGE_BONUS];
- // slag amount
- set_user_gravity(id, 1.0 - g_Knives[knife_id][KNIFE_SLAG_AMOUNT]);
- }
- public CmdKnifeShop(id) {
- show_main_menu(id);
- return PLUGIN_HANDLED;
- }
- public show_main_menu(id) {
- new menu_title[128];
- formatex(menu_title, charsmax(menu_title), "\r[JailBreak] \wKnives Shop^n\wCash: $%d | Top Knife: %s | Current: %s",
- g_iPlayerCash[id],
- g_Knives[get_player_top_knife(id)][KNIFE_NAME],
- g_Knives[g_iPlayerEquippedKnife[id]][KNIFE_NAME]);
- new menu = menu_create(menu_title, "main_menu_handler");
- menu_additem(menu, "View Knives");
- menu_additem(menu, "My Inventory");
- menu_additem(menu, "Shop Information");
- menu_additem(menu, "צפה בסכין"); // Hebrew option for "View Knife"
- menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
- menu_display(id, menu, 0);
- }
- public main_menu_handler(id, menu, item) {
- if (item == MENU_EXIT) {
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- switch (item) {
- case 0: show_knives_list(id, 0);
- case 1: show_inventory(id);
- case 2: show_shop_info(id);
- case 3: show_preview_menu(id);
- }
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- public show_preview_menu(id) {
- new menu = menu_create("[JailBreak] \wviewing Knive", "preview_menu_handler");
- for (new i = 0; i < sizeof g_Knives; i++) {
- new item_text[64], item_info[8];
- formatex(item_text, charsmax(item_text), "%s", g_Knives[i][KNIFE_NAME]);
- formatex(item_info, charsmax(item_info), "%d", i);
- menu_additem(menu, item_text, item_info);
- }
- menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
- menu_display(id, menu, 0);
- }
- public preview_menu_handler(id, menu, item) {
- if (item == MENU_EXIT) {
- menu_destroy(menu);
- show_main_menu(id);
- return PLUGIN_HANDLED;
- }
- new item_info[8], item_name[64], access, callback;
- menu_item_getinfo(menu, item, access, item_info, charsmax(item_info), item_name, charsmax(item_name), callback);
- new knife_id = str_to_num(item_info);
- preview_knife(id, knife_id);
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- public preview_knife(id, knife_id) {
- g_iPlayerPreviewingKnife[id] = knife_id;
- client_print(id, print_chat, "Previewing %s for %.0f seconds", g_Knives[knife_id][KNIFE_NAME], PREVIEW_TIME);
- set_task(PREVIEW_TIME, "end_preview", id);
- }
- public end_preview(id) {
- g_iPlayerPreviewingKnife[id] = -1;
- client_print(id, print_chat, "Preview ended. Returned to your equipped knife.");
- }
- public show_knives_list(id, page) {
- new total_pages = (sizeof g_Knives - 1) / 7 + 1;
- new menu_title[64];
- formatex(menu_title, charsmax(menu_title), "Knives List - Page %d/%d", page + 1, total_pages);
- new menu = menu_create(menu_title, "knives_list_handler");
- new start = page * 7;
- new end = min(start + 7, sizeof g_Knives);
- for (new i = start; i < end; i++) {
- new item_text[64], item_info[8];
- formatex(item_text, charsmax(item_text), "%s | $%d | Lvl %d %s",
- g_Knives[i][KNIFE_NAME], g_Knives[i][KNIFE_PRICE], g_Knives[i][KNIFE_LEVEL_REQ],
- is_knife_owned(id, i) ? "| Owned" : "");
- formatex(item_info, charsmax(item_info), "%d", i);
- menu_additem(menu, item_text, item_info);
- }
- if (page > 0) menu_additem(menu, "Previous Page", "prev");
- if (end < sizeof g_Knives) menu_additem(menu, "Next Page", "next");
- menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
- menu_display(id, menu, 0);
- }
- public knives_list_handler(id, menu, item) {
- if (item == MENU_EXIT) {
- menu_destroy(menu);
- show_main_menu(id);
- return PLUGIN_HANDLED;
- }
- new item_info[8], item_name[64], access, callback;
- menu_item_getinfo(menu, item, access, item_info, charsmax(item_info), item_name, charsmax(item_name), callback);
- if (equal(item_info, "prev")) {
- new page = (item - 1) / 7;
- show_knives_list(id, page - 1);
- } else if (equal(item_info, "next")) {
- new page = (item - 1) / 7;
- show_knives_list(id, page + 1);
- } else {
- new knife_id = str_to_num(item_info);
- show_knife_details(id, knife_id);
- }
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- public show_knife_details(id, knife_id) {
- new menu_title[64];
- formatex(menu_title, charsmax(menu_title), "%s Details", g_Knives[knife_id][KNIFE_NAME]);
- new menu = menu_create(menu_title, "knife_details_handler");
- new item_text[256];
- formatex(item_text, charsmax(item_text), "\wLevel Requirement: \y%d %s^n\
- \wCost: \y$%d^n\
- \wCash Bonus: \y%.1f%%",
- g_Knives[knife_id][KNIFE_LEVEL_REQ], (g_iPlayerLevel[id] >= g_Knives[knife_id][KNIFE_LEVEL_REQ]) ? "(Reached)" : "",
- g_Knives[knife_id][KNIFE_PRICE],
- g_Knives[knife_id][KNIFE_CASH_BONUS] * 100.0);
- menu_addtext(menu, item_text, 0);
- if (is_knife_owned(id, knife_id)) {
- menu_additem(menu, "Use");
- } else if (g_iPlayerLevel[id] >= g_Knives[knife_id][KNIFE_LEVEL_REQ]) {
- menu_additem(menu, "Purchase Knife");
- }
- menu_additem(menu, "View Knife Stats");
- menu_additem(menu, "Back to Knives Menu");
- menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
- menu_display(id, menu, 0);
- }
- public knife_details_handler(id, menu, item) {
- if (item == MENU_EXIT) {
- menu_destroy(menu);
- show_knives_list(id, 0);
- return PLUGIN_HANDLED;
- }
- new item_info[8], item_name[64], access, callback;
- menu_item_getinfo(menu, item, access, item_info, charsmax(item_info), item_name, charsmax(item_name), callback);
- new knife_id = str_to_num(item_info);
- switch (item) {
- case 0: {
- // Use or Purchase logic
- if (is_knife_owned(id, knife_id)) {
- g_iPlayerEquippedKnife[id] = knife_id;
- apply_knife_abilities(id);
- client_print(id, print_chat, "You have equipped %s!", g_Knives[knife_id][KNIFE_NAME]);
- } else if (g_iPlayerCash[id] >= g_Knives[knife_id][KNIFE_PRICE]) {
- g_iPlayerCash[id] -= g_Knives[knife_id][KNIFE_PRICE];
- add_owned_knife(id, knife_id);
- client_print(id, print_chat, "You have purchased %s!", g_Knives[knife_id][KNIFE_NAME]);
- save_player_data(id);
- } else {
- client_print(id, print_chat, "You don't have enough cash to purchase this knife.");
- }
- }
- case 1: {
- // View Knife Stats
- show_knife_stats(id, knife_id);
- }
- case 2: {
- show_knives_list(id, 0);
- }
- }
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- public show_knife_stats(id, knife_id) {
- new stats_text[512];
- formatex(stats_text, charsmax(stats_text),
- "\r[Frag JailBreak] Knives Shop^n^n\
- \yYou Are Using: \w%s^n\
- \yYour Top Knife: \w%s^n^n\
- \r%s \wStats:^n^n\
- \y1. \wSlag Amount: \r+%.2f%%^n\
- \y2. \wHealth Bonus: \rUp To %d^n\
- \y3. \wArmor Bonus: \r+%d^n\
- \y4. \wDamage Bonus: \r+%d^n\
- \y5. \wCash Bonus: \r+%.1f%%^n\
- \y6. \wThis Knife Costs: \r(%d Cash)^n^n\
- \r0. \wBack",
- g_Knives[g_iPlayerEquippedKnife[id]][KNIFE_NAME],
- g_Knives[get_player_top_knife(id)][KNIFE_NAME],
- g_Knives[knife_id][KNIFE_NAME],
- g_Knives[knife_id][KNIFE_SLAG_AMOUNT] * 100.0,
- g_Knives[knife_id][KNIFE_HEALTH_BONUS],
- g_Knives[knife_id][KNIFE_ARMOR_BONUS],
- g_Knives[knife_id][KNIFE_DAMAGE_BONUS],
- g_Knives[knife_id][KNIFE_CASH_BONUS] * 100.0,
- g_Knives[knife_id][KNIFE_PRICE]
- );
- show_menu(id, MENU_KEY_0, stats_text, -1, "Knife Stats Menu");
- }
- public knife_stats_menu_handler(id, key) {
- if (key == 9) { // Back key
- show_knife_details(id, g_iPlayerEquippedKnife[id]);
- }
- return PLUGIN_HANDLED;
- }
- public show_inventory(id) {
- new menu = menu_create("My Inventory", "inventory_menu_handler");
- for (new i = 0; i < sizeof g_Knives; i++) {
- if (is_knife_owned(id, i)) {
- new item_text[64], item_info[8];
- formatex(item_text, charsmax(item_text), "%s %s",
- g_Knives[i][KNIFE_NAME],
- (i == g_iPlayerEquippedKnife[id]) ? "(Equipped)" : "");
- formatex(item_info, charsmax(item_info), "%d", i);
- menu_additem(menu, item_text, item_info);
- }
- }
- menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
- menu_display(id, menu, 0);
- }
- public inventory_menu_handler(id, menu, item) {
- if (item == MENU_EXIT) {
- menu_destroy(menu);
- show_main_menu(id);
- return PLUGIN_HANDLED;
- }
- new item_info[8], item_name[64], access, callback;
- menu_item_getinfo(menu, item, access, item_info, charsmax(item_info), item_name, charsmax(item_name), callback);
- new knife_id = str_to_num(item_info);
- g_iPlayerEquippedKnife[id] = knife_id;
- apply_knife_abilities(id);
- client_print(id, print_chat, "You have equipped %s!", g_Knives[knife_id][KNIFE_NAME]);
- menu_destroy(menu);
- show_inventory(id);
- return PLUGIN_HANDLED;
- }
- public show_shop_info(id) {
- new info_text[512];
- formatex(info_text, charsmax(info_text),
- "\r[Frag JailBreak] Knives Shop Information^n\
- ^n\
- Welcome to the Knives Shop!^n\
- ^n\
- Here you can purchase and equip various knives.^n\
- Each knife has unique stats and bonuses.^n\
- ^n\
- - Earn cash by killing enemies^n\
- - Level up to unlock more powerful knives^n\
- - Equipped knives give cash bonuses on kills^n\
- ^n\
- Use /knife command to open the shop anytime!");
- show_motd(id, info_text, "Shop Information");
- }
- public get_player_top_knife(id) {
- new top_knife = 0;
- for (new i = 0; i < sizeof g_Knives; i++) {
- if (is_knife_owned(id, i) && g_Knives[i][KNIFE_PRICE] > g_Knives[top_knife][KNIFE_PRICE]) {
- top_knife = i;
- }
- }
- return top_knife;
- }
- public bool:is_knife_owned(id, knife_id) {
- new owned_knives[256];
- copy(owned_knives, charsmax(owned_knives), g_szPlayerOwnedKnives[id]);
- new knife_name[32];
- copy(knife_name, charsmax(knife_name), g_Knives[knife_id][KNIFE_NAME]);
- return (contain(owned_knives, knife_name) != -1);
- }
- public add_owned_knife(id, knife_id) {
- new owned_knives[256];
- formatex(owned_knives, charsmax(owned_knives), "%s,%s", g_szPlayerOwnedKnives[id], g_Knives[knife_id][KNIFE_NAME]);
- copy(g_szPlayerOwnedKnives[id], charsmax(g_szPlayerOwnedKnives[]), owned_knives);
- }
- public load_player_data(id) {
- new authid[32];
- get_user_authid(id, authid, charsmax(authid));
- new data[512];
- if (nvault_get(g_vault, authid, data, charsmax(data))) {
- new key[32], value[96];
- while (strlen(data) > 0) {
- strtok(data, key, charsmax(key), value, charsmax(value), ';');
- trim(key); trim(value);
- if (equal(key, "cash")) g_iPlayerCash[id] = str_to_num(value);
- else if (equal(key, "level")) g_iPlayerLevel[id] = str_to_num(value);
- else if (equal(key, "xp")) g_iPlayerXP[id] = str_to_num(value);
- else if (equal(key, "equipped_knife")) g_iPlayerEquippedKnife[id] = str_to_num(value);
- else if (equal(key, "owned_knives")) copy(g_szPlayerOwnedKnives[id], charsmax(g_szPlayerOwnedKnives[]), value);
- }
- } else {
- // Default values for new players
- g_iPlayerCash[id] = 1000;
- g_iPlayerLevel[id] = 1;
- g_iPlayerXP[id] = 0;
- g_iPlayerEquippedKnife[id] = 0;
- formatex(g_szPlayerOwnedKnives[id], charsmax(g_szPlayerOwnedKnives[]), "Default Knife");
- }
- }
- public save_player_data(id) {
- new authid[32];
- get_user_authid(id, authid, charsmax(authid));
- new data[512];
- formatex(data, charsmax(data), "cash=%d;level=%d;xp=%d;equipped_knife=%d;owned_knives=%s",
- g_iPlayerCash[id], g_iPlayerLevel[id], g_iPlayerXP[id], g_iPlayerEquippedKnife[id], g_szPlayerOwnedKnives[id]);
- nvault_set(g_vault, authid, data);
- }
- public client_putinserver(id) {
- load_player_data(id);
- g_iPlayerPreviewingKnife[id] = -1;
- }
- public client_disconnected(id) {
- save_player_data(id);
- }
- public event_player_kill() {
- new killer = read_data(1);
- new victim = read_data(2);
- if (killer == victim || !is_user_connected(killer)) return;
- // Add cash and XP for kill
- new xp_gain = is_user_alive(victim) ? 20 : 10; // More XP for killing guards
- g_iPlayerCash[killer] += 100;
- g_iPlayerXP[killer] += xp_gain;
- client_print(killer, print_chat, "You gained %d XP and $100 for the kill!", xp_gain);
- if (g_iPlayerXP[killer] >= g_iPlayerLevel[killer] * 100) {
- g_iPlayerXP[killer] -= g_iPlayerLevel[killer] * 100;
- g_iPlayerLevel[killer]++;
- // Announce level up to all players
- new name[32];
- get_user_name(killer, name, charsmax(name));
- client_print(0, print_chat, "%s has leveled up to level %d!", name, g_iPlayerLevel[killer]);
- }
- // Apply cash bonus from equipped knife
- new knife_id = g_iPlayerEquippedKnife[killer];
- new Float:cash_bonus = g_Knives[knife_id][KNIFE_CASH_BONUS];
- if (cash_bonus > 0.0) {
- new bonus_cash = floatround(float(g_iPlayerCash[killer]) * cash_bonus);
- g_iPlayerCash[killer] += bonus_cash;
- client_print(killer, print_chat, "You earned a bonus of $%d from your knife!", bonus_cash);
- }
- save_player_data(killer);
- }
- public native_get_player_knife_cash(plugin_id, num_params) {
- new id = get_param(1);
- if (id < 1 || id > MAX_PLAYERS) {
- log_error(AMX_ERR_NATIVE, "Invalid player id %d", id);
- return 0;
- }
- return g_iPlayerCash[id];
- }
- public native_set_player_knife_cash(plugin_id, num_params) {
- new id = get_param(1);
- new cash = get_param(2);
- if (id < 1 || id > MAX_PLAYERS) {
- log_error(AMX_ERR_NATIVE, "Invalid player id %d", id);
- return 0;
- }
- g_iPlayerCash[id] = cash;
- save_player_data(id);
- return 1;
- }
- public native_get_player_knife_level(plugin_id, num_params) {
- new id = get_param(1);
- if (id < 1 || id > MAX_PLAYERS) {
- log_error(AMX_ERR_NATIVE, "Invalid player id %d", id);
- return 0;
- }
- return g_iPlayerLevel[id];
- }
- public native_set_player_knife_level(plugin_id, num_params) {
- new id = get_param(1);
- new level = get_param(2);
- if (id < 1 || id > MAX_PLAYERS) {
- log_error(AMX_ERR_NATIVE, "Invalid player id %d", id);
- return 0;
- }
- g_iPlayerLevel[id] = level;
- save_player_data(id);
- return 1;
- }
Advertisement
Comments
-
- מי שעוקב אחריי המוד רק בתהליכי בנייה כי יש בחור מתנשא
- infender חושב שהוא מתכנת על
- build shop hardcoded 1.8.3 so lets copy and paste the SAME SHIT, OFC NOT 100% SAME only half works because not have time
Add Comment
Please, Sign In to add comment
Advertisement