Erori:
- L 03/08/2015 - 16:30:18: [AMXX | Afiseaza codul
Displaying debug trace (plugin "zp_bank.amxx") L 03/08/2015 - 16:30:18: [AMXX] Run time error 10: native error (native "nvault_get") L 03/08/2015 - 16:30:18: [AMXX] [0] zp_bank.sma::retrieve_data (line 563) L 03/08/2015 - 16:30:18: [AMXX] [1] zp_bank.sma::client_putinserver (line 434) L 03/08/2015 - 16:30:35: [nVault] Invalid vault id: 40]
- | Afiseaza codul
L 03/08/2015 - 16:30:35: [AMXX] Displaying debug trace (plugin "zp_bank.amxx") L 03/08/2015 - 16:30:35: [AMXX] Run time error 10: native error (native "nvault_set") L 03/08/2015 - 16:30:35: [AMXX] [0] zp_bank.sma::save_data (line 548) L 03/08/2015 - 16:30:35: [AMXX] [1] zp_bank.sma::client_disconnect (line 422) L 03/08/2015 - 16:30:35: [nVault] Invalid vault id: 40
- | Afiseaza codul
L 03/08/2015 - 16:30:35: [AMXX] Displaying debug trace (plugin "zp_bank.amxx") L 03/08/2015 - 16:30:35: [AMXX] Run time error 10: native error (native "nvault_close") L 03/08/2015 - 16:30:35: [AMXX] [0] zp_bank.sma::plugin_end (line 108) L 03/08/2015 - 16:30:48: Start of error session. L 03/08/2015 - 16:30:48: Info (map "as_oilrig") (file "addons/amxmodx/logs/error_20150308.log") L 03/08/2015 - 16:30:48: [nVault] Invalid vault id: 40
- | Afiseaza codul
//Uncomment to be greedy and not give people 5 ammo packs when they join (if they have less than 5 that is) //#define THERE_IS_NO_GOD #include <amxmodx> #include <amxmisc> #include <nvault> #include <fakemeta> #include <zombieplague> static const version[] = "0.8b"; static const plugin[] = "ZP Bank"; static const defaultPacks = 5; enum pcvar { enable = 0, cap, } new pcvars[pcvar]; new bankstorage[33]; new saveAuthID[33]; new thinkobj; new gvault; new spreeToggle; new g_maxplayers // max players counter new g_msgSayText // Message IDs vars public SaveData() { for( new o = 1; o < 33; o++) { if ( !is_user_connected(o) || is_user_bot(o) ) continue; client_disconnect(o); //bankstorage[o] = 0; } } public plugin_init() { register_plugin(plugin, version, "Random1"); register_event("HLTV", "event_round_start", "a", "1=0", "2=0"); //Language files //register_dictionary("zp_bank.txt") pcvars[enable] = register_cvar("zp_bank", "1"); pcvars[cap] = register_cvar("zp_bank_limit", "1000000"); gvault = nvault_open("Zombie Bank"); g_maxplayers = get_maxplayers() // Get Max Players g_msgSayText = get_user_msgid("SayText") //Settings variables spreeToggle = 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"); register_clcmd("zp_give_packs", "givex_cmd", ADMIN_RCON, "<name> <amount>, gives ammo packs, only if the person is in game"); register_clcmd("zp_take_packs", "takex_cmd", ADMIN_RCON, "<name> <amount>, takes ammo packs away, only if the person is in game"); register_concmd("zp_reset_bank", "prune_task", ADMIN_RCON, "<time> in days. time 0 = clean all"); register_clcmd("zp_spendingspree", "spending_cmd", ADMIN_RCON, "enable or disable spending spree mode"); 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; zp_colored_print(0, "^x04[%s]^x01 Ammo packs are automatically saved.", plugin); //zp_colored_print(0, "^x04[%s]^x01 No typing withdraw / deposit needed.", plugin); set_pev(ent, pev_nextthink, get_gametime() + 240.0); return FMRES_HANDLED; } public plugin_natives() { //natives register_native("zp_bank_get_packs", "getAmmoPacks", 1) register_native("zp_bank_set_packs", "setAmmoPacks", 1) } public plugin_end() { server_print("[%s] Saving your money. ", plugin); for( new o = 1; o < 33; o++) { if ( !is_user_connected(o) || is_user_bot(o) ) continue; save_data(o); } nvault_close(gvault); } public getAmmoPacks(id) { if ( spreeToggle == 0) { return zp_get_user_ammo_packs(id); } else { return bankstorage[id]; } return -1; } public setAmmoPacks(id, amnt) { if ( spreeToggle == 0) { zp_set_user_ammo_packs(id, amnt); } else { bankstorage[id] = amnt; } } 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); // 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) || equali(arg1, "withdraw", 8) || equali(arg1, "take", 4) || equali(arg1, "retrieve", 8)) { zp_colored_print(id, "^x04[%s]^x01 Deposit and withdraw are unnecessary.", plugin); zp_colored_print(id, "^x04[%s]^x01 Money is stored automatically", plugin); return PLUGIN_CONTINUE; } else if ( equali(arg1, "mybank", 6) || equali(arg1, "account", 7) || equali(arg1, "bank", 4) ) { if ( arg2[0] == 0 ) { zp_colored_print(id, "^x04[%s]^x01 Currently your account has %d ammo packs in it",plugin, getAmmoPacks(id)); return PLUGIN_HANDLED; } else { new player = cmd_target(id,arg2,2); if ( !player ) return PLUGIN_CONTINUE; zp_colored_print(id, "^x04[%s]^x01 %s has %d ammo packs", plugin, arg2, getAmmoPacks(player)); return PLUGIN_HANDLED; } } } else if ( equali( arg1, "donate", 6 ) ) { give_cmd(id, arg2, arg3); return PLUGIN_HANDLED; } return PLUGIN_CONTINUE; } public prune_task(id,level,cid) { if (!cmd_access(id,level,cid,1)) { console_print(id,"You have no access to that command"); return; } new connum = read_argc() if (connum > 2) { console_print(id,"Too many arguments supplied."); return; } if ( connum == 1 ) return; //person just typed command to see the description //we check this because str_to_num will return 0 on an empty string thus doing the same thing as "zp_reset_bank 0" which does a full reset static adminname[32]; get_user_name(id, adminname, 31); new arg[10]; read_argv(1,arg,9); new timeamnt = str_to_num(arg); if ( timeamnt == 0 ) { nvault_prune(gvault, 0, 0); zp_colored_print(0, "^x04[%s]^x01 The Bank's Been Robbed!, those dirty crooks stole all your money!", plugin); log_amx("[%s] bank has been reset(completly) by admin %s", plugin, adminname); //for those who are in the server at the time of prune need to whipe out there stuff as well for( new o = 1; o < 33; o++) { if ( !is_user_connected(o) || is_user_bot(o) ) continue; bankstorage[o] = 0; if (spreeToggle == 0) zp_set_user_ammo_packs(o, 0); } } else { nvault_prune(gvault, 0, get_systime() - (timeamnt * 86400)); log_amx("[%s] Bank has been pruned %d day%s by admin %s", plugin, timeamnt, timeamnt == 1 ? "" : "'s", adminname); } } public takex_cmd(id) { if ( read_argc() > 3 ) return PLUGIN_HANDLED; new arg1[32], arg2[10], amount, curAmount; read_argv(1, arg1, sizeof(arg1) - 1); read_argv(2, arg2, sizeof(arg2) - 1); amount = str_to_num(arg2); new target = cmd_target(0, arg1, 2); if ( target == 0 ) { //couldnt find them zp_colored_print(id, "^x04[%s]^x01 Could not find the requested user."); return PLUGIN_HANDLED; } else { //we found them! new targetName[64]; get_user_name(target, targetName, 63); curAmount = getAmmoPacks(target); if ( amount > curAmount ) { if (curAmount == 0) { zp_colored_print(id, "^x04[%s]^x01 %s has %d ammo packs!", plugin , targetName, curAmount); return PLUGIN_HANDLED; } else { zp_colored_print(id, "^x04[%s]^x01 %s only had %d ammo packs, so they were all removed!", plugin , targetName, curAmount); } //if (spreeToggle == 0) store_cash(target, curAmount); setAmmoPacks(target, 0); amount = curAmount; } else { //if (spreeToggle == 0) store_cash(target, amount); setAmmoPacks(target, curAmount - amount); } zp_colored_print(id, "^x04[%s]^x01 You have punished %s by taking %d ammo packs!", plugin , targetName, amount ); zp_colored_print(target, "^x04[%s]^x01 You have been punished and have lost %d ammo packs!", plugin , amount ); return PLUGIN_HANDLED; } return PLUGIN_HANDLED; } public givex_cmd(id) { if ( read_argc() > 3 ) return PLUGIN_HANDLED; new arg1[32], arg2[10], amount; read_argv(1, arg1, sizeof(arg1) - 1); read_argv(2, arg2, sizeof(arg2) - 1); amount = str_to_num(arg2); new target = cmd_target(0, arg1, 2); if ( target == 0 ) { //couldnt find them zp_colored_print(id, "^x04[%s]^x01 Could not find the requested user.", plugin); return PLUGIN_HANDLED; } else { //we found them! //bankstorage[target] += amount; setAmmoPacks(target, getAmmoPacks(target) + amount); //if( spreeToggle == 1) store_cash(target, amount); if(id == target) { zp_colored_print(id, "^x04[%s]^x01 You have given yourself %d ammo packs!", plugin, amount ); } else { new targetName[64]; get_user_name(target, targetName, 63); zp_colored_print(id, "^x04[%s]^x01 You have awarded %s with %d ammo packs!", plugin , targetName, amount ); zp_colored_print(target, "^x04[%s]^x01 You have been awarded with %d ammo packs!", plugin , amount ); } return PLUGIN_HANDLED; } return PLUGIN_HANDLED; } public spending_cmd(id) { if ( read_argc() > 2 ) { client_print(id, print_console, "[%s] Incorrect contaxt.", plugin); return PLUGIN_HANDLED; } new arg1[32], spree; read_argv(1, arg1, sizeof(arg1) - 1); spree = str_to_num(arg1); if ( spree == 0 ) { //disable our spending spree //first check if it was previously enabled if ( spreeToggle == 0) return PLUGIN_HANDLED; //end our spending spree zp_colored_print(0, "^x04[%s]^x01 The spending spree is over.", plugin); client_print(id, print_console, "[%s] Disabled spending spree.", plugin); //remove everyone's extra money for( new o = 1; o < 33; o++) { if ( !is_user_connected(o) || is_user_bot(o) ) continue; //re-withdraw everyone's money zp_set_user_ammo_packs(o, bankstorage[o]); bankstorage[o] = 0; } spreeToggle = 0; return PLUGIN_HANDLED; } else { //enable it if ( spreeToggle == 1) return PLUGIN_HANDLED; for( new o = 1; o < 33; o++) { if ( !is_user_connected(o) || is_user_bot(o) ) continue; //store our money first bankstorage[o] = zp_get_user_ammo_packs(o); //set a high amount of money for everyone zp_set_user_ammo_packs(o, get_pcvar_num(pcvars[cap])); } zp_colored_print(0, "^x04[%s]^x01 The spending spree is ON! Go Wild!", plugin); client_print(id, print_console, "[%s] Enabled spending spree.", plugin); spreeToggle = 1; return PLUGIN_HANDLED; } return PLUGIN_HANDLED; } give_cmd(id, target[], amnt[]) { new temp = str_to_num(amnt); if ( temp < 0 ) { client_print(id, print_chat, "[%s] The ^"amount^" argument passed is negative, either overflowed or your trying to cheat", plugin ); return PLUGIN_HANDLED; } new player = cmd_target(id, target, 8); if ( !player ) { zp_colored_print(id, "^x04[%s]^x01 Could not find the requested user.", plugin); return PLUGIN_HANDLED; } new temp2 = getAmmoPacks(id); if ( temp > temp2 ) { client_print(id, print_chat, "[%s] You don't have enough ammo packs to donate, you only have %d out of %d specified",plugin, temp2, temp); return PLUGIN_HANDLED; } static playername[32], givename[32]; get_user_name(player, playername, 31); get_user_name(id, givename, 31); client_print(id, print_chat, "[%s] You just donated %d ammo packs to %s", plugin, temp, playername); client_print(player, print_chat, "[%s] %s just donated %d ammo packs to you", plugin, givename, temp); if ( getAmmoPacks(id) > temp ) { setAmmoPacks(id, getAmmoPacks(id) - temp); setAmmoPacks(player, getAmmoPacks(player) + temp); } else { temp -= getAmmoPacks(id); setAmmoPacks(id, 0); setAmmoPacks(player, getAmmoPacks(player) + temp); } return PLUGIN_HANDLED; } //public zp_user_disconnect_pre(id) public client_disconnect(id) { //fixed bug here, people could spend all their money, and then not have it save the 0 remaining save_data(id); } //public zp_user_connect_post(id) public client_putinserver(id) { get_user_name(id,saveAuthID[id],34); bankstorage[id] = 0; //clear residual before loading zp_set_user_ammo_packs(id, 0); //clear retrieve_data(id); } public event_round_start() { if (spreeToggle == 1) { //replenish everyone's money for( new o = 1; o < 33; o++) { if ( !is_user_connected(o) || is_user_bot(o) ) continue; zp_set_user_ammo_packs(o, get_pcvar_num(pcvars[cap])); } set_task(2.2, "spreeAlert") } for( new o = 1; o < 33; o++) { if ( !is_user_connected(o) || is_user_bot(o) ) continue; save_data(o); } } public spreeAlert() { zp_colored_print(0, "^x04[%s]^x01 The spending spree is ON! Go Wild!", plugin); } 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); zp_colored_print(id, "^x04[%s]^x01 Your bank account has reached it's maximium capacity of %d", plugin, limit); zp_colored_print(id, "^x04[%s]^x01 Only %d of the %d you specified to deposit has been deposited", plugin, amnt - overflow, amnt); } } else zp_colored_print(id, "^x04[%s]^x01 Amount specified(%d) is greater than current ammo pack count(%d)", plugin, amnt, temp); } else take_cash(id, -amnt); } take_cash(id, amnt) { if ( !get_pcvar_num(pcvars[enable]) ) return; if ( amnt == 0 ) return; //otherwise a non terminal loop is possible 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 { /* zp_colored_print(id, "^x04[%s]^x01 Amount specified(%d) is greater than whats in bank(%d)", plugin, amnt, bankstorage[id]); */ } } else store_cash(id, -amnt); } checkmax(id) { if ( zp_get_user_ammo_packs(id) > get_pcvar_num(pcvars[cap]) ) zp_set_user_ammo_packs(id, get_pcvar_num(pcvars[cap])); else if ( zp_get_user_ammo_packs(id) < 0 ) zp_set_user_ammo_packs(id, 0); } save_data(id) { //new AuthID[35]; //get_user_name(id,AuthID,34); new vaultkey[40],vaultdata[13]; formatex( vaultkey, 39, "__%s__", saveAuthID[id]); formatex( vaultdata, 12, "%i", getAmmoPacks(id)); nvault_set(gvault, vaultkey, vaultdata); //clear data //bankstorage[id] = 0; //clear residual before loading //zp_set_user_ammo_packs(id, 0); //clear } retrieve_data(id) { //new AuthID[35]; //get_user_name(id,AuthID,34); new vaultkey[40], vaultdata[13]; format(vaultkey, 39, "__%s__", saveAuthID[id]); nvault_get(gvault, vaultkey, vaultdata, 12); zp_set_user_ammo_packs(id, str_to_num(vaultdata)); checkmax(id); //if they have less then the default, be nice and give them some #if !defined THERE_IS_NO_GOD if ( zp_get_user_ammo_packs(id) < defaultPacks ) zp_set_user_ammo_packs(id, defaultPacks); #endif if ( spreeToggle == 1 ) { bankstorage[id] = zp_get_user_ammo_packs(id); zp_set_user_ammo_packs(id, get_pcvar_num(pcvars[cap])); } } /*================================================================================ --The following are copied directly from zombie_plague, no reinventing wheels... [Shared Functions] =================================================================================*/ zp_colored_print(target, const message[], any:...) { static buffer[512], i, argscount argscount = numargs() // Send to everyone if (!target) { static player for (player = 1; player <= g_maxplayers; player++) { // Not connected if (!is_user_connected(player)) continue; // Remember changed arguments static changed[5], changedcount // [5] = max LANG_PLAYER occurencies changedcount = 0 // Replace LANG_PLAYER with player id for (i = 2; i < argscount; i++) { if (getarg(i) == LANG_PLAYER) { setarg(i, 0, player) changed[changedcount] = i changedcount++ } } // Format message for player vformat(buffer, sizeof buffer - 1, message, 3) // Send it message_begin(MSG_ONE, g_msgSayText, _, player) write_byte(player) write_string(buffer) message_end() // Replace back player id's with LANG_PLAYER for (i = 0; i < changedcount; i++) setarg(changed, 0, LANG_PLAYER) } } // Send to specific target else { /* // Replace LANG_PLAYER with player id for (i = 2; i < argscount; i++) { if (getarg(i) == LANG_PLAYER) setarg(i, 0, target) } */ // Format message for player vformat(buffer, sizeof buffer - 1, message, 3) // Send it message_begin(MSG_ONE, g_msgSayText, _, target) write_byte(target) write_string(buffer) message_end() } }