AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bug with my plugin (https://forums.alliedmods.net/showthread.php?t=223308)

Randomize 08-12-2013 03:47

Bug with my plugin
 
I have created bomb with entity to be thrown and explode when I dectonate it such as satchel charge. It works fine if I'm alone, but If there's a player who uses that item too the bug happens. I throw my bomb and he throw his bomb, when I dectonate mine it don't want to explode. But when he dectonate his, his bomb explodes.

Here is part of my code:
PHP Code:

public explode_bomb(id)
{
    if(!
is_valid_ent(id) || !is_valid_ent(c5_entity))
        return 
PLUGIN_CONTINUE
        
    
if(!is_user_connected(id) || !is_user_alive(id))
        return 
PLUGIN_CONTINUE

    
new Float:fOrigin[3]
    new 
iOrigin[3]
    
    
entity_get_vector(c5_entityEV_VEC_originfOrigin)
    new 
g_owner entity_get_edict(c5_entityEV_ENT_owner)
    
    
client_printidprint_chat"%i %s"g_ownerg_owner)
    
    new 
g_players[32], g_playersnumx
    get_players
(g_playersg_playersnum"a")
    
    
FVecIVec(fOriginiOrigin)
    
    if (
g_has_planted[id])
    {
        if (
g_owner == id)
        {
            for(
0<= g_playersnumx++)
            {
                new 
g_players[x]
                
                if(!
is_user_connected(i)) continue
                
                new 
g_distance floatround(entity_range(c5_entityi))
        
                if (
g_distance <= get_pcvar_num(g_radius)) //c5 distance between player less equal with c5 radius
                
{
                    if(
get_user_team(id) != get_user_team(i))
                    {
                        if((
get_user_health(i) - get_pcvar_num(g_damage)) <= 0)
                        {
                            
user_silentkill(i)
                            
emit_sound(idCHAN_AUTOg_c5_kill1.0ATTN_NORM0PITCH_NORM)
                            
make_deathmsg(idi0"c5")
                            
cs_set_user_money(idcs_get_user_money(id) + get_pcvar_num(g_reward))
                            
set_user_frags(idget_user_frags(id) + 1)
                        }
                        else
                        {
                            
set_user_health(iget_user_health(i) - get_pcvar_num(g_damage))
                            
emit_sound(idCHAN_AUTOg_c5_kill1.0ATTN_NORM0PITCH_NORM)
                        }
                    }
                }
            }
            
message_begin(MSG_BROADCASTSVC_TEMPENTITYiOrigin)
            
write_byte (TE_EXPLOSION)
            
write_coord(iOrigin[0])
            
write_coord(iOrigin[1])
            
write_coord(iOrigin[2])
            
write_short(explode)
            
write_byte (30)
            
write_byte (15)
            
write_byte (0)
            
message_end()
            
            
message_begin(MSG_BROADCASTSVC_TEMPENTITYiOrigin)
            
write_byte (TE_SMOKE)
            
write_coord(iOrigin[0])
            
write_coord(iOrigin[1])
            
write_coord(iOrigin[2])
            
write_short(smoke)
            
write_byte (100)
            
write_byte (15)
            
message_end()
            
            
cs_set_user_bpammo(idCSW_HEGRENADE0)
            
emit_sound(idCHAN_AUTOg_c5_sound[4], 1.0ATTN_NORM0PITCH_NORM)
            
remove_entity(c5_entity)
            
            
g_has_planted[id] = false
            g_has_dectonator
[id] = false
            g_bought
[id] = false
            
return PLUGIN_HANDLED
        
}
        return 
PLUGIN_HANDLED
    
}    
    return 
PLUGIN_HANDLED



red_bull2oo6 08-12-2013 04:41

Re: Bug with my plugin
 
is the c5_entity a global variable?
if it is make it c5_entity[ 33 ]; and use c5_entity[ id ].
i think that entities ids are getting confused :-?

its hard to find the bug without complete code.

Randomize 08-12-2013 06:39

Re: Bug with my plugin
 
Okay I'll try, I don't want to put complete code here. I may send via PM if you can help me.

EDIT: Hey it solved my problem! Thanks redbull.


All times are GMT -4. The time now is 15:59.

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