AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Fix error pev (https://forums.alliedmods.net/showthread.php?t=282989)

Apb hq 05-22-2016 05:56

Fix error pev
 
Can someone help me to fix those errors
Error:
Code:

L 05/22/2016 - 11:43:03: [AMXX] Displaying debug trace (plugin "guns_new.amxx")
L 05/22/2016 - 11:43:03: [AMXX] Run time error 10: native error (native "pev")
L 05/22/2016 - 11:43:03: [AMXX]    [0] guns_new.sma::fw_touch (line 300)

Here is the code
PHP Code:

public fw_touch(bulletent)
{
    new class[
20];
    
pev(bulletpev_classname, class, 19);
    if (!
equali(class, "pbBullet"))
        return 
FMRES_IGNORED;

    new 
Float:origin[3], class2[20], owner pev(bulletpev_owner), is_ent_alive is_user_alive(ent);
    
pev(entpev_classnameclass219);
    
pev(bulletpev_originorigin);

    if (
is_ent_alive)
    {
        if (
owner == ent || pev(entpev_takedamage) == DAMAGE_NO)
            return 
FMRES_IGNORED;
        if (
get_user_team(owner) == get_user_team(ent))
            if (!
get_pcvar_num(friendlyfire))
                return 
FMRES_IGNORED;

        
ExecuteHam(Ham_TakeDamageentownerownerfloat(get_pcvar_num(damge)), 4098);
    }

    if (!
equali(class, class2))
    {    
        
set_pev(bulletpev_velocityFloat:{0.00.00.0});
        
set_pev(bulletpev_classname"pbPaint");
        
set_pev(bulletpev_solid0);
        
set_pev(bulletpev_movetype0);
        
engfunc(EngFunc_SetModelbullet"sprites/paintball.spr");

        new 
afindpb 0;
        while (
a++ < g_pbcount && !findpb)
            if (
g_paintballs[a] == bullet)
                
findpb g_pbstatus[a] = 2;

        
remove_task(bullet);
        
remove_task(bullet+TASK_PB_RESET);

        if (
get_pcvar_num(sound))
        {
            static 
wav[20];
            
formatex(wav20is_ent_alive "player/pl_pain%d.wav" "misc/pb%d.wav"is_ent_alive random_num(4,7) : random_num(1,4));
            
emit_sound(bulletCHAN_AUTOwav1.0ATTN_NORM0PITCH_NORM);
        }

        new 
bool:valid_surface = (is_ent_alive || containi(class2"door") != -1) ? false true;
        if (
pev(entpev_health) && !is_ent_alive)
        {
            
ExecuteHam(Ham_TakeDamageentownerownerfloat(pev(entpev_health)), 0);
            
valid_surface false;
        }
        if (
valid_surface)
        {
            
paint_splat(bullet);
            
set_task(float(get_pcvar_num(blife)), "paint_reset"bullet+TASK_PB_RESET);
        }
        else
            
paint_reset(bullet+TASK_PB_RESET);

        return 
FMRES_HANDLED
    }

    return 
FMRES_IGNORED;



siriusmd99 05-22-2016 06:24

Re: Fix error pev
 
Before you start doing something you shall check if entity is valid , just put this before new class:

if(!pev_valid(bullet) || !pev_valid(ent))
return FMRES_IGNORED;

Apb hq 05-22-2016 07:51

Re: Fix error pev
 
Man i have done this before but i get this bug on the server look at those pictures you should see a paint splat not paintball balls blocked in wall
Your edit bug:
http://i.imgur.com/V0HP7bI.png

What i should obtain when i shoot at the wall
http://i.imgur.com/5Z8kO3i.png

siriusmd99 05-22-2016 15:56

Re: Fix error pev
 
Sorry, i was confused. Wall will return true...

Put this only :

Quote:

if(!pev_valid(bullet))
return FMRES_IGNORED;

Apb hq 05-22-2016 16:42

Re: Fix error pev
 
Thanks man problem solved :P


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

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