PDA

View Full Version : [CoD2] Weapon hit range



Toxys
31st October 2020, 17:14
Hi,

How can I set "kar98k"'s hit range? Is this enough if I set in eg.: weapons/kar98k_mp maxDamageRange?

If the player's hit range > 2000 then print a text to the screen: "The hit range was too high"


I don't know what the exact name is for this function but I might meant about shoot distance so if the distance was higher than for ex.: 1 meter then print "The distance was too high" to the screen?

EDIT2: Sorry I wrote this topic in hurry and I know that my english isn't very well... Let's clarify what I want:

I want to do a script, if the player shot within one meter then hits the enemy player else print that "The shooting distance was too high"...

I don't want to beg for a free script but I really don't know how to start this...

maxdamage99
2nd November 2020, 05:06
hm, i think: better do process dmg, distance and weap in callback


codecallback_playerDamage(..., ..., ..., ...)
{
if (isDefined(self) && isDefined(eAttacker) && isPlayer(self) && isPlayer(eAttacker) && self != eAttacker && sWeapon == "kar98k_mp" && distance(self.origin, eAttacker.origin) > 1000)
{
eAttacker iprintlnbold("distance so long");
return;
}
}

Toxys
2nd November 2020, 12:23
I need to set this in for ex.: sd.gsc right?

I changed the Callback_PlayerDamage function to this but it doesn't seem to work. A little modification about my question: I wan't to print "distance so long" everytime if the player who is in "axis" side is shooting no matter if he is hitting the enemy player or no... just if the distance is longer than 1 meter print this. I hope you understand what I want to say.


Callback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime)
{
if (isDefined(self) && isDefined(eAttacker) && isPlayer(self) && isPlayer(eAttacker) && self != eAttacker && sWeapon == "kar98k_mp" && distance(self.origin, eAttacker.origin) > 1000)
{
eAttacker iprintlnbold("distance so long");
return;
}
}

maxdamage99
3rd November 2020, 06:21
I need to set this in for ex.: sd.gsc right?

I changed the Callback_PlayerDamage function to this but it doesn't seem to work. A little modification about my question: I wan't to print "distance so long" everytime if the player who is in "axis" side is shooting no matter if he is hitting the enemy player or no... just if the distance is longer than 1 meter print this. I hope you understand what I want to say.


Callback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime)
{
if (isDefined(self) && isDefined(eAttacker) && isPlayer(self) && isPlayer(eAttacker) && self != eAttacker && sWeapon == "kar98k_mp" && distance(self.origin, eAttacker.origin) > 1000)
{
eAttacker iprintlnbold("distance so long");
return;
}
}

1642
1. Add my code in function. NO REPLACE YOUR FUNCTION ONLY FOR MY CODE, just add MY code IN YOUR


Callback_PlayerDamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, psOffsetTime)
{
if (isDefined(self) && isDefined(eAttacker) && isPlayer(self) && isPlayer(eAttacker) && self != eAttacker && sWeapon == "kar98k_mp" && distance(self.origin, eAttacker.origin) > 1000)
{
eAttacker iprintlnbold("distance so long");
return;
}
/*

...

code

...

*/
}

2. edit: change 1000 to 1, delete iprintlnbold

Toxys
3rd November 2020, 12:41
I didn't replaced the whole Callback_PlayerDamage function. Just added your code. But this is always displays "distance so long" no matter how far I shoot the enemy player.

I want to display the "distance so long" message if the player shoot away more than 1 meter from itself no matter if hitting the enemy or no.

One more question: Why I can't hit custom models? I can hit and kill the default american,german,russian, etc models... but if the enemy is choose for ex.: a brush model (e.g. brush_egypt_desert_1) I can't hit and kill him.

maxdamage99
5th November 2020, 04:28
I didn't replaced the whole Callback_PlayerDamage function. Just added your code. But this is always displays "distance so long" no matter how far I shoot the enemy player.

I want to display the "distance so long" message if the player shoot away more than 1 meter from itself no matter if hitting the enemy or no.

One more question: Why I can't hit custom models? I can hit and kill the default american,german,russian, etc models... but if the enemy is choose for ex.: a brush model (e.g. brush_egypt_desert_1) I can't hit and kill him.

do you need the distance between the player and the bullet point of impact?

I don't know why this code doesn't work, how are you testing? maybe you always shoot at a distance of more than 1000?

do test script for value 100-250. bcs 1 - very small value: maybe it's impossible distance between players.
?? 1meter != 1 from distance(); ??

Toxys
5th November 2020, 14:07
No, I tested with different distances and always got that message.

maxdamage99
9th November 2020, 06:56
No, I tested with different distances and always got that message.

i think you do some wrong