View Single Post
InstantDeath
Senior Member
Join Date: Mar 2007
Old 07-11-2017 , 15:04   Re: [CS:S] One Man Army issues
Reply With Quote #6

Okay so a couple of things.

I've set the grenades to be removed when a player goes invisible, but instead of removing it, it seems to be showing a completely different equipment set. Should i set it to none if i want no equipment bits showing?
PHP Code:
#define CSAddon_NONE            0 
this is how it currently looks:
PHP Code:
#define CSAddon_NONE            0
#define CSAddon_HEGrenade       (1<<2)
#define CSAddon_SmokeGrenade    (1<<3)

new g_bits[MAXPLAYERS+1];

...

public 
Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
...

new 
henade GetClientGrenades(clientSlot_HEgrenade);
new 
sgnade GetClientGrenades(clientSlot_Smokegrenade);

if(
henade 0)
    
g_bits[client] &= ~CSAddon_HEGrenade;

if(
sgnade 0)
    
g_bits[client] &= ~CSAddon_SmokeGrenade;

...

    return 
Plugin_Continue;
}

//rest of plugin

GetClientGrenades(clientAmmoOffs)
{
    new 
offsNades FindDataMapInfo(client"m_iAmmo") + (AmmoOffs 4);
    
    return 
GetEntData(clientoffsNades);



The other thing is I have is a peculiar crash which I believe to have narrowed down to the "goodie box" a prop_physics that spawns where the CT player dies(if killed by the OMA). The OMA can touch it and pick up unique bonuses or a detriment(it can also explode, hurting the OMA)

There is a function called Entity_Touch that is used by both teams. The CT team can touch prop_physics and "find something" be it new gear, a health pack, etc.

Both teams use this function, and I've noticed that if a CT and a T touch the goodie box at the same time, the game crashes. Probably because when a T touches the goodie box, it removes it.


I'm not sure how to go about fixing this. Here are the functions in question:

also OMA_Goodie[MAXPLAYERS+1]; is a global array.

PHP Code:
#define GOODIEBOX_MODEL "models/items/boxmrounds.mdl"

public OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_TouchEntity_Touch);
        
        
//rest of code
}

stock SpawnGoodieBox(client)
{
    new 
Float:pos[3], Float:numVel[3];
    
numVel[0] = GetRandomFloat(-100.0100.0);
    
numVel[1] = GetRandomFloat(-100.0100.0);
    
numVel[2] = GetRandomFloat(1.0100.0);
    
OMA_Goodie[client] = CreateEntityByName("prop_physics");
    
SetEntityModel(OMA_Goodie[client], GOODIEBOX_MODEL);
    
DispatchSpawn(OMA_Goodie[client]);
    
GetClientAbsOrigin(clientpos);
    
TeleportEntity(OMA_Goodie[client], posNULL_VECTORnumVel);
    
CreateTimer(15.0TimedDeleteEntityOMA_Goodie[client], TIMER_FLAG_NO_MAPCHANGE); 
}

public 
Action:Entity_Touch(entity1entity2)
{
    new 
cliententity;
    if(
entity1 && entity1 <= 64)
    {
        
client entity1;
        
entity entity2;

    }
    else
    {
        
client entity2;
        
entity entity1;
    }
    new 
boolomaenable GetConVarBool(cvarpluginstatus);
    if(
omaenable)
    {
        new 
team GetClientTeam(client);
        if(
IsClientInGame(client))
        {
            if(
IsPlayerAlive(client))
            {
                if (
IsValidEntity(entity))
                {
                    
decl String:classname[32];
                    
GetEdictClassname(entityclassnamesizeof(classname));
                    
                    if((
WarmupActive && Weaponlvl[client] < 0) || (!WarmupActive && team == TEAM_CT))
                    {
                        if(
StrEqual(classname"weapon_hegrenade"false))
                        {
                            new 
count GetClientGrenades(clientSlot_HEgrenade);
                        
                            if (
count PlayerSkills[client][2])
                            {    
                                
PickupGrenade(cliententity);
                            }
                        }
                        
                        else if(
StrEqual(classname"weapon_smokegrenade"false))
                        {
                            new 
count GetClientGrenades(clientSlot_Smokegrenade);
                            
                            if (
count PlayerSkills[client][3])
                            {    
                                
PickupGrenade(cliententity);
                            }
                        }
                        
                        else if(
StrEqual(classname"prop_physics"false) || StrEqual(classname"prop_physics_multiplayer"false) || StrEqual(classname"func_physbox"false))
                        {
                            
//money roll code
                            //weapon roll code
                            //armor roll code
                        
}
                    }
                    else if((
WarmupActive && Weaponlvl[client] >= 0) || (!WarmupActive && team == TEAM_T))
                    {
                        if(
StrEqual(classname"prop_physics"false))
                        {
                            
                            new 
boolfoundent falsec;
                            for(
1MaxClientsc++)
                            {
                                if(
OMA_Goodie[c] == entity)
                                {
                                    
PrintDebugMsg("OMA touched Goodie box");
                                    
foundent true;
                                    if(
IsValidEdict(entity))
                                    {    
                                        
RemoveEdict(entity);
                                        
OMA_Goodie[c] = -1;
                                    }
                                    break;
                                }
                            }
                            if(
foundent)
                            {
                                new 
bool:lvl2keyrollrandom GetRandomInt(14);
                                new 
cashwonClientCash GetClientMoney(client);
                                new 
Float:pos[3];
                                
                                
GetClientAbsOrigin(clientpos);
                                
lvl2keyroll ChanceRoll(OMA_lvl[client]);
                                
                                switch(
random)
                                {
                                    case 
1:
                                    {
                                        
//found small amount of money reward code
                                    
}
                                    
                                    case 
2:
                                    {
                                        new 
randitem GetRandomInt(13);
                                        switch(
randitem)
                                        {
                                            case 
1:
                                            {
                                                
                                                
//found healthkit reward code

                                                
EmitSoundToAll(HEALTHKIT_SOUNDclientSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGS1.0SNDPITCH_NORMAL, -1posNULL_VECTORtrue0.0);
                                            }
                                            case 
2:
                                            {
                                                new 
ClientArmor GetClientArmor(client);
                                                
                                                if(
ClientArmor 100)
                                                {
                                                    
SetClientArmor(client100);
                                                    
EmitSoundToAll(ITEMPICKUP_SOUNDclientSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGS1.0SNDPITCH_NORMAL, -1posNULL_VECTORtrue0.0);
                                                }
                                            }
                                            case 
3:
                                            {
                                                new 
ClientArmor GetClientArmor(client);
                                                
                                                if(
ClientArmor 25 <= 125)
                                                {
                                                    
SetClientArmor(client125);
                                                }
                                                else
                                                
SetClientArmor(client125);
                                                
                                                
EmitSoundToAll(ITEMPICKUP_SOUNDclientSNDCHAN_AUTOSNDLEVEL_NORMALSND_NOFLAGS1.0SNDPITCH_NORMAL, -1posNULL_VECTORtrue0.0);
                                            }
                                        }
                                    }
                                    case 
3:
                                    {
                                        
cashwon GetRandomInt(15000);
                                        
SetClientMoney(clientClientCash+cashwon);
                                        
PrintToChat(client"[SM] %t""found money"cashwon);
                                    }
                                    
                                    case 
4:
                                    {
                                        
//box explodes code
                                    
}
                                }
                                
PrintDebugMsg("OMA successfuly recieved Goodie box");
                            }
                        }
                    }
                }
            }
        }
    }
    return 
Plugin_Continue;

__________________

Last edited by InstantDeath; 07-11-2017 at 15:07.
InstantDeath is offline