Raised This Month: $51 Target: $400
 12% 

Error while compiling


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Yeoo
Junior Member
Join Date: Nov 2020
Old 12-13-2023 , 12:44   Error while compiling
Reply With Quote #1

Can someone solve this ?
Ty.

(2 8 ) : error 033: array must be indexed (variable "cvars")

PHP Code:
#include <amxmodx>
#include <hamsandwich>

native strip_user_weapons(index);

native cs_get_user_hasprim(index);
native cs_get_user_buyzone(index);

new 
cvars[4];

new const 
name_cvars[][][] =
{
    {
"surf_delete_corpse""1"},
    {
"surf_buyzone_kill""0"},
    {
"surf_superwalls""1"},
    {
"surf_strip_sec_weapons""1"}
}

public 
plugin_init()
{
    
register_plugin("Surf Addon""1.1""cyby");
    
    
RegisterHam(Ham_TakeDamage"player""ham_take_damage");
    
RegisterHam(Ham_TraceAttack"player""ham_trace_attack");
    
RegisterHam(Ham_Killed"player""killed_player");
    
    for(new 
0sizeof name_cvarsi++)
    
cvars register_cvar(name_cvars[0], name_cvars[1]);
    
    if(
get_pcvar_num(cvars[0]) > 0)
        
set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET);
}

public 
ham_take_damage(vicinfattFloat:dmgdmgbits)
{
    if(!
is_user_alive(att) || att == vic || !is_user_alive(vic))
        return 
HAM_IGNORED;
        
    if(
get_pcvar_num(cvars[1]) == 0)
    {
        if(
get_user_team(att) != get_user_team(vic))
        {
            if(
cs_get_user_buyzone(att))
            {
                
client_print(attprint_center"You can't attack here!");
                return 
HAM_SUPERCEDE;
            }
            
            if(
cs_get_user_buyzone(vic))
                return 
HAM_SUPERCEDE;
        }
    }
    
    if(
get_pcvar_num(cvars[2]) > 0)
    {
        if(!(
dmgbits & (1<<1)))
            return 
HAM_IGNORED;
        
        if(!
get_isplayer(att))
            return 
HAM_SUPERCEDE;
    }
    return 
HAM_IGNORED;
}

public 
ham_trace_attack(vicattFloat:dmgFloat:vecdr[3], trdmgbits)
{
    if(!
is_user_alive(vic) || !is_user_alive(att))
        return 
HAM_IGNORED;
        
    if(
get_pcvar_num(cvars[1]) == 0)
    {
        if(
get_user_team(att) != get_user_team(vic))
        {
            if(
cs_get_user_buyzone(att))
                return 
HAM_SUPERCEDE;
            
            if(
cs_get_user_buyzone(vic))
                return 
HAM_SUPERCEDE;
        }
    }
    
    if(
get_pcvar_num(cvars[2]) > 0)
    {
        if(!(
dmgbits & (1<<1)))
            return 
HAM_IGNORED;
            
        if(!
get_isplayer(att))
            return 
HAM_SUPERCEDE;
    }
    
    return 
HAM_IGNORED;
}

public 
killed_player(victim)
{
    if(
get_pcvar_num(cvars[3]) > 0)
    {
        if(!
is_user_connected(victim))
            return 
HAM_IGNORED;
            
        if(!
cs_get_user_hasprim(victim))
            
strip_user_weapons(victim);
    }
    return 
HAM_IGNORED;
}

stock bool:get_isplayer(attacker)
{
    new 
victimcrap;
    
get_user_aiming(attackervictimcrap);
    if(!
is_user_alive(victim))
        return 
false;
        
    return 
true;


Last edited by Yeoo; 12-13-2023 at 12:45.
Yeoo is offline
Siska1
Senior Member
Join Date: Feb 2020
Location: BedRock
Old 12-13-2023 , 14:56   Re: Error while compiling
Reply With Quote #2

See if it works as it should :

Code:
#include <amxmodx>
#include <hamsandwich>

native strip_user_weapons(index);

native cs_get_user_hasprim(index);
native cs_get_user_buyzone(index);

new cvars[4];

new const name_cvars[][][] =
{
    {"surf_delete_corpse", "1"},
    {"surf_buyzone_kill", "0"},
    {"surf_superwalls", "1"},
    {"surf_strip_sec_weapons", "1"}
};

public plugin_init()
{
    register_plugin("Surf Addon", "1.1", "cyby");

    RegisterHam(Ham_TakeDamage, "player", "ham_take_damage");
    RegisterHam(Ham_TraceAttack, "player", "ham_trace_attack");
    RegisterHam(Ham_Killed, "player", "killed_player");

    for (new i = 0; i < sizeof name_cvars; i++)
        cvars[i] = register_cvar(name_cvars[i][0], name_cvars[i][1]);

    if (get_pcvar_num(cvars[0]) > 0)
        set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET);
}

public ham_take_damage(vic, inf, att, Float:dmg, dmgbits)
{
    if (!is_user_alive(att) || att == vic || !is_user_alive(vic))
        return HAM_IGNORED;

    if (get_pcvar_num(cvars[1]) == 0)
    {
        if (get_user_team(att) != get_user_team(vic))
        {
            if (cs_get_user_buyzone(att))
            {
                client_print(att, print_center, "You can't attack here!");
                return HAM_SUPERCEDE;
            }

            if (cs_get_user_buyzone(vic))
                return HAM_SUPERCEDE;
        }
    }

    if (get_pcvar_num(cvars[2]) > 0)
    {
        if (!(dmgbits & (1 << 1)))
            return HAM_IGNORED;

        if (!get_isplayer(att))
            return HAM_SUPERCEDE;
    }
    return HAM_IGNORED;
}

public ham_trace_attack(vic, att, Float:dmg, Float:vecdr[3], tr, dmgbits)
{
    if (!is_user_alive(vic) || !is_user_alive(att))
        return HAM_IGNORED;

    if (get_pcvar_num(cvars[1]) == 0)
    {
        if (get_user_team(att) != get_user_team(vic))
        {
            if (cs_get_user_buyzone(att))
                return HAM_SUPERCEDE;

            if (cs_get_user_buyzone(vic))
                return HAM_SUPERCEDE;
        }
    }

    if (get_pcvar_num(cvars[2]) > 0)
    {
        if (!(dmgbits & (1 << 1)))
            return HAM_IGNORED;

        if (!get_isplayer(att))
            return HAM_SUPERCEDE;
    }

    return HAM_IGNORED;
}

public killed_player(victim)
{
    if (get_pcvar_num(cvars[3]) > 0)
    {
        if (!is_user_connected(victim))
            return HAM_IGNORED;

        if (!cs_get_user_hasprim(victim))
            strip_user_weapons(victim);
    }
    return HAM_IGNORED;
}

stock bool:get_isplayer(attacker)
{
    new victim, crap;
    get_user_aiming(attacker, victim, crap);
    if (!is_user_alive(victim))
        return false;

    return true;
}
__________________
Siska1 is offline
Send a message via Skype™ to Siska1
Uzviseni Bog
Senior Member
Join Date: Jun 2020
Old 12-13-2023 , 19:29   Re: Error while compiling
Reply With Quote #3

HTML Code:
cvars = register_cvar(name_cvars[0], name_cvars[1]);
Change to
HTML Code:
cvars[i] = register_cvar(name_cvars[i][0], name_cvars[i][1]);
Uzviseni Bog is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-13-2023 , 20:44   Re: Error while compiling
Reply With Quote #4

You might want to look into learning the basics of arrays so that it will be easier for you to find and fix these types of issues yourself.
__________________
fysiks 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 14:01.


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