AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Crashed on explosion (https://forums.alliedmods.net/showthread.php?t=50486)

Cheap_Suit 01-27-2007 13:40

Crashed on explosion
 
I cant figure out why it is randomly crashing after the grenade has exploded.

PHP Code:


public grenade_throw(identwid)
{
    if(
fm_is_valid_ent(ent) && wid == CSW_HEGRENADE)
    {
        
set_pev(entpev_iuser11)
        
set_pev(entpev_iuser2get_user_team(id))
    }
}

public 
fwd_touch(entid)
{
    if(!
fm_is_valid_ent(ent) || !is_user_alive(id))
        return 
FMRES_IGNORED
    
    
new classname[STR_T]
    
pev(entpev_classnameclassname, (STR_T-1))
    
    if(
equali(classname"grenade"))
    {
        if(
pev(entpev_iuser1) != 1)
            return 
FMRES_IGNORED
        
        
if(get_user_team(id) == pev(entpev_iuser2))
            return 
FMRES_IGNORED
        
        set_pev
(entpev_iuser10)
        
set_pev(entpev_aimentid)
        
set_pev(entpev_movetypeMOVETYPE_FOLLOW)
        
set_pev(entpev_sequence0)
    }
    return 
FMRES_IGNORED
}

public 
fwd_think(ent)
{
    if(!
fm_is_valid_ent(ent))
        return 
FMRES_IGNORED
    
    
new classname[STR_T]
    
pev(entpev_classnameclassname, (STR_T-1))
    
    if(
equali(classname"grenade"))
    {
        if(
pev(entpev_iuser1) != 1)
            return 
FMRES_IGNORED
            
        
if(pev(entpev_flags) & FL_ONGROUND)
            return 
FMRES_IGNORED
        
        
static Float:nadeorigin[3]
        
pev(entpev_originnadeorigin)
        
        static 
players[32], num
        get_players
(playersnum"a")
        
        for(new 
0num; ++i)    
        {
            new 
id players[i]

            if(
get_user_team(id) == pev(entpev_iuser2))
                continue
                
            if(!
fm_is_ent_visible(entid))
                continue

            static 
Float:origin[3]
            
pev(idpev_originorigin)
            
            new 
Float:maxdistance get_pcvar_float(cvar_maxdis)
            new 
Float:distance get_distance_f(originnadeorigin)
            
            if(
distance maxdistance)
            {
                
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
                
write_byte(TE_BEAMFOLLOW)
                
write_short(ent)
                
write_short(sprite_trail)
                
write_byte(30)
                
write_byte(10)
                
write_byte(255)
                
write_byte(0)
                
write_byte(0)
                
write_byte(100)
                
message_end()
                
                
entity_set_follow(entidfloat(fm_get_speed(ent)))
            }
        }
    }
    return 
FMRES_IGNORED
}

stock entity_set_follow(entitytargetFloat:speed
{
    if(!
fm_is_valid_ent(entity) || !fm_is_valid_ent(target)) 
        return 
0

    
new Float:entity_origin[3], Float:target_origin[3]
    
pev(entitypev_originentity_origin)
    
pev(targetpev_origintarget_origin)

    new 
Float:diff[3]
    
diff[0] = target_origin[0] - entity_origin[0]
    
diff[1] = target_origin[1] - entity_origin[1]
    
diff[2] = target_origin[2] - entity_origin[2]

    new 
Float:length floatsqroot(floatpower(diff[0], 2.0) + floatpower(diff[1], 2.0) + floatpower(diff[2], 2.0))

    new 
Float:velocity[3]
    
velocity[0] = diff[0] * (speed length)
    
velocity[1] = diff[1] * (speed length)
    
velocity[2] = diff[2] * (speed length)

    
set_pev(entitypev_velocityvelocity)

    return 
1



Zenith77 01-27-2007 16:35

Re: Crashed on explosion
 
It crashes as soon as it explodes, and not when you throw it right? Are there anything in the logs, error messages coming up, etc?

Cheap_Suit 01-27-2007 16:41

Re: Crashed on explosion
 
Yep when it explodes. No logs because it crashed to my desktop. Plus seems crashing randomly.

XxAvalanchexX 01-27-2007 17:10

Re: Crashed on explosion
 
Comment out the entire "if(equali(classname,"grenade"))" block of your fwd_think and see if it still occurs.

Cheap_Suit 01-27-2007 17:55

Re: Crashed on explosion
 
Didnt help.

#edit
I think I track down the problem, I commented out my fwd_touch function and it stopped crashing.

Super Fantastic 06-26-2008 16:58

Re: Crashed on explosion
 
Sorry, I did not know that can not post here.
Not needed -karma.
:(


All times are GMT -4. The time now is 22:25.

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