AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   tag mismatch on line 359 (https://forums.alliedmods.net/showthread.php?t=126537)

HLM 05-10-2010 13:27

tag mismatch on line 359
 
Code:

if(get_pcvar_num(amx_ok_bb_enable))
        {
                get_user_name(victimid,victimname,31)
                new healthtransfer = g_bhealth[victimid]/2
                if(healthtransfer < 1)
                        healthtransfer = 1
                new healthloss = g_bhealth[victimid]/2.5
                if(get_pcvar_num(amx_ok_bb_cap_override))
                {
                        g_bhealth[victimid] -= healthloss
                        g_bhealth[killerid] += healthtransfer
                        client_print(killerid,print_chat,"[OK] (%d)  +%d blood for killing %s.",g_bhealth[killerid],healthtransfer,victimname)
                        client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
                        DisplayHud(victimid)
                        DisplayHud(killerid)
                }
                else if(!get_pcvar_num(amx_ok_bb_cap_override))
                {
                        if((g_bhealth[killerid] + healthtransfer) <= (get_pcvar_num(amx_ok_bb_cap)))
                        {
                                g_bhealth[victimid] -= healthloss
                                g_bhealth[killerid] += healthtransfer
                                client_print(killerid,print_chat,"[OK] (%d)  +%d blood for killing %s.",g_bhealth[killerid],healthtransfer,victimname)
                                client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
                                DisplayHud(victimid)
                                DisplayHud(killerid)
                        }
                        else
                        {
                                g_bhealth[killerid] = (get_pcvar_num(amx_ok_bb_cap))
                                client_print(killerid,print_chat,"[OK] You could not gain any more Blood, because your current bank is full(%d)!",(get_pcvar_num(amx_ok_bb_cap)))
                                g_bhealth[victimid] -= healthloss
                                g_bhealth[killerid] = (get_pcvar_num(amx_ok_bb_cap))
                                client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
                                DisplayHud(victimid)
                                DisplayHud(killerid)
                        }
                }
        }


grimvh2 05-10-2010 13:42

Re: tag mismatch on line 359
 
show the full code, probally this "amx_ok_bb_cap_override" is bad.

HLM 05-10-2010 13:49

Re: tag mismatch on line 359
 
full code? all 2000 lines?

PHP Code:

new g_health[33]
new 
g_bhealth[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_debug,amx_ok_bb_cap,amx_ok_bb_enable,amx_ok_bb_flagcap,amx_ok_bb_capreward,amx_ok_bb_cap_override

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","250"/* 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_debug register_cvar("amx_ok_debug","0"/* enable shitty debug messages */
    
amx_ok_bb_cap register_cvar("amx_ok_bb_cap""10000"/* set the limit for the blood bank */
    
amx_ok_bb_cap_override register_cvar("amx_ok_bb_cap_override""1"/* override the blood bank cap, so you can get literally infinite blood */
    
amx_ok_bb_enable register_cvar("amx_ok_bb_enable""1"/* is the bank open today? */
    
amx_ok_bb_flagcap register_cvar("amx_ok_bb_flagcap""1"/* give bonus blood for a flagcap?*/
    
amx_ok_bb_capreward register_cvar("amx_ok_bb_capreward""50"/* how much blood to give for a flag cap? */
    
register_event("DeathMsg""overkill""a")
    
    
register_clcmd("amx_bloodbank""bb_menu", -1"Opens the Blood Bank Menu")
    
register_clcmd("say","say_help")
    
register_clcmd("say_team","say_help")
    
register_clcmd("setblood","set_user_blood",ADMIN_SLAY,"Sets a users bloodlevel")
    
register_clcmd("amx_ok_reset","empty_vault",ADMIN_BAN,"Clears all bloodbank records")
    
    
register_forward(FM_Touch,"hook_touch")
    
    
RegisterHam(Ham_TakeDamage"player""fw_takedamage")
    
    
RegisterHamHam_Spawn "player" "ham_user_spawn" )
    
    
register_forward(FM_ChangeLevel"fwd_FM_ChangeLevel");
    
    
register_logevent("flagcap"3"1=triggered""2&dropoff");
    
    return 
PLUGIN_CONTINUE 


PHP Code:

public overkill() 
{
    if (!
get_pcvar_num(amx_overkill))
        return 
PLUGIN_CONTINUE
    
new killerid read_data(1)
    new 
victimid read_data(2)
    new 
victimname[32]
    
get_user_name(victimid,victimname,31)
    if( (
killerid == ) || (victimid == 0) || (killerid == victimid ) )
        return 
PLUGIN_CONTINUE
    
    
//users should already connected and killer should be alive... duh.. >< just check for safety
    
if(!is_user_connected(victimid))
        return 
PLUGIN_CONTINUE
    
//Reward if it's a teamkill?
    
if (get_user_team(killerid) == get_user_team(victimid) && !get_pcvar_num(amx_ok_ff))
        return 
PLUGIN_CONTINUE
    g_health
[victimid] = 100    
    
new Float:hp float(get_user_health(victimid) * -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
    
    
    
if(is_user_alive(killerid))
    {
        if(
g_health[killerid] == life_cap)
        {
            
client_print(killerid,print_chat"[OK] Could not gain any more life, you are capped! (%d)",floatround(life_cap))
        }
        else
        {
            
g_health[killerid] = (floatround(health))
            
set_user_health(killerid,floatround(health))
            
client_print(killeridprint_chat"[OK] +%dhp!",floatround(rewardhp))
        }
    }
    if(
get_pcvar_num(amx_ok_bb_enable))
    {
        
get_user_name(victimid,victimname,31)
        new 
healthtransfer g_bhealth[victimid]/2
        
if(healthtransfer 1)
            
healthtransfer 1
        
new healthloss g_bhealth[victimid]/2.5
        
if(get_pcvar_num(amx_ok_bb_cap_override))
        {
            
g_bhealth[victimid] -= healthloss
            g_bhealth
[killerid] += healthtransfer
            client_print
(killerid,print_chat,"[OK] (%d)  +%d blood for killing %s.",g_bhealth[killerid],healthtransfer,victimname)
            
client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
            
DisplayHud(victimid)
            
DisplayHud(killerid)
        }
        else if(!
get_pcvar_num(amx_ok_bb_cap_override))
        {
            if((
g_bhealth[killerid] + healthtransfer) <= (get_pcvar_num(amx_ok_bb_cap)))
            {
                
g_bhealth[victimid] -= healthloss
                g_bhealth
[killerid] += healthtransfer
                client_print
(killerid,print_chat,"[OK] (%d)  +%d blood for killing %s.",g_bhealth[killerid],healthtransfer,victimname)
                
client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
                
DisplayHud(victimid)
                
DisplayHud(killerid)
            }
            else
            {
                
g_bhealth[killerid] = (get_pcvar_num(amx_ok_bb_cap))
                
client_print(killerid,print_chat,"[OK] You could not gain any more Blood, because your current bank is full(%d)!",(get_pcvar_num(amx_ok_bb_cap)))
                
g_bhealth[victimid] -= healthloss
                g_bhealth
[killerid] = (get_pcvar_num(amx_ok_bb_cap))
                
client_print(victimid,print_chat,"[OK] (%d) -%d blood.",g_bhealth[victimid],healthloss)
                
DisplayHud(victimid)
                
DisplayHud(killerid)
            }
        }
    }
    else
    {
        
client_print(killerid,print_chat,"[OK] No blood rewarded, because blood bank is disabled")
        
    }
    return 
PLUGIN_CONTINUE 


edit: even though there is a tag mismatch, all seems to be functioning properly

grimvh2 05-10-2010 16:35

Re: tag mismatch on line 359
 
PHP Code:

 new Float:maxreward float(get_pcvar_num(amx_ok_max))

// you can also do

get_pcvar_float(UrCvar


ConnorMcLeod 05-10-2010 16:42

Re: tag mismatch on line 359
 
I guess the error is on line :

new healthloss = g_bhealth[victimid]/2.5

I don't think you can divide an integer by a float.

Try :

new healthloss = (g_bhealth[victimid]*10)/25

KadiR 05-10-2010 17:56

Re: tag mismatch on line 359
 
You look ugly Connor. :roll:

[/offtopic]

SnoW 05-11-2010 09:18

Re: tag mismatch on line 359
 
Quote:

Originally Posted by ConnorMcLeod (Post 1176737)
I guess the error is on line :

new healthloss = g_bhealth[victimid]/2.5

I don't think you can divide an integer by a float.

Try :

new healthloss = (g_bhealth[victimid]*10)/25

False.

PHP Code:

stock Float:operator/(oper1Float:oper2)
     return 
floatdiv(float(oper1), oper2); 


ConnorMcLeod 05-11-2010 11:42

Re: tag mismatch on line 359
 
That's what i say :

floatdiv returns a Float, so

new healthloss

should be

new Float:healthloss

Exolent[jNr] 05-11-2010 13:04

Re: tag mismatch on line 359
 
Quote:

Originally Posted by SnoW (Post 1177252)
False.

PHP Code:

stock Float:operator/(oper1Float:oper2)
     return 
floatdiv(float(oper1), oper2); 


:roll:

HLM 05-11-2010 15:46

Re: tag mismatch on line 359
 
okay, thanks everyone I got it fixed, and ConnorMcLeod... your picture is very.... good..


All times are GMT -4. The time now is 03:38.

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