Changed code to this:
Code:
public client_PreThink(id)
{
new button = get_user_button(id)
if(button & IN_ATTACK)
{
new Victim = read_data(2)
new Enemy = id, BodyPart
new Float: distance = get_user_aiming(id, Victim, BodyPart)
new EnemyName[34], VictimName[34]
get_user_name(Enemy, EnemyName, 33)
get_user_name(Victim, VictimName, 33)
if (Victim == 0 || Enemy == 0 || is_user_alive(Enemy)==0 || is_user_alive(Victim)==0)
{
return PLUGIN_HANDLED
}
//evade
new DodgeChance = random_num(0, 100)
new DodgeMod = (PlayerSkill[Victim][SKILL_DODGE] - PlayerSkill[Enemy][SKILL_TRUESHOT])
if(DodgeMod >= DodgeChance)
{
client_print(Victim, print_chat, "You dodged a shot by %s!", EnemyName)
client_print(0, print_console, "DodgeMod(%i)/DodgeChance(%i) = SUCCESS!", DodgeMod, DodgeChance)
client_print(Enemy, print_chat, "%s dodged your shot!", VictimName)
if(is_user_alive(Victim))
{
set_user_godmode (Victim, 1)
return PLUGIN_HANDLED
}
}
else
{
if(is_user_alive(Victim))
{
client_print(0, print_console, "Skill(%i)/DodgeChance(%i) = FAILURE!", PlayerSkill[Victim][SKILL_DODGE], DodgeChance)
set_user_godmode(Victim)
return PLUGIN_HANDLED
}
}
}
return PLUGIN_HANDLED
}
and it works fine, except for the fact that it runs around 6 - 8 times per shot (tested with usp) is there any way to stop this? I only want it ran once per shot.
EDIT:
Found this off a post and added it to help, but didn't work
Code:
public curweapon(id)
{
new wpnid = read_data(2)
new clip = read_data(3)
if (lastweap[id] != wpnid){
//Changed weapons
}
else if ( lastclip[id] > clip ) {
if (wpnid != CSW_C4 && wpnid != CSW_HEGRENADE && wpnid != CSW_FLASHBANG && wpnid != CSW_SMOKEGRENADE && wpnid != CSW_KNIFE) {
//Fired a Bullet
UserFired[id] = 1
}
else
UserFired[id] = 0
}
lastclip[id] = clip
lastweap[id] = wpnid
}
__________________
"What then is truth? Truths are illusions which we have forgotten are illusions - they are metaphors that have become worn out... this (truth) is the duty to lie according to a fixed convention.
-Friedrich Nietzsche