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

[REQ] Plugin crashes on use


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wiwi249
Member
Join Date: Oct 2013
Old 12-14-2013 , 17:52   [REQ] Plugin crashes on use
Reply With Quote #1

Hello!
I was trying to make a C4 for my mod. Once you press USE, a C4 pack appears on the ground. When you press it again, it explodes.
It works well but sometimes it crashes and I have no idea why. Can someone rescribe me the function to make it well working?

PHP Code:
public Bug_Ciche_Chodzenie(id
{
    new 
szNoMines[128], szNoC4[128];
    
formatex(szNoMinescharsmax(szNoMines), "%L"LANG_PLAYER"MSG_NOMINES");
    
formatex(szNoC4charsmax(szNoC4), "%L"LANG_PLAYER"MSG_NOC4");
    
    
        if(
is_user_alive(id)) 
        {
                new 
Float:fVector[3];
                
pev(idpev_velocityfVector);
                new 
FloatfSpeed floatsqroot(fVector[0]*fVector[0]+fVector[1]*fVector[1]+fVector[2]*fVector[2]);
                if((
fm_get_user_maxspeed(id) * 5) > (fSpeed*9))
                        
set_pev(idpev_flTimeStepSound300);
            
            
    if(
is_user_alive(id)){
    new 
buttons pev(idpev_button// buttons in current frame
    
new oldbuttons pev(idpev_oldbuttons// buttons in previous frame
    
if( buttons IN_USE && !(oldbuttons IN_USE))
    {
    if(
equipment2[id] == 6)
    {
        if (!
ilosc_min_gracza[id])
        {
            
client_print(idprint_centerszNoMines);
        }
        else
        {
            new 
Float:origin[3];
            
entity_get_vector(idEV_VEC_originorigin);
    
            new 
ent create_entity("info_target");
            
entity_set_string(ent ,EV_SZ_classname"claymore");
            
entity_set_edict(ent ,EV_ENT_ownerid);
            
entity_set_int(entEV_INT_movetypeMOVETYPE_TOSS);
            
entity_set_origin(entorigin);
            
entity_set_int(entEV_INT_solidSOLID_BBOX);
    
            
entity_set_model(entmodelMiny);
            
entity_set_size(ent,Float:{-16.0,-16.0,0.0},Float:{16.0,16.0,2.0});
    
            
drop_to_floor(ent);
            
ilosc_min_gracza[id]--;
        }
    }
    else if(
equipment2[id] == 4)
    {
        if(!
ilosc_dynamitow_gracza[id])
        {
            
client_print(idprint_centerszNoC4);
        }
        else{
        {
            static 
dynamit_gracza[33];
            if(
is_valid_ent(dynamit_gracza[id]))
            {
                
ilosc_dynamitow_gracza[id]--;
                
                new 
Float:fOrigin[3];
                
entity_get_vector(dynamit_gracza[id], EV_VEC_originfOrigin);
                
                new 
iOrigin[3];
                for(new 
i=0;i<3;i++)
                    
iOrigin[i] = floatround(fOrigin[i]);
                
                
message_begin(MSG_BROADCAST,SVC_TEMPENTITYiOrigin);
                
write_byte(TE_EXPLOSION);
                
write_coord(iOrigin[0]);
                
write_coord(iOrigin[1]);
                
write_coord(iOrigin[2]);
                
write_short(sprite_blast_dynamit);
                
write_byte(32);
                
write_byte(20);
                
write_byte(0);
                
message_end();
                
                
message_beginMSG_BROADCASTSVC_TEMPENTITYiOrigin );
                
write_byteTE_BEAMCYLINDER );
                
write_coordiOrigin[0] );
                
write_coordiOrigin[1] );
                
write_coordiOrigin[2] );
                
write_coordiOrigin[0] );
                
write_coordiOrigin[1] + 250 );
                
write_coordiOrigin[2] + 250 );
                
write_shortsprite_white_dynamit );
                
write_byte);
                
write_byte);
                
write_byte10 );
                
write_byte10 );
                
write_byte255 );
                
write_byte255 );
                
write_byte100 );
                
write_byte100 );
                
write_byte128 );
                
write_byte);
                
message_end();
                
                new 
entlist[33];
                new 
numfound find_sphere_class(dynamit_gracza[id], "player"250.0 entlist32);
                new 
pid;
                for (new 
i=0i<numfoundi++)
                {               
                    
pid entlist[i];
                    if (
is_user_alive(pid))
                        
ExecuteHamB(Ham_TakeDamagepiddynamit_gracza[id], id200.0, (1<<24));
                }
                
remove_entity(dynamit_gracza[id]);
            }
            else
            {
            
                new 
Float:origin[3];
                
entity_get_vector(idEV_VEC_originorigin);
                
                
dynamit_gracza[id] = create_entity("info_target");
                
entity_set_string(dynamit_gracza[id], EV_SZ_classname"C4");
                
entity_set_edict(dynamit_gracza[id], EV_ENT_ownerid);
                
entity_set_int(dynamit_gracza[id], EV_INT_movetypeMOVETYPE_TOSS);
                
entity_set_origin(dynamit_gracza[id], origin);
                
entity_set_int(dynamit_gracza[id], EV_INT_solidSOLID_BBOX);
                
                
entity_set_model(dynamit_gracza[id], "models/wiwi249_bf3/w_c4.mdl");
                
entity_set_size(dynamit_gracza[id], Float:{-16.0,-16.0,0.0}, Float:{16.0,16.0,2.0});
                
                
drop_to_floor(dynamit_gracza[id]);
            }
        }
    }
    }
}
}
}

Bug_Ciche_Chodzenie is a Fakemeta Client_PreThink function.
Regs, looking forward for your help.

Last edited by wiwi249; 12-14-2013 at 17:53.
wiwi249 is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 12-14-2013 , 20:53   Re: [REQ] Plugin crashes on use
Reply With Quote #2

You should not use prethink for this, use
PHP Code:
register_forward(FM_CmdStart"eventCmdStart"
instead
mottzi is offline
Send a message via MSN to mottzi
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 23:17.


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