SA-MP Forums Archive
[Include] Detect Weapon Butt Attack - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Detect Weapon Butt Attack (/showthread.php?tid=421274)



Detect Weapon Butt Attack - HitnKill - 08.03.2013

Hello, this codes it's useful example if you use an system to modified damage weapons or other system... I check the anims at the players for detect this... very easy but good.

PHP код:
#DEFINE MAXWEAPONBUTTGUN 15 // cold steel <= 15 
OnPlayerAnimButtGun(playerid,weapondid

    if(
weapondid MAXWEAPONBUTTGUN// > at the cold steel you can modified this if you want... my GM dont use other cold steel
    

        if(
strcmp(GetPlayerAnimationNameEx(playerid), "GUN_BUTT"true)== || strcmp(GetPlayerAnimationNameEx(playerid), "GUN_STAND"true)    == || strcmp(GetPlayerAnimationNameEx(playerid), "GUN_BUTT_crouch"true) == ) return 1
    } 
    return 
0

GetPlayerAnimationNameEx(playerid

    new 
animlib[32]; 
     new 
animname[32]; 
       
GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32); 
    return 
animname

// example on OnPlayerTakeDamage
PHP код:
if(!OnPlayerAnimButtGun(issuerid,weaponid)) //false

//code 

// OR
if(OnPlayerAnimButtGun(issuerid,weaponid)) // true

//code 




Re: Detect Weapon Butt Attack - Whitetiger - 09.03.2013

the problem is sometimes a player who damages another one like this, it won't be synced on their screen and only the person you damaged's screen. to be honest, it's more practical (imo) to just detect if a player did < 3 or so damage with any shootable, and IsPlayerInRangeOfPoint.


Respuesta: Detect Weapon Butt Attack - Glimma - 09.03.2013

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    static Float:damage, Float:health, Float:armour;
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(amount == 2.64) // Detects default damage butt attack.
        {
            damage = 5.0; // Sets a new damage to the butt attack (editable).
        }
        GetPlayerHealth(playerid, heaalth);
        GetPlayerArmour(playerid, armour);
        if(armour)
        {
            if(armour > damage) SetPlayerArmour(playerid, armour-damage);
            else
            {
                SetPlayerArmour(playerid, 0.0);
                armour = damage-armour;
                if(armour >= health) SetPlayerHealth(playerid, 0.0);
                else SetPlayerHealth(playerid, health-armour);
            }
        }
        else
        {
            if(health > damage) SetPlayerHealth(playerid, health-damage);
            else SetPlayerHealth(playerid, 0.0);
        }
    }
    return 1;
}
It's simple, default damage or default in singleplayer butt attack is 2.64, which makes my code is to convert that damage you want.

Sorry for my bad english, i'm Argentinan.


Re : Detect Weapon Butt Attack - LittleSamp - 09.03.2013

good job !


Re : Detect Weapon Butt Attack - HitnKill - 09.03.2013

Quote:
Originally Posted by whitetigerswt
Посмотреть сообщение
the problem is sometimes a player who damages another one like this, it won't be synced on their screen and only the person you damaged's screen. to be honest, it's more practical (imo) to just detect if a player did < 3 or so damage with any shootable, and IsPlayerInRangeOfPoint.
Yes with the sync he can have the bugs with this func and with not this func, example the player who give the damage see he give the "weapon butt attack" and the player who receive this damage see a fire, but this func is not for detect if its sync or not i just want to detect when the player have 1 at this 3 anims. Why?

It all depends on what the person want to do, an example if the player who give the damage see he give a weapon butt attack and the player who receive this damage a fire by an Desert Eagle, you cant cancel the damage at this Desert Eagle (you can SetHP but if you setHP < Damage its very bad visually). I think your system is not perfectly but i know with the sync SAMP we cant to do a system perfect sync but i want just detect this anims its better i think.

Quote:
Originally Posted by DeadSkyTkb
Посмотреть сообщение
It's simple, default damage or default in singleplayer butt attack is 2.64, which makes my code is to convert that damage you want.
Sorry for my bad english, i'm Argentinan.
Example for me.

PHP код:
switch(weaponid)
                       {
                            case 
15amount 12;
                            case 
4amount 40;
                            case 
5amount 12;
                               case 
22amount 18;
                            case 
28amount 8;
                            case 
29amount 10;
                            case 
32amount 9;
                            case 
33amount 40;
                            case 
34amount 50;
                        }
                           
armour armour amount;
                        if(
armour 0.0)
                        {
                              
health += armour;
                             if(
health <= 0.0)
                             {
                                
health 0.0;
                               }
                            
armour 0.0;
                         }
                         
SetPlayerHealthTakeDamage(playeridhealth); // My Func change this
                         
SetPlayerArmourTakeDamage(playeridarmour); // My Func change this
                    

But GetPlayerHealth/Armour is bad on OnPlayerTakeDamage look this post why: https://sampforum.blast.hk/showthread.php?tid=414939