Modifying weapon damage?
#1

I've seen on servers the damage weapons do. Someone said you need to use OnPlayerShootPlayer? What exactly should I write to modify the damage of say..a sniper to take 100 HP? And would it take away armor also or skip armor and take their HP?
Reply
#2

Well use OnPlayerShootPlayer indeed.
Use the callback:

pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
And then, if the "shooter" shot "target", and the weapon of the "shoot" is sniper, set "target" 's health - 100 HP.
Here's an example

pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    new Float:H;
    GetPlayerHealth(target, H);
    if(GetPlayerWeapon(shooter) == 34)
        SetPlayerHealth(target, H-100);
    return 1;
}
That should work ^^
Here's the include: https://sampforum.blast.hk/showthread.php?tid=195439
Reply
#3

Quote:
Originally Posted by Kwarde
Посмотреть сообщение
Well use OnPlayerShootPlayer indeed.
Use the callback:

pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
And then, if the "shooter" shot "target", and the weapon of the "shoot" is sniper, set "target" 's health - 100 HP.
Here's an example

pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    new Float:H;
    GetPlayerHealth(target, H);
    if(GetPlayerWeapon(shooter) == 34)
        SetPlayerHealth(target, H-100);
    return 1;
}
That should work ^^
Here's the include: https://sampforum.blast.hk/showthread.php?tid=195439
Yes, that should work perfectly.
Reply
#4

Will that check for armor first and if he does have armor, take it? Or would I have to write below it..

SetPlayerArmor(target, A-100)

And I probably sound stupid, but how do I make a .inc?
Reply
#5

Quote:
Originally Posted by Zack9764
Посмотреть сообщение
Will that check for armor first and if he does have armor, take it? Or would I have to write below it..

SetPlayerArmor(target, A-100)

And I probably sound stupid, but how do I make a .inc?
I'll make it with armour too now.

pawn Код:
public OnPlayerShootPlayer(shooter, target, Float:damage)
{
    new Float:A, Float:H, Float:health, Float:armour;
    GetPlayerHealth(target, H);
    GetPlayerArmour(target, A);
    armour = 100 - A;
    health = H - armour;
    SetPlayerArmour(target, armour);
    SetPlayerHealth(target, health);
    return 1;
}
Maybe something like that?
However about the include: Just make an new file named "{name}.inc" and put it in pawno/includes
But you need to make the include. Just make functions etc. If you need something like "OnPlayerConnect", use CallRemoteFunction/CallLocalFunction
Reply
#6

Quote:
Originally Posted by Zack9764
Посмотреть сообщение
Will that check for armor first and if he does have armor, take it? Or would I have to write below it..

SetPlayerArmor(target, A-100)

And I probably sound stupid, but how do I make a .inc?
pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    new Float:H[2];
    GetPlayerHealth(target, H[0]);
    GetPlayerArmour(target,H[1]);
    if(GetPlayerWeapon(shooter) == 34)
    {
        if(H[1] > 0) return SetPlayerArmour(target,0);
        SetPlayerHealth(target, H[0]-100);
    }
    return 1;
}
EDIT: Oh i was late But my code is different.
A bug on Kwarde code:
If players armour is more than 100, then armour gets set to a negative value, and health is Health + some armour.
Reply
#7

Quote:
Originally Posted by wups
Посмотреть сообщение
pawn Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    new Float:H[2];
    GetPlayerHealth(target, H[0]);
    GetPlayerArmour(target,H[1]);
    if(GetPlayerWeapon(shooter) == 34)
    {
        if(H[1] > 0) return SetPlayerArmour(target,0);
        SetPlayerHealth(target, H[0]-100);
    }
    return 1;
}
EDIT: Oh i was late But my code is different.
Yours is better. I'm not good with thinking 1-2-3. I need to write it on notepad.
I've just done that. This is my result:

Код:
100 A
80 H

A: 100 - 80 (= 20)
H: 100 - A = 100 - 20 = 80

Armour = 20
Health = 80
it looks like this: You have 100 armour and 80 health.
You get shot by ANY weapon (forget GetPlayerWeapon). It will do :
Armour = 100-80
Health = 100 - "Armour" (100-80) - 100 - 20
So armour will be 20 and health 80 now. (actually, it's a bit RP. In real, your armour won't gone first , then health)
And like I said, I forgot the GetPlayerWeapon

Use Wups code
Reply
#8

So that will set his armor to 0 and then take 100 HP?

And how would I setup another weapon to edit? Take the Country Rifle for example. Say if he has 100 armor and 100 HP. I want it take 75 armor. Then if he's shot again it would take 25 armor and 50 HP.

Sorry. Scripting can really confuse me.
Reply
#9

Quote:

And how would I setup another weapon to edit?

Use GetPlayerWeapon. If you want an minigun, for example, use:

Код:
if(GetPlayerWeapon(shooter) == 38)
Weapon ID's are here: (+name+image)
http://weedarr.wikidot.com/gunlist
Reply
#10

So this is correct?

Код:
public OnPlayerShootPlayer(shooter,target,Float:damage)
{
    new Float:H[2];
    GetPlayerHealth(target, H[0]);
    GetPlayerArmour(target,H[1]);
    if(GetPlayerWeapon(shooter) == 34)
    {
        if(H[1] > 0) return SetPlayerArmour(target,0);
        SetPlayerHealth(target, H[0]-100);
    }
    if(GetPlayerWeapon(shooter) == 33)
    {
        if(H[1] > 0) return SetPlayerArmour(target,0);
        SetPlayerHealth(target, H[0]-75);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)