MaHm0ud 455 Posted December 23, 2018 Share Posted December 23, 2018 Nume : plugin save ammo packs Versiune : The newest. Descriere detaliata : I want something to Stabilizes with mod ZP 6.3 Always with server crashes Link to comment Share on other sites More sharing options...
@_@KaiN- 18 Posted December 24, 2018 Share Posted December 24, 2018 Compile .SMA Quote #include <amxmodx> #include <amxmisc> #include <nvault> #include <fakemeta> #include <colorchat> #include <zombieplague> static const version[] = "0.3"; static const plugin[] = "[ZP] Sub Plugin: Auto-save Bank(Name)"; static const prefix[] = "ZP Bank" enum pcvar { enable = 0, cap, start } new pcvars[pcvar]; new bankstorage[33]; new gvault, thinkobj; public plugin_init() { register_plugin(plugin, version, "Random1, 93()|29!/<"); gvault = nvault_open("Zombie Bank Name"); pcvars[enable] = register_cvar("zp_bank", "1"); pcvars[cap] = register_cvar("zp_bank_limit", "900000000"); pcvars[start] = register_cvar("zp_bank_blockstart", "0"); if (get_pcvar_num(pcvars[cap]) > 2147483646) { set_pcvar_num(pcvars[cap], 2147483646); server_print("[%s] Due to a 32 bit restriction in perl zp_ammo_limit reset based on restriction", plugin); } register_clcmd("say", "handle_say"); register_clcmd("say_team", "handle_say"); thinkobj = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")); if (pev_valid(thinkobj)) { set_pev(thinkobj, pev_classname, "advertisement_loop"); set_pev(thinkobj, pev_nextthink, get_gametime() + 240.0); register_forward(FM_Think, "fourmin_think"); } } public fourmin_think(ent) { if (ent != thinkobj) return FMRES_IGNORED; if (!get_pcvar_num(pcvars[enable])) return FMRES_IGNORED; ColorChat(0, GREEN, "[%s]^x01 Activat.^x03 %d^x01 este limita de depozitare.", prefix, get_pcvar_num(pcvars[cap])); ColorChat(0, GREEN, "[%s]^x01 Poti verifica depozitul tastand in chat^x03 deposit <amount>", prefix); ColorChat(0, GREEN, "[%s]^x01 Pentru a preleva ammo packs, tasteaza^x03 withdraw <amount>", prefix); ColorChat(0, GREEN, "[%s]^x01 Auto save este^x03 activat", prefix); set_pev(ent, pev_nextthink, get_gametime() + 240.0); return FMRES_HANDLED; } public plugin_end() nvault_close(gvault); public handle_say(id) { if (!get_pcvar_num(pcvars[enable])) return PLUGIN_CONTINUE; new text[70], arg1[32], arg2[32], arg3[6]; read_args(text, sizeof(text)-1); remove_quotes(text); arg1[0] = '^0'; arg2[0] = '^0'; arg3[0] = '^0'; parse(text, arg1, sizeof(arg1)-1, arg2, sizeof(arg2)-1, arg3, sizeof(arg3)-1); //dbg_log("cmd_say() arg1:#%s# arg2:#%s# arg3:#%s#", arg1, arg2, arg3); // if the chat line has more than 2 words, we're not interested at all if (arg3[0] == 0) { //strip forward slash if present if (equali(arg1, "/", 1)) format(arg1, 31, arg1[1]); if (equali(arg1, "deposit", 7) || equali(arg1, "send", 4) || equali(arg1, "store", 5)) { if (isdigit(arg2[0]) || (arg2[0] == '-' && isdigit(arg2[1]))) { new value = str_to_num(arg2); store_cash(id, value); ColorChat(id, GREEN, "[%s]^x01 Ai depozitat^x03 %d^x01 ammo packs!", prefix, value) return PLUGIN_HANDLED; } else if (equali(arg2, "all")) { store_cash(id, -1); ColorChat(id, GREEN, "[%s]^x01 Ai depozitat^x03 toate^x01 pachetele!", prefix) return PLUGIN_HANDLED; } else if (arg2[0] == 0) ColorChat(id, GREEN, "[%s]^x01 Pentru a depozita ammo packs, tasteaza^x03 deposit <amount to deposit>", prefix); return PLUGIN_CONTINUE; } else if (equali(arg1, "withdraw", 8) || equali(arg1, "take", 4) || equali(arg1, "retrieve", 8)) { if (isdigit(arg2[0]) || (arg2[0] == '-' && isdigit(arg2[1]))) { new value = str_to_num(arg2); take_cash(id, value); ColorChat(id, GREEN, "[%s]^x01 Ai prelevat^x03 %d^x01 ammo packs din depozitul tau!", prefix, value) return PLUGIN_HANDLED; } else if (equali(arg2, "all")) { take_cash(id, -1); ColorChat(id, GREEN, "[%s]^x01 Ai prelevat^x03 toate^x01 pachetele din depozitul tau!", prefix) return PLUGIN_HANDLED; } else if (arg2[0] == 0) ColorChat(id, GREEN, "[%s]^x01 Pentru a preleva ammo packs, tasteaza^x03 withdraw <amount to withdraw>", prefix); return PLUGIN_CONTINUE; } else if (equali(arg1, "mybank", 6) || equali(arg1, "account", 7) || equali(arg1, "bank", 4)) { if (arg2[0] == 0) { ColorChat(id, GREEN, "[%s]^x01 Momentan ai^x03 %d^x01 ammo packs in depozit!", prefix, bankstorage[id]); return PLUGIN_HANDLED; } else { new player = cmd_target(id, arg2, 2); if (!player) return PLUGIN_CONTINUE; static playername[32]; get_user_name(player, playername, 31); ColorChat(id, GREEN, "[%s]^x03 %s^x01 detine^x04 %d^x01 ammo packs in depozitul sau!", prefix, playername, bankstorage[player]); return PLUGIN_HANDLED; } } } else if (equali(arg1, "donate", 6)) { give_cmd(id, arg2, arg3); return PLUGIN_HANDLED; } return PLUGIN_CONTINUE; } give_cmd(id, target[], amnt[]) { new temp = str_to_num(amnt); if (temp < 0) { ColorChat(id, GREEN, "[%s]^x01 Valoarea ^"amount^" este negativa, primesti overflow sau incerci sa trisezi!", prefix); return; } new player = cmd_target(id, target, 8); if (!player) { ColorChat(id, GREEN, "[%s]^x01 Jucatorul specificat nu exista sau se gasesc mai multi jucatori cu acelasi nume!", prefix); return; } new temp2 = bankstorage[id] + zp_get_user_ammo_packs(id); if (temp > temp2) { ColorChat(id, GREEN, "[%s]^x01 Nu ai destule ammo packs pentru a putea dona, detii doar^x04 %d^x01 din^x03 %d^x01 specificate!", prefix, temp2, temp); return; } static playername[32], givename[32]; get_user_name(player, playername, 31); get_user_name(id, givename, 31); ColorChat(id, GREEN, "[%s]^x01 Tocmai ai donat^x03 %d^x01 lui^x04 %s", prefix, temp, playername); ColorChat(player, GREEN, "[%s]^x03 %s^x01 tocmai ti-a donat^x04 %d^x01 ammo packs!", prefix, givename, temp); bankstorage[player] += temp; if (bankstorage[id] > temp) bankstorage[id] -= temp; else { temp -= bankstorage[id]; bankstorage[id] = 0; zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) - temp); } } //public zp_user_disconnect_pre(id) public client_disconnect(id) { store_cash(id, -1); if (bankstorage[id] > 0) save_data(id); } //public zp_user_connect_post(id) public client_connect(id) { bankstorage[id] = 0; //clear residual before loading retrieve_data(id); } store_cash(id, amnt) { if (!get_pcvar_num(pcvars[enable])) return; if (amnt == -1) { bankstorage[id] += zp_get_user_ammo_packs(id); zp_set_user_ammo_packs(id, 0); checkmax(id); } else if (amnt > 0) { new temp = zp_get_user_ammo_packs(id); new limit = get_pcvar_num(pcvars[cap]); if (temp >= amnt) { if (bankstorage[id] + amnt <= limit) { bankstorage[id] += amnt zp_set_user_ammo_packs(id, temp - amnt); } else { new overflow = bankstorage[id] + amnt - limit; bankstorage[id] = limit; zp_set_user_ammo_packs(id, temp - amnt + overflow); ColorChat(id, GREEN, "[%s]^x01 Limita depozitarii a fost atinsa cu^x03 %d^x01 ammo packs", prefix, limit); ColorChat(id, GREEN, "[%s]^x01 Doar^x03 %d^x01 ammo packs din^x04 %d^x01 au fost depozitate", prefix, amnt - overflow, amnt); } } else ColorChat(id, GREEN, "[%s]^x01 Nu dispui de (^x03%d^x01) ammo packs pentru a le putea depozita. (^x04%d^x01)", prefix, amnt, temp); } else take_cash(id, -amnt); } take_cash(id, amnt) { if (!get_pcvar_num(pcvars[enable])) return; if (amnt == 0) //otherwise a non terminal loop is possible return; if (amnt == -1) { zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + bankstorage[id]) bankstorage[id] = 0; } else if (amnt > 0) { if (bankstorage[id] >= amnt) { zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + amnt); bankstorage[id] -= amnt; } else { ColorChat(id, GREEN, "[%s]^x01 Nu dispui de (^x03%d^x01) pentru a le putea preleva. Depozit: (^x04%d^x01)", prefix, amnt, bankstorage[id]); } } else store_cash(id, -amnt); } save_data(id) { new Name[35]; get_user_name(id, Name, 34); new vaultkey[40], vaultdata[13]; formatex(vaultkey, 39, "__%s__", Name); formatex(vaultdata, 12, "%i", bankstorage[id]); nvault_set(gvault, vaultkey, vaultdata); } retrieve_data(id) { new Name[35]; get_user_name(id, Name, 34); new vaultkey[40], vaultdata[13]; format(vaultkey, 39, "__%s__", Name); nvault_get(gvault, vaultkey, vaultdata, 12); bankstorage[id] = str_to_num(vaultdata); checkmax(id); // If they have an account don't allow zombie mod to give them 5 ammo packs at beggining if (get_pcvar_num(pcvars[start]) && bankstorage[id] > 0) zp_set_user_ammo_packs(id, 0); } checkmax(id) { if (bankstorage[id] > get_pcvar_num(pcvars[cap])) bankstorage[id] = get_pcvar_num(pcvars[cap]); else if (bankstorage[id] < 0) bankstorage[id] = 0; } Name: Auto-save Bank Version: 0.3 Cvars : add in amxx.cfg zp_bank - 1/0 Active / disable zp_bank_limit - max ammo in bank 1 1 Link to comment Share on other sites More sharing options...
Recommended Posts