AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with stock (https://forums.alliedmods.net/showthread.php?t=86580)

padilha007 02-27-2009 17:23

Problem with stock
 
i creat one stock to give/get weapons with Clip and Ammo but sometimes crash my server.

PHP Code:

stock fm_give_item_full(index, const item[], iWeaponclipammomodgetinfo
{
    if (
getinfo == 0)
    {
        if ( 
iWeapon == )
        {
            if (!
equal(item"weapon_"7) && !equal(item"ammo_"5) && !equal(item"item_"5) && !equal(item"tf_weapon_"10))    
                return 
0
            
            
new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocStringitem))
            if (!
pev_valid(ent))
                return 
0
            
            
new Float:origin[3]
            
pev(indexpev_originorigin)
            
set_pev(entpev_originorigin)
            
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN)
            
dllfunc(DLLFunc_Spawnent)
            
            if(
mod == 1)
            {
                
set_pdata_int(ent51clip4)
                
                static 
offset
                
                
new szWeapon[20]
                
pev(entpev_classnameszWeaponcharsmax(szWeapon))
                
                new 
iWeaponID
                iWeaponID 
get_weaponid(szWeapon)
                
                switch(
iWeaponID)
                {
                    case 
CSW_AWPoffset OFFSET_AWM_AMMO;
                    case 
CSW_SCOUT,CSW_AK47,CSW_G3SG1offset OFFSET_SCOUT_AMMO;
                    case 
CSW_M249offset OFFSET_PARA_AMMO;
                    case 
CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552offset OFFSET_FAMAS_AMMO;
                    case 
CSW_M3,CSW_XM1014offset OFFSET_M3_AMMO;
                    case 
CSW_USP,CSW_UMP45,CSW_MAC10offset OFFSET_USP_AMMO;
                    case 
CSW_FIVESEVEN,CSW_P90offset OFFSET_FIVESEVEN_AMMO;
                    case 
CSW_DEAGLEoffset OFFSET_DEAGLE_AMMO;
                    case 
CSW_P228offset OFFSET_P228_AMMO;
                    case 
CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITEoffset OFFSET_GLOCK_AMMO;
                    case 
CSW_FLASHBANGoffset OFFSET_FLASH_AMMO;
                    case 
CSW_HEGRENADEoffset OFFSET_HE_AMMO;
                    case 
CSW_SMOKEGRENADEoffset OFFSET_SMOKE_AMMO;
                    case 
CSW_C4offset OFFSET_C4_AMMO;
                    default: return 
0;
                }
                
                
set_pdata_int(indexoffsetammo5);
                
                return 
0
            
}
            
            new 
save pev(entpev_solid)
            
dllfunc(DLLFunc_Touchentindex)
            if (
pev(entpev_solid) != save)
                return 
ent
            
            engfunc
(EngFunc_RemoveEntityent)
            
            return -
1
        
}
        
        if( 
iWeapon )
        {
            while( 
pev_validiWeapon ) )
            {
                new 
iWeaponBox
                iWeaponBox 
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"weaponbox"))
                if( 
pev_validiWeaponBox ) )
                {
                    
//new Float:origin[3]
                    //pev(index, pev_origin, origin)
                    //set_pev(iWeaponBox, pev_origin, origin)
                    
set_pev(iWeaponBoxpev_spawnflagspev(iWeaponBoxpev_spawnflags) | SF_NORESPAWN)
                    
dllfunc(DLLFunc_SpawniWeaponBox)
                    
                    if(
mod == 1)
                    {
                        
set_pdata_int(iWeaponBox51clip4)
                        
                        static 
offset
                        
                        
new szWeapon[20]
                        
pev(iWeaponpev_classnameszWeaponcharsmax(szWeapon))
                        
                        new 
iWeaponID
                        iWeaponID 
get_weaponid(szWeapon)
                        
                        switch(
iWeaponID)
                        {
                            case 
CSW_AWPoffset OFFSET_AWM_AMMO;
                            case 
CSW_SCOUT,CSW_AK47,CSW_G3SG1offset OFFSET_SCOUT_AMMO;
                            case 
CSW_M249offset OFFSET_PARA_AMMO;
                            case 
CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552offset OFFSET_FAMAS_AMMO;
                            case 
CSW_M3,CSW_XM1014offset OFFSET_M3_AMMO;
                            case 
CSW_USP,CSW_UMP45,CSW_MAC10offset OFFSET_USP_AMMO;
                            case 
CSW_FIVESEVEN,CSW_P90offset OFFSET_FIVESEVEN_AMMO;
                            case 
CSW_DEAGLEoffset OFFSET_DEAGLE_AMMO;
                            case 
CSW_P228offset OFFSET_P228_AMMO;
                            case 
CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITEoffset OFFSET_GLOCK_AMMO;
                            case 
CSW_FLASHBANGoffset OFFSET_FLASH_AMMO;
                            case 
CSW_HEGRENADEoffset OFFSET_HE_AMMO;
                            case 
CSW_SMOKEGRENADEoffset OFFSET_SMOKE_AMMO;
                            case 
CSW_C4offset OFFSET_C4_AMMO;
                            default: return 
0;
                        }
                        
                        
set_pdata_int(indexoffsetammo5);
                        
                        return 
0
                    
}
                    
                    new 
save pev(iWeaponBoxpev_solid)
                    
dllfunc(DLLFunc_TouchiWeaponBoxindex)
                    
                    if (
pev(iWeaponBoxpev_solid) != save)
                        return 
iWeaponBox
                    
                    engfunc
(EngFunc_RemoveEntityiWeaponBox)
                    
                    return -
1
                
}
            }
        }
        
        return 
0
    
}
    else
    {
        if (
iWeapon == 0)
        {
            static 
offset
            
            
new szWeapon[20]
            
pev(iWeaponpev_classnameszWeaponcharsmax(szWeapon))
            
            new 
iWeaponID
            iWeaponID 
get_weaponid(szWeapon)
            
            switch(
iWeaponID)
            {
                case 
CSW_AWPoffset OFFSET_AWM_AMMO;
                case 
CSW_SCOUT,CSW_AK47,CSW_G3SG1offset OFFSET_SCOUT_AMMO;
                case 
CSW_M249offset OFFSET_PARA_AMMO;
                case 
CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552offset OFFSET_FAMAS_AMMO;
                case 
CSW_M3,CSW_XM1014offset OFFSET_M3_AMMO;
                case 
CSW_USP,CSW_UMP45,CSW_MAC10offset OFFSET_USP_AMMO;
                case 
CSW_FIVESEVEN,CSW_P90offset OFFSET_FIVESEVEN_AMMO;
                case 
CSW_DEAGLEoffset OFFSET_DEAGLE_AMMO;
                case 
CSW_P228offset OFFSET_P228_AMMO;
                case 
CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITEoffset OFFSET_GLOCK_AMMO;
                case 
CSW_FLASHBANGoffset OFFSET_FLASH_AMMO;
                case 
CSW_HEGRENADEoffset OFFSET_HE_AMMO;
                case 
CSW_SMOKEGRENADEoffset OFFSET_SMOKE_AMMO;
                case 
CSW_C4offset OFFSET_C4_AMMO;
                default: return 
0;
            }
            
            return 
get_pdata_int(indexoffset5);
        }
        else
        {
            static 
offset
            
            
new szWeapon[20]
            
pev(iWeaponpev_classnameszWeaponcharsmax(szWeapon))
            
            new 
iWeaponID
            iWeaponID 
get_weaponid(szWeapon)
            
            switch(
iWeaponID)
            {
                case 
CSW_AWPoffset OFFSET_AWM_AMMO;
                case 
CSW_SCOUT,CSW_AK47,CSW_G3SG1offset OFFSET_SCOUT_AMMO;
                case 
CSW_M249offset OFFSET_PARA_AMMO;
                case 
CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552offset OFFSET_FAMAS_AMMO;
                case 
CSW_M3,CSW_XM1014offset OFFSET_M3_AMMO;
                case 
CSW_USP,CSW_UMP45,CSW_MAC10offset OFFSET_USP_AMMO;
                case 
CSW_FIVESEVEN,CSW_P90offset OFFSET_FIVESEVEN_AMMO;
                case 
CSW_DEAGLEoffset OFFSET_DEAGLE_AMMO;
                case 
CSW_P228offset OFFSET_P228_AMMO;
                case 
CSW_GLOCK18,CSW_MP5NAVY,CSW_TMP,CSW_ELITEoffset OFFSET_GLOCK_AMMO;
                case 
CSW_FLASHBANGoffset OFFSET_FLASH_AMMO;
                case 
CSW_HEGRENADEoffset OFFSET_HE_AMMO;
                case 
CSW_SMOKEGRENADEoffset OFFSET_SMOKE_AMMO;
                case 
CSW_C4offset OFFSET_C4_AMMO;
                default: return 
0;
            }
            
            return 
get_pdata_int(indexoffset5);
        }
    }

    return -
1



Dr.G 02-27-2009 17:39

Re: Problem with stock
 
oh dear... check out fakemeta_util.inc


All times are GMT -4. The time now is 16:53.

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