Raised This Month: $ Target: $400
 0% 

[ HELP ] How to fix the code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-19-2015 , 14:12   [ HELP ] How to fix the code?
Reply With Quote #1

I have a little problem this plugin, it multiplies the damage pattern of a gun by the number of cvars, but not working, what's wrong? and I can improve the code?

Code:
#include < amxmodx > #include < hamsandwich > #include < zombieplague > new const VERSION[] = "1.1"; new g_hamczbots, cvar_botquota, Float:cvar_increase_damage_x, cvar_gmode_increase_damage[5]; public plugin_init() {     register_plugin("[ZP43] Addon: Increase Damage", VERSION, "CrazY");     cvar_botquota = get_cvar_pointer("bot_quota");     cvar_gmode_increase_damage[0] = register_cvar("zp_infection_mod_damage_x", "1.0")     cvar_gmode_increase_damage[1] = register_cvar("zp_nemesis_mod_damage_x", "1.0")     cvar_gmode_increase_damage[3] = register_cvar("zp_survivor_mod_damage_x", "1.0")     cvar_gmode_increase_damage[4] = register_cvar("zp_swarm_mod_damage_x", "1.0")     cvar_gmode_increase_damage[5] = register_cvar("zp_plague_mod_damage_x", "1.0")     RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage"); } public client_putinserver(id) {     if (is_user_bot(id) && g_hamczbots && cvar_botquota)         set_task(0.1, "register_ham_bots", id); } public register_ham_bots(id) {     if (g_hamczbots || !is_user_connected(id) || !get_pcvar_num(cvar_botquota))         return;     RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage");         g_hamczbots = true; } public zp_round_started(mode) {     new attacker = read_data(2);         if(!zp_get_user_zombie(attacker))     {         switch (mode)         {             case MODE_INFECTION: // Infection mode             {                 cvar_increase_damage_x = get_pcvar_float(cvar_gmode_increase_damage[0]);             }             case MODE_MULTI: // Multi-Infection mode             {                 cvar_increase_damage_x = get_pcvar_float(cvar_gmode_increase_damage[0]);             }             case MODE_NEMESIS: // Nemesis mode             {                 cvar_increase_damage_x = get_pcvar_float(cvar_gmode_increase_damage[1]);             }             case MODE_SURVIVOR: // Survivor mode             {                 cvar_increase_damage_x = get_pcvar_float(cvar_gmode_increase_damage[2]);             }             case MODE_SWARM: // Swarm mode             {                 cvar_increase_damage_x = get_pcvar_float(cvar_gmode_increase_damage[3]);             }             case MODE_PLAGUE: // Plague mode             {                 cvar_increase_damage_x = get_pcvar_float(cvar_gmode_increase_damage[4]);             }         }     } } public fw_TakeDamage(attacker, victim, inflictor, Float:damage) {     if (is_user_alive(attacker) && is_user_alive(victim))     {         SetHamParamFloat(4, damage * cvar_increase_damage_x);     } }
__________________








CrazY. is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 11-19-2015 , 14:25   Re: [ HELP ] How to fix the code?
Reply With Quote #2

In plugin_init you stored a cvar in an out of bounds index of 5.
Darkness_ is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-19-2015 , 14:56   Re: [ HELP ] How to fix the code?
Reply With Quote #3

cvar_gmode_increase_damage[5] => cvar_gmode_increase_damage[6]
OciXCrom is offline
Send a message via Skype™ to OciXCrom
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-19-2015 , 19:00   Re: [ HELP ] How to fix the code?
Reply With Quote #4

Thank for the help, the other problem was g_hamczbots.
I've got another little problem, I made a plugin to give an extra item to a random bot, and modified so that no extra if the bot already have, only when all the bots already have the extra, the weapon is given to a player with id 0, how to fix?

Code:
#include < amxmodx > #include < zombieplague > new const VERSION[] = "1.0"; new g_MaxPlayers, cvar_give_extras_delay, g_endround, g_has_extra[33]; public plugin_init() {     register_plugin("[ZP43] Addon: Give Random Extras Bot", VERSION, "CrazY");     g_MaxPlayers = get_maxplayers()     cvar_give_extras_delay = register_cvar("zp_give_extras_delay", "20.0"); } public zp_round_started() {     g_endround = false;     set_task(get_pcvar_float(cvar_give_extras_delay), "give_extras_bot", 053, .flags="b"); } public zp_round_ended() {     g_endround = true;     if(task_exists(053)) remove_task(053); } public give_extras_bot() {     if(!g_endround)     {         static iBotName[33], iBotsNum; iBotsNum = fnGetAlive();         new botid = fnGetRandomAlive(random_num(1, iBotsNum))         get_user_name(botid, iBotName, 32);         set_hudmessage(random(255), random(255), random(255), -1.0, 0.7, 1, 6.0, 1.1, 0.5, 0.5);         show_hudmessage(0, "O bot %s ganhou uma  M249 Para Machinegun", iBotName);         zp_force_buy_extra_item(botid, zp_get_extra_item_id("M249 Para Machinegun"), 1);         g_has_extra[botid] = true;     } }   stock fnGetAlive() {     new iAlive, id;         for (id = 1; id <= g_MaxPlayers; id++)     {        if (is_user_alive(id) && is_user_bot(id) && !zp_get_user_zombie(id) && !zp_get_user_survivor(id) && !g_has_extra[id])             iAlive++     }         return iAlive; } stock fnGetRandomAlive(target_index) {     new iAlive, id;         for (id = 1; id <= g_MaxPlayers; id++)     {         if (is_user_alive(id) && is_user_bot(id) && !zp_get_user_zombie(id) && !zp_get_user_survivor(id) && !g_has_extra[id])             iAlive++                 if (iAlive == target_index)             return id;     }         return -1; }
__________________








CrazY. is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:04.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode