AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Cannot detect Darwin Danger Shield? (https://forums.alliedmods.net/showthread.php?t=234192)

Chdata 01-26-2014 18:31

Cannot detect Darwin Danger Shield?
 
Code: http://pastebin.com/Mbrf7aZi

Any bIsWeapon which I forgot from the code above.
PHP Code:

stock bIsWeapon(clientany:char)
{
    new 
weapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon");

    
decl String:wepclassname[32];

    if (
weapon <= MaxClients || !IsValidEntity(weapon) || !GetEdictClassname(weaponwepclassnamesizeof(wepclassname)))
    {
        
strcopy(wepclassnamesizeof(wepclassname), "");
    }

    return (
wepclassname[11] == char); // tf_weapon_sniperrifle all have 'n' in common that other sniper weapons don't


For some reason, this does not always send the message when headshotting someone who has a danger shield equipped.

What's wrong and how can I fix it?

Here's what I suspect:

1. My way of checking if they have a shield is broken
2. My way of detecting headshots is broken
3. TF wearables suck and are broken and it only acts if I have the actual index randomly

Removing the

TF2_IsPlayerInCondition(attacker, TFCond_Zoomed)

check changed nothing.

Unless reloading the plugin removes the OnTakeDamage hook, which it shouldn't considering it's added in OnPluginStart.

Edit: Added a check for body shots too, it's not running any code at all after GetIndexOfWeaponSlot

Also for some reason, after map change, it seems to have completely broken instead of only sometimes detecting it. Wat.

Also, using FindEntityByClassname and checking if the owner of the shield was the victim, had just about the same issue.

MasterOfTheXP 01-26-2014 20:09

Re: Cannot detect Darwin Danger Shield?
 
GetPlayerWeaponSlot doesn't work on wearable weapons. The rest of your code seems fine, though...are you sure you tried FindEntityByClassname correctly?
PHP Code:

if (DoesClientHaveWearableIndex(victim231))
    ...

stock DoesClientHaveWearableIndex(clientindex)
{
    new 
= -1;
    while ((
FindEntityByClassname(i"tf_wearable*")) != -1)
    {
        if (
client != GetEntPropEnt(iProp_Send"m_hOwnerEntity")) continue;
        if (
index != GetEntProp(iProp_Send"m_iItemDefinitionIndex")) continue;
        if (
GetEntProp(iProp_Send"m_bDisguiseWearable")) continue;
        return 
i;
    }
    return 
0;



Chdata 01-26-2014 21:17

Re: Cannot detect Darwin Danger Shield?
 
I switched back to it and it seems to be working again. I moved off it before because it broke though...

Edit:

PHP Code:

stock bool:bVictimHasDarwin(victim//GetIndexOfWeaponSlot(victim, TFWeaponSlot_Secondary) == 231
{
    new 
ent = -1;

    while ((
ent FindEntityByClassname2(ent"tf_wearable")) != -1)
    {
        new 
idx GetEntProp(entProp_Send"m_iItemDefinitionIndex");

        if (
GetEntPropEnt(entProp_Send"m_hOwnerEntity") == victim && idx == 231)
        {
            return 
true;
        }
    }

    return 
false;
}

stock FindEntityByClassname2(startEnt, const String:classname[])
{
    
/* If startEnt isn't valid shifting it back to the nearest valid one */
    
while (startEnt > -&& !IsValidEntity(startEnt))
    {
        
startEnt--;
    }

    return 
FindEntityByClassname(startEntclassname);


This was working perfectly until just recently, I was able to survive a headshot (meaning the check failed).

The server is sniper only due to class restrictions.

It seems I'm able to one shot some people using it, another person is complaining he can't one shot anyone using it.

Edit: As it's a sniper only server...

PHP Code:

if (GetClientHealth(iVictim) > 125)
{
     
//He has tha derwan.


And if it were non-sniper only, would just have to check if class == sniper too.

Edit: Wat, that doesn't work either. At least now I know something else must be wrong.

Edit 2: Updated my OP with the full OnTakeDamage check.

Things I'm sure of:

The bitwise checks aren't the problem.
The bodyshot nerf always works.
The melee nerf always works.


All times are GMT -4. The time now is 18:03.

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