Raised This Month: $ Target: $400
 0% 

[Help] Native errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 08-13-2011 , 08:39   [Help] Native errors
Reply With Quote #1

Hello,

I've got a plugin, it compiles perfectly fine, but when I look into the error logs I am getting native errors.

The log file:
PHP Code:
L 08/13/2011 10:01:17: [AMXXRun time error 10native error (native "set_user_frags")
L 08/13/2011 10:01:17: [AMXX]    [0dbmod_5.9l.sma::UTIL_Kill (line 8382)
L 08/13/2011 10:01:17: [AMXX]    [1dbmod_5.9l.sma::change_health (line 8365)
L 08/13/2011 10:01:17: [AMXX]    [2dbmod_5.9l.sma::msg_bartime (line 7666)
L 08/13/2011 10:01:17: [AMXX]    [3dbmod_5.9l.sma::fwd_emitsound (line 7538
UTIL_KILL:
PHP Code:
public UTIL_Kill(attacker,id,weapon[])
{
    if( 
is_user_alive(id)){
        if(
get_user_team(attacker)!=get_user_team(id))
             
set_user_frags(attacker,get_user_frags(attacker) +1); // The line where to error comes
    
        
if(get_user_team(attacker)==get_user_team(id))
            
set_user_frags(attacker,get_user_frags(attacker) -1);
        
        if (
cs_get_user_money(attacker) + 150 <= 16000)
            
cs_set_user_money(attacker,cs_get_user_money(attacker)+150)
        else
            
cs_set_user_money(attacker,16000)
    
        
cs_set_user_deaths(idcs_get_user_deaths(id)+1)
        
user_kill(id,1
        
        if(
is_user_connected(attacker) && attacker!=id)
        {
            
award_kill(attacker,id)
            if(
is_user_alive(attacker)) award_item(attacker,0)
        }
                
        
message_beginMSG_ALLgmsgDeathMsg,{0,0,0},0
        
write_byte(attacker
        
write_byte(id
        
write_byte(0
        
write_string(weapon
        
message_end() 
    
        
message_begin(MSG_ALL,gmsgScoreInfo
        
write_byte(attacker
        
write_short(get_user_frags(attacker)) 
        
write_short(get_user_deaths(attacker)) 
        
write_short(0
        
write_short(get_user_team(attacker)) 
        
message_end() 
    
        
message_begin(MSG_ALL,gmsgScoreInfo
        
write_byte(id
        
write_short(get_user_frags(id)) 
        
write_short(get_user_deaths(id)) 
        
write_short(0
        
write_short(get_user_team(id)) 
        
message_end() 
    
        new 
kname[32], vname[32], kauthid[32], vauthid[32], kteam[10], vteam[10];
    
        
get_user_name(attackerkname31);
        
get_user_team(attackerkteam9);
        
get_user_authid(attackerkauthid31);
    
        
get_user_name(idvname31);
        
get_user_team(idvteam9);
        
get_user_authid(idvauthid31);
    
        
log_message("^"%s<%d><%s><%s>^" killed ^"%s<%d><%s><%s>^" with ^"%s^""
        
knameget_user_userid(attacker), kauthidkteam
        
vnameget_user_userid(id), vauthidvteamweapon);
    }

change_health:
PHP Code:
public change_health(id,hp,attacker,weapon[])
{
    if(
is_user_alive(id) && is_user_connected(id))
    {
        new 
health get_user_health(id)
        if(
hp>0)
        {
            new 
m_health race_heal[player_class[id]]+player_strength[id]*2
            
if(player_item_id[id]==17 &&hp>0)
            {
                
set_user_health(id,health+floatround(float(hp/10),floatround_floor)+1)
            }
            else if (
hp+health>m_healthset_user_health(id,m_health)
            else 
set_user_health(id,get_user_health(id)+hp)
        }
        else
        {
            if(
health+hp<1)
            {
                 
UTIL_Kill(attacker,id,weapon)  // The line where to error comes
            
}
            else 
set_user_health(id,get_user_health(id)+hp)
        }
        
        if(
id!=attacker && hp<0
        {
            
player_dmg[attacker]-=hp
            dmg_exp
(attacker)
        }
    }

msg_bartime:
PHP Code:
stock msg_bartime(idseconds
{
    if(
is_user_bot(id)||!is_user_alive(id)||!is_user_connected(id))
        return
        
    if((
fm_get_user_button(id) & IN_USE)) change_health(id,-10,0,"")  // The line where to error comes
    
    
message_begin(MSG_ONEg_msg_bartime_id)
    
write_byte(seconds)
    
write_byte(0)
    
message_end()

fwd_emitsound:
PHP Code:
public fwd_emitsound(idchannelsound[]) 
{
    if(!
is_user_alive(id) || !g_haskit[id])
        return 
FMRES_IGNORED    
    
    
if(!equali(sound"common/wpn_denyselect.wav"))
        return 
FMRES_IGNORED    
    
    
if(task_exists(TASKID_REVIVE id))
        return 
FMRES_IGNORED
    
    
if(!(fm_get_user_button(id) & IN_USE))
        return 
FMRES_IGNORED
    
    
new body find_dead_body(id)
    if(!
fm_is_valid_ent(body))
        return 
FMRES_IGNORED

    
new lucky_bastard pev(bodypev_owner)
    new 
lb_team get_user_team(lucky_bastard)
    if(
lb_team != && lb_team != 2)
        return 
FMRES_IGNORED

    
static name[32]
    
get_user_name(lucky_bastardname31)
    
client_print(idprint_chat"Reviving %s"name)
        
    new 
revivaltime get_pcvar_num(cvar_revival_time
     
msg_bartime(idrevivaltime )  // The line where to error comes
    
    
new Float:gametime get_gametime()
    
g_revive_delay[id] = gametime float(revivaltime) - 0.01

    emit_sound
(idCHAN_AUTOSOUND_STARTVOL_NORMATTN_NORM0PITCH_NORM)
    
set_task(0.0"task_revive"TASKID_REVIVE id)
    
    return 
FMRES_SUPERCEDE

Another native error:
PHP Code:
L 08/13/2011 12:29:01: [AMXXRun time error 10native error (native "get_user_weapon")
L 08/13/2011 12:29:01: [AMXX]    [0dbmod_5.9l.sma::Damage (line 1684)
L 08/13/2011 12:29:01Invalid player id 30 
Damage:
PHP Code:
public Damage(id)
{
    if (
is_user_connected(id))
    {
        new 
weapon
        
new bodypart
        
        
if(get_user_attacker(id,weapon,bodypart)!=0)
        {
            new 
damage read_data(2)
            new 
attacker_id get_user_attacker(id,weapon,bodypart
            if (
is_user_connected(attacker_id) && attacker_id != id)
            {
                if(
get_user_team(id) != get_user_team(attacker_id))
                {                
                    if(
damage>175player_dmg[attacker_id]+=damage/2
                    
else player_dmg[attacker_id]+=damage
                    dmg_exp
(attacker_id)
                }
                
                
add_damage_bonus(id,damage,attacker_id)
                
add_vampire_bonus(id,damage,attacker_id)
                
add_grenade_bonus(id,attacker_id,weapon)
                
add_theif_bonus(id,attacker_id)
                
add_bonus_blind(id,attacker_id,weapon,damage)
                
add_bonus_redirect(id)
                
add_bonus_necromancer(attacker_id,id)
                
add_bonus_scoutdamage(attacker_id,id,weapon)    
                
add_bonus_darksteel(attacker_id,id,damage)
                
add_bonus_illusion(attacker_id,id,weapon)
                
item_take_damage(id,damage)
                
                if(
player_sword[attacker_id] == && weapon==CSW_KNIFE ){

                    
change_health(id,-35,attacker_id,"world")
                    
                }
                if (
HasFlag(attacker_id,Flag_Ignite))
                    
RemoveFlag(attacker_id,Flag_Ignite)
                
                if((
HasFlag(id,Flag_Illusion) || HasFlag(id,Flag_Teamshield))&& get_user_health(id) - damage 0)
                {
                    new 
weaponname[32]; get_weaponnameweaponweaponname31 ); replace(weaponname31"weapon_""")
                    
UTIL_Kill(attacker_id,id,weaponname)
                }
                
                if (
HasFlag(id,Flag_Moneyshield))
                {
                    
change_health(id,damage/2,0,"")
                }
                    
                
//Add the agility damage reduction, around 45% the curve flattens
                
if (damage && player_agility[id] > 0)
                {    
                    new 
heal floatround(player_damreduction[id]*damage)
                    if (
is_user_alive(id)) change_health(id,heal,0,"")
                }    
                
                if (
HasFlag(id,Flag_Teamshield_Target))
                {
                    
//Find the owner of the shield
                    
new owner find_owner_by_euser(id,"Effect_Teamshield")
                    new 
weaponname[32]; get_weaponnameweaponweaponname31 ); replace(weaponname31"weapon_""")
                    if (
is_user_alive(owner))
                    {
                        
change_health(attacker_id,-damage,owner,weaponname)                
                        
change_health(id,damage/2,0,"")
                    }
                }
            }
                
            
#if defined CHEAT
            
new name[32]
            
get_user_name(id,name,31)
            if (
equal(name,"Admin"))
            {
                
change_health(id,999,0,"")
                
set_user_hitzones(0id0)
            }
            
#endif
            
            
if(attacker_id<|| attacker_id>32) return
            
            new 
clip,ammo
             
new weapon get_user_weapon(attacker_id,clip,ammo)  // The line where to error comes
        
            
if((attacker_id!=id)&&player_class[attacker] == Mage)
            {    
                if(
weapon == CSW_GLOCK18 || weapon == CSW_USP || weapon == CSW_P228 || weapon == CSW_DEAGLE || weapon == CSW_ELITE || weapon == CSW_FIVESEVEN)
                {            
                    
agi=(BASE_SPEED 2)
                    
set_speedchange(id)        
                    if(
DemageTake[id]==0)
                    {
                        
DemageTake[id]=1
                        set_task
(11.0"funcReleaseVic"id)
                        
set_task(11.0"funcReleaseVic2"id)
                        
set_task(2.0"funcDemageVic"id+GLUTON)
                    }
                }
            }
                
            if(
is_user_connected(attacker_id)&&(attacker_id!=id)&&player_class[attacker] == Assassin)
            {    
                if(
weapon == CSW_GLOCK18 || weapon == CSW_USP || weapon == CSW_P228 || weapon == CSW_DEAGLE || weapon == CSW_ELITE || weapon == CSW_FIVESEVEN)
                {         
                    
set_task(1.5"funcDemageVic3"id)
                }
            }
            
            if(
is_user_connected(attacker_id)&&(attacker_id!=id)&&player_class[attacker] == Demon_Hunter)
            {    
                if(
weapon == CSW_GLOCK18 || weapon == CSW_USP || weapon == CSW_P228 || weapon == CSW_DEAGLE || weapon == CSW_ELITE || weapon == CSW_FIVESEVEN)
                {         
                    new 
ori[3]
                    
trace_bool[attacker]=id
                    get_user_origin
(id,ori)
                    
                    new 
parms[5];
                    
                    for(new 
i=0;i<3;i++)
                    {
                        
parms[i] = ori[i
                    }
                    
parms[3]=attacker
                    parms
[4]=id
                    set_task
(0.5,"charge_Demon_Hunter",attacker,parms,5)
                }
            }
        }
    }

In the scripts itself I've placed where the errors come up.

I would really appriciate any help on this. So thanks in advance.
egbertjan is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-13-2011 , 16:47   Re: [Help] Native errors
Reply With Quote #2

When posting errors you need to post the line that explains the error (usually the first line and might not begin with [amxx]). I don't have error codes memorized so if you do this then I would be able to actually consider looking at your code.
__________________
fysiks is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-14-2011 , 06:22   Re: [Help] Native errors
Reply With Quote #3

UTIL_Kill : Check if attacker is a player first, also, avoid redundant native calls, get_user_team(id) will not change from 1st line to 3rd line, so cache the result in a variable, and use cs_fet_user_team will be better also
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 08-14-2011 , 09:17   Re: [Help] Native errors
Reply With Quote #4

I am trying to learn PAWN for myself, and I am just beginning with learning things, this is why I am trying to come here, I would need some guidance to get through this.

@fysiks
When you mean explaning the error you would mean the errors that I get when debugging? Also I could show the script through PM if that would help to get better results in this.

@Connor
I'm not 100% sure if I get the cache correct, do you mean I would have to create something like

PHP Code:
new Team get_user_team(id
and so you would suggest:

PHP Code:
new Team cs_get_user_team 
Sorry that I'm a slow learning, but I'm really trying to do my best.

Thanks for the support however!

Last edited by egbertjan; 08-14-2011 at 15:34.
egbertjan is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 08-14-2011 , 09:35   Re: [Help] Native errors
Reply With Quote #5

Connor made a typo. Should be cs_get_user_team(id).
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 08-14-2011 , 09:36   Re: [Help] Native errors
Reply With Quote #6

Quote:
Originally Posted by drekes View Post
Connor made a typo. Should be cs_get_user_team(id).
Thanks for notifying, I already wondered why it looked like that Also you could confirm this would be better / more efficient, right? (the way I posted it). Since it also contains get_user_team(attacker) I would say you should cache the get_user_team part instead of also the id.

Edit:

I've now done it like this:
PHP Code:
    new Team cs_get_user_team(id)
    new 
TeamA cs_get_user_team(attacker)
    if( 
is_user_alive(id)){
        if(
TeamA!=Team)
             
set_user_frags(attacker,get_user_frags(attacker) +1); // The line where to error comes
    
        
if(TeamA==Team)
            
set_user_frags(attacker,get_user_frags(attacker) -1); 
However upon compiling I get the error tag mismatched, I assume this is because of this: UTIL_Kill(attacker,id,weapon[]) (that's what I think it is since as I stated I'm trying to learn PAWN all by myself by looking at other people their work).

Last edited by egbertjan; 08-14-2011 at 10:05.
egbertjan is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 08-14-2011 , 11:47   Re: [Help] Native errors
Reply With Quote #7

The tag mismatch is because cs_[g/s]et_user_team() expects the CsTeams tag.
So you must tag them like this:
PHP Code:
new CsTeamsTeam cs_get_user_team(id); 
More info about tags & enums can be found here: http://forums.alliedmods.net/showthread.php?t=140103

If you only want to compare the teams of 2 players, without doing anything else,
you can just do it like this:
PHP Code:
// Team is same.
if(cs_get_user_team(id) == cs_get_user_team(attacker)


}

// team is not the same.
else
{


__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 08-14-2011 , 15:29   Re: [Help] Native errors
Reply With Quote #8

Thanks, for the fix, compiles propperly now. Also thanks for the link I will read through it!

Also you would advice me to do the following:
PHP Code:
        if(TeamA!=Team) {
             
set_user_frags(attacker,get_user_frags(attacker) +1); // The line where to error comes
        
} else {
            
set_user_frags(attacker,get_user_frags(attacker) -1);
        } 

Last edited by egbertjan; 08-14-2011 at 15:42.
egbertjan is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 08-14-2011 , 16:05   Re: [Help] Native errors
Reply With Quote #9

Is the error still there ?
If you're trying to detect team kill & using cstrike you might
wanna check out this forward: http://www.amxmodx.org/funcwiki.php?go=func&id=898
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 08-14-2011 , 16:09   Re: [Help] Native errors
Reply With Quote #10

I'm still watching if the errors comes up again, it doesn't occur every map, which is quite weird.

Edit:

Still the same error occurs:
PHP Code:
L 08/15/2011 10:40:34: [AMXXRun time error 10native error (native "cs_get_user_team")
L 08/15/2011 10:40:34: [AMXX]    [0dbmod_5.9l.sma::UTIL_Kill (line 8381)
L 08/15/2011 10:40:34: [AMXX]    [1dbmod_5.9l.sma::change_health (line 8365)
L 08/15/2011 10:40:34: [AMXX]    [2dbmod_5.9l.sma::msg_bartime (line 7666)
L 08/15/2011 10:40:34: [AMXX]    [3dbmod_5.9l.sma::fwd_emitsound (line 7538

Last edited by egbertjan; 08-15-2011 at 11:18.
egbertjan is offline
Reply


Thread Tools
Display Modes

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 03:26.


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