Raised This Month: $ Target: $400
 0% 

Overkill fix please


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-18-2009 , 17:18   Overkill fix please
Reply With Quote #1

The plugin OverKill (originally for cs but said to work for all), on tfc it wants me to enable debug, but it wont work on my linux box, but when I debug on my windows box this is what I get
Code:
L 06/18/2009 - 23:14:00: Start of error session.
L 06/18/2009 - 23:14:00: Info (map "crossover2") (file "addons/amxmodx/logs/error_20090618.log")
L 06/18/2009 - 23:14:00: [AMXX] Displaying debug trace (plugin "overkill.amxx")
L 06/18/2009 - 23:14:00: [AMXX] Run time error 4: index out of bounds 
L 06/18/2009 - 23:14:00: [AMXX]    [0] overkill.sma::overkill (line 132)
and the main problem is that I will be put on my own team, but still on the same team

example:
Blue (7 players)
Red (1 player)
Red (6 players)

and another problem is after reaching the max overkill it will reset to the default health..

can someone help me please?
PHP Code:
/****************************************
*    Author: TwN            *
*    Credits (in random order)    *
*    Yamikaitou            *
*    connorr                *
*    kingpin (idea of saving        *
*        also borrowed         *
*        some code)        *
*    Greenberet            *
*    Howdy                *
*                    *
*    Note, I like to use inline    *
*    comments more, dno why...    *
*                    *
*    Similair plugins        *
*    hitreward (mistagee)        *
*    repay (kingpin port)        *
*                    *
*****************************************/

#include <amxmodx>
#include <fun>

#define AUTHOR "TwN"
#define NAME "OverKill"
#define VERSION "0.7.7.7"


enum Color {
    
YELLOW 1// Yellow
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

new 
TeamInfo;
new 
SayText;

new 
TeamName[][] = {
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

//new bool:IsConnected[33];


new g_health[33]
new 
color[33]
new 
amx_overkill,amx_ok_perc,amx_ok_life_cap,amx_ok_max,amx_ok_reward_cap,amx_ok_perc_capped,amx_ok_ff,amx_ok_savehp

public plugin_init() 

    
register_plugin(NAME,VERSION,AUTHOR)
    
amx_overkill register_cvar("amx_overkill","1"/* on/off var */
    
amx_ok_perc register_cvar("amx_ok_perc","100"/* starting perc */
    
amx_ok_life_cap =register_cvar("amx_ok_life_cap","200"/* maximum total healt*/
    
amx_ok_max register_cvar("amx_ok_max","80"/* maximum reward per overkill 0 to disable */
    
amx_ok_reward_cap register_cvar("amx_ok_reward_cap","5"/* hp before breaking down */
    
amx_ok_perc_capped register_cvar("amx_ok_perc_capped","15"/* number to lower the perc by */
    
amx_ok_ff register_cvar("amx_ok_ff","1"/* teamkills give reward? */
    
amx_ok_savehp register_cvar("amx_ok_savehp","1"/* save hp? */
    
register_event("DeathMsg","overkill","ade","5=0"/* 5=0 -> no car kills/trigger hurts etc. */
    
register_event("ResetHUD","load_health","be"
    
register_logevent("save_health",2,"1=Round_End")
    
    
TeamInfo get_user_msgid("TeamInfo");
    
SayText get_user_msgid("SayText");
    
    return 
PLUGIN_CONTINUE 
}


public 
load_health(id) {
    if (!
get_pcvar_num(amx_overkill) || !get_pcvar_num(amx_ok_savehp))
        return 
PLUGIN_CONTINUE
    
new hp g_health[id]
    if (
hp 100)
    { 
        
// avoid conflicts with other plugins. Hope this works ><
        
new curhp get_user_health(id)
        
hp hp 100 curhp
        set_user_health
(id,hp)
        switch(
hp)
        {
            case 
0..115// green
            
{
                
color[0] = 0x04;
            }
            case 
116..130// yellow
            
{
                
color[0] = 0x01;
            }
            default:
            
color[0] = 0x03;
            
        }
        
//ColorChat(0, RED, "%s, This color is %s.", "Hello", "red");
        
ColorChat(idRED"^x04[^x1OK^x04]^x01 * You have %s%d^x01 health because of your previous OverKilling!",color,hp)
        
client_print(id,print_chat,"[OK] * You have %d health because of your previous overkilling!",hp
    }
    
    return 
PLUGIN_CONTINUE


public 
save_health() {
    if (!
get_pcvar_num(amx_overkill) || !get_pcvar_num(amx_ok_savehp))
        return 
PLUGIN_CONTINUE
    
    
for (new 1<= get_maxplayers(); ++i
        
g_health[i] = get_user_health(i)  
    
    return 
PLUGIN_CONTINUE 


public 
overkill(id) {
    if (!
get_pcvar_num(amx_overkill))
        return 
PLUGIN_CONTINUE
    
new killerid read_data(1)
    if (
killerid == 0)
        return 
PLUGIN_CONTINUE
    
new deadid read_data(2)
    
//users should already connected and killer should be alive... duh.. >< just check for safety
    
if (!is_user_alive(killerid) && !is_user_connected(deadid))
        return 
PLUGIN_CONTINUE
    
//Reward if it's a teamkill?
    
if (get_user_team(killerid) == get_user_team(deadid) && !get_pcvar_num(amx_ok_ff))
        return 
PLUGIN_CONTINUE
    g_health
[deadid] = 100    
    
new Float:hp float(get_user_health(deadid) * -1)
    if (!
hp)
        return 
PLUGIN_CONTINUE
    
new Float:rewardhp,Float:temp,Float:reward_cap float(get_pcvar_num(amx_ok_reward_cap)),Float:perc get_pcvar_num(amx_ok_perc) / 100.0,Float:perc_capped get_pcvar_num(amx_ok_perc_capped) / 100.0,Float:tempperc
    
new inloop 1
    
    
while (inloop)
    {    
        if (
hp <= reward_cap) {
            
temp hp perc
            inloop 
0
        
}
        
        else {
            
temp reward_cap perc
            hp 
-= reward_cap
            
            tempperc 
perc
            perc 
perc perc_capped
            
//client_print(killerid,print_chat,"perc %d hp %d",perc,hp)
            
if (perc 0) {
                
tempperc perc_capped perc
                temp 
+= tempperc hp
                inloop
=0
                
//client_print(killerid,print_chat,"in loop perc < 0 **perc=%d",perc)
            
}
        }
        
        
rewardhp += temp
    
}
    
    new 
Float:maxreward float(get_pcvar_num(amx_ok_max))
    if (
maxreward)
        
rewardhp rewardhp maxreward maxreward rewardhp
    
    
new Float:health float(get_user_health(killerid))
    
health += rewardhp
    
    
new Float:life_cap float(get_pcvar_num(amx_ok_life_cap))
    if (
life_cap
        
health health life_cap life_cap health
    
    set_user_health
(killerid,floatround(health))
    
//client_print(killerid,print_chat,"[OK] +%dhp.",floatround(rewardhp))
    //ColorChat(0, RED, "%s, This color is %s.", "Hello", "red");
    
switch(floatround(rewardhp))
    {
        case 
0..25// green
        
{
            
color[0] = 0x04;
        }
        default:
        
color[0] = 0x03;
        
    }
    
ColorChat(killeridRED"^x01[^x04OK^x01]^x01 +%s%d^x01hp!",color,floatround(rewardhp))
    
    
    return 
PLUGIN_CONTINUE 




/*
public client_putinserver(player) {
    IsConnected[player] = true;
}

public client_disconnect(player) {
    IsConnected[player] = false;
}*/

public ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...) {
    if(
get_playersnum() < 1
    {   
        return; 
    }
    
    static 
message[256];
    
    switch(
type)
    {
        case 
YELLOW// Yellow
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
        
message[0] = 0x03;
        
    }
    
    
vformat(message[1], 251msg4);
    
    
// Make sure message is not longer than 192 character. Will crash the server.
    
message[192] = '^0';
    
    new  
ColorChange
    
    ColorChange 
ColorSelection(idMSG_ONEtype);
    
    
ShowColorMessage(idMSG_ONEmessage);
    
    if(
ColorChange)
    {
        
Team_Info(idMSG_ONETeamName[get_user_team(id)]);
    }
}

public 
ShowColorMessage(idtypemessage[])
{
    
message_begin(typeSayText_id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

public 
Team_Info(idtypeteam[])
{
    
message_begin(typeTeamInfo_id);
    
write_byte(id);
    
write_string(team);
    
message_end();
    
    return 
1;
}

public 
ColorSelection(indextypeColor:Type)
{
    switch(
Type)
    {
        case 
RED:
        {
            return 
Team_Info(indextypeTeamName[1]);
        }
        case 
BLUE:
        {
            return 
Team_Info(indextypeTeamName[2]);
        }
        case 
GREY:
        {
            return 
Team_Info(indextypeTeamName[0]);
        }
    }
    
    return 
0;

__________________
+|- KARMA Respectively

HLM is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-18-2009 , 17:32   Re: Overkill fix please
Reply With Quote #2

register_event("DeathMsg", "overkill", "a")
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-18-2009 , 18:25   Re: Overkill fix please
Reply With Quote #3

so if I change it to that it should be fixed?
__________________
+|- KARMA Respectively

HLM is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-19-2009 , 00:58   Re: Overkill fix please
Reply With Quote #4

Atm the moment it is registered like this :

register_event("DeathMsg","overkill","ade","5 =0")

flags d and e are used when you register event with flag b and not flag a.
DeathMsg is a global event that has to be registered with flag a.
Also, there are never 5 args in that message, that's why i've also removed "5=0"

Also, as it is registered with flag a, no id will be passed, so change :

public overkill(id)
{

with

public overkill()
{



Could be more errors in that plugin, haven't read it much.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-19-2009 , 11:19   Re: Overkill fix please
Reply With Quote #5

that does fix the health reset, but for some reason after getting an overkill, that person is moved into their own unassigned team (red/blue)

I dont really understand why/how it does that..
__________________
+|- KARMA Respectively

HLM is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-21-2009 , 00:37   Re: Overkill fix please
Reply With Quote #6

This is a respective bump, not to take a priority over others, but to help me learn how to solve my own problems in the future
__________________
+|- KARMA Respectively

HLM 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 15:36.


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