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, &impulse, Float:vel[3], Float:angles[3], &weapon)
{
...
new henade = GetClientGrenades(client, Slot_HEgrenade);
new sgnade = GetClientGrenades(client, Slot_Smokegrenade);
if(henade > 0)
g_bits[client] &= ~CSAddon_HEGrenade;
if(sgnade > 0)
g_bits[client] &= ~CSAddon_SmokeGrenade;
...
return Plugin_Continue;
}
//rest of plugin
GetClientGrenades(client, AmmoOffs)
{
new offsNades = FindDataMapInfo(client, "m_iAmmo") + (AmmoOffs * 4);
return GetEntData(client, offsNades);
}
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(client, SDKHook_Touch, Entity_Touch);
//rest of code
}
stock SpawnGoodieBox(client)
{
new Float:pos[3], Float:numVel[3];
numVel[0] = GetRandomFloat(-100.0, 100.0);
numVel[1] = GetRandomFloat(-100.0, 100.0);
numVel[2] = GetRandomFloat(1.0, 100.0);
OMA_Goodie[client] = CreateEntityByName("prop_physics");
SetEntityModel(OMA_Goodie[client], GOODIEBOX_MODEL);
DispatchSpawn(OMA_Goodie[client]);
GetClientAbsOrigin(client, pos);
TeleportEntity(OMA_Goodie[client], pos, NULL_VECTOR, numVel);
CreateTimer(15.0, TimedDeleteEntity, OMA_Goodie[client], TIMER_FLAG_NO_MAPCHANGE);
}
public Action:Entity_Touch(entity1, entity2)
{
new client, entity;
if(entity1 > 0 && entity1 <= 64)
{
client = entity1;
entity = entity2;
}
else
{
client = entity2;
entity = entity1;
}
new bool: omaenable = GetConVarBool(cvarpluginstatus);
if(omaenable)
{
new team = GetClientTeam(client);
if(IsClientInGame(client))
{
if(IsPlayerAlive(client))
{
if (IsValidEntity(entity))
{
decl String:classname[32];
GetEdictClassname(entity, classname, sizeof(classname));
if((WarmupActive && Weaponlvl[client] < 0) || (!WarmupActive && team == TEAM_CT))
{
if(StrEqual(classname, "weapon_hegrenade", false))
{
new count = GetClientGrenades(client, Slot_HEgrenade);
if (count < PlayerSkills[client][2])
{
PickupGrenade(client, entity);
}
}
else if(StrEqual(classname, "weapon_smokegrenade", false))
{
new count = GetClientGrenades(client, Slot_Smokegrenade);
if (count < PlayerSkills[client][3])
{
PickupGrenade(client, entity);
}
}
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 bool: foundent = false, c;
for(c = 1; c < MaxClients; c++)
{
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:lvl2keyroll, random = GetRandomInt(1, 4);
new cashwon, ClientCash = GetClientMoney(client);
new Float:pos[3];
GetClientAbsOrigin(client, pos);
lvl2keyroll = ChanceRoll(OMA_lvl[client]);
switch(random)
{
case 1:
{
//found small amount of money reward code
}
case 2:
{
new randitem = GetRandomInt(1, 3);
switch(randitem)
{
case 1:
{
//found healthkit reward code
EmitSoundToAll(HEALTHKIT_SOUND, client, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, 1.0, SNDPITCH_NORMAL, -1, pos, NULL_VECTOR, true, 0.0);
}
case 2:
{
new ClientArmor = GetClientArmor(client);
if(ClientArmor < 100)
{
SetClientArmor(client, 100);
EmitSoundToAll(ITEMPICKUP_SOUND, client, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, 1.0, SNDPITCH_NORMAL, -1, pos, NULL_VECTOR, true, 0.0);
}
}
case 3:
{
new ClientArmor = GetClientArmor(client);
if(ClientArmor + 25 <= 125)
{
SetClientArmor(client, 125);
}
else
SetClientArmor(client, 125);
EmitSoundToAll(ITEMPICKUP_SOUND, client, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, 1.0, SNDPITCH_NORMAL, -1, pos, NULL_VECTOR, true, 0.0);
}
}
}
case 3:
{
cashwon = GetRandomInt(1, 5000);
SetClientMoney(client, ClientCash+cashwon);
PrintToChat(client, "[SM] %t", "found money", cashwon);
}
case 4:
{
//box explodes code
}
}
PrintDebugMsg("OMA successfuly recieved Goodie box");
}
}
}
}
}
}
}
return Plugin_Continue;
}
__________________