littlewhitey's Servers Forum (SA-MP/VC-MP/MTA)

Recycle Bin => Suggestions (2008-2011) => SA-MP Archive (2015) => SA-MP Archive => Recycle Bin => Accepted Suggestions => Topic started by: Slice on October 30, 2010, 05:53:16 PM

Title: [I]Anti-2shot
Post by: Slice on October 30, 2010, 05:53:16 PM
No more 2shot with this! Needs y_bit.inc from YSI (http://www.y-less.com/YSI/YSI_1.0.zip).

Code: [Select]
#include <a_samp>
#include <YSI/y_bit.inc>

#define FREEZE_TIME (650)

#define iPlayer  playerid

#pragma tabsize 0

new
BitArray:g_abIsSawnoffClipUsed< MAX_PLAYERS >,
         g_iSawnoffAmmo[ MAX_PLAYERS ],
         g_cFiredShots[ MAX_PLAYERS char ],
         g_cPreviousWeapon[ MAX_PLAYERS char ]
;

public OnPlayerSpawn( iPlayer )
{
g_iSawnoffAmmo[ iPlayer ] = -1;
g_cFiredShots{ iPlayer } = 0;
g_cPreviousWeapon{ iPlayer } = 0;

Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );
}

public OnPlayerUpdate( iPlayer )
{
static
s_iState,
s_iSpecialAction
;

s_iState = GetPlayerState( iPlayer );
s_iSpecialAction = GetPlayerSpecialAction( iPlayer );

if ( s_iState == PLAYER_STATE_ONFOOT && ( s_iSpecialAction == SPECIAL_ACTION_NONE || s_iSpecialAction == SPECIAL_ACTION_DUCK ) )
{
static
s_iWeapon,
s_iAmmo
;

s_iWeapon = GetPlayerWeapon( iPlayer );
s_iAmmo = GetPlayerAmmo( iPlayer );

if ( g_cPreviousWeapon{ iPlayer } != s_iWeapon )
{
if ( g_cPreviousWeapon{ iPlayer } == WEAPON_SAWEDOFF )
{
if ( Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
{
static
s_iWeaponState
;

s_iWeaponState = GetPlayerWeaponState( iPlayer );

if ( ( s_iWeaponState == WEAPONSTATE_MORE_BULLETS
     || s_iWeaponState == WEAPONSTATE_LAST_BULLET )
&& g_cFiredShots{ iPlayer } != 4 )
{
new
Float:fVX,
Float:fVY,
Float:fVZ
;

GetPlayerVelocity( iPlayer, fVX, fVY, fVZ );

if ( floatabs( fVZ ) < 0.15 )
{
ClearAnimations( iPlayer, 1 );

ApplyAnimation( playerid, "PED", "XPRESSscratch", 0.0, 1, 0, 0, 0, FREEZE_TIME, 1 );
}
}
}

g_cFiredShots{ iPlayer } = 0;
}


g_cPreviousWeapon{ iPlayer } = s_iWeapon;
}

if ( s_iWeapon == WEAPON_SAWEDOFF )
{
if ( g_iSawnoffAmmo[ iPlayer ] == -1 )
g_iSawnoffAmmo[ iPlayer ] = GetPlayerAmmo( iPlayer );
else
{
if ( GetPlayerWeaponState( iPlayer ) == WEAPONSTATE_RELOADING )
{
if ( Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );
}
else
{
if ( g_iSawnoffAmmo[ iPlayer ] != s_iAmmo )
{
if ( s_iAmmo < g_iSawnoffAmmo[ iPlayer ] )
{
Bit_Let( g_abIsSawnoffClipUsed, iPlayer );

g_cFiredShots{ iPlayer } += g_iSawnoffAmmo[ iPlayer ] - s_iAmmo;
}
else
{
g_cFiredShots{ iPlayer } = 0;

Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );
}

g_iSawnoffAmmo[ iPlayer ] = s_iAmmo;
}
}
}
}
else if ( g_iSawnoffAmmo[ iPlayer ] != -1 || Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
{
g_iSawnoffAmmo[ iPlayer ] = -1;

Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );

g_cFiredShots{ iPlayer } = 0;
}
}
else if ( g_iSawnoffAmmo[ iPlayer ] != -1 || Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
{
g_iSawnoffAmmo[ iPlayer ] = -1;

Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );

g_cFiredShots{ iPlayer } = 0;
}

return 1;
}

Edit: Update.
Title: Re: Anti-2shot
Post by: iMJets on October 30, 2010, 06:13:49 PM
i suggested this along time ago and it was said to be not possible i knew it was lol
Title: Re: Anti-2shot
Post by: Flashy on October 30, 2010, 06:41:47 PM
+10²³²³

The question is now: Does this work?
Title: Re: Anti-2shot
Post by: Reny on October 30, 2010, 06:43:40 PM
+10²³²³

The question is now: Does this work?
If Slice scripted it,there's no doubt about it :)
Good job.
Title: Re: Anti-2shot
Post by: Quickplay on October 30, 2010, 08:11:29 PM
fuckin fuckin good :D :D
often happens that idiots use dual shot even after u said them to don't do that...and they don't care when there's no admin on to ban them. this would be great
Title: Re: Anti-2shot
Post by: SRC on October 30, 2010, 08:14:34 PM
That is very good for server and bad for abuser :P gj  ;)
Title: Re: Anti-2shot
Post by: Fuse on October 30, 2010, 10:39:40 PM
Nice work slice, you think in smart ways that i would never be able do :)

Cool script
Title: Re: Anti-2shot
Post by: j.king on October 30, 2010, 11:21:47 PM
slaice gw
Title: Re: Anti-2shot
Post by: iMJets on October 31, 2010, 07:53:06 PM
that was fast nice to see it implemented
Title: Re: Anti-2shot
Post by: Gryphus_One on October 31, 2010, 07:56:42 PM
that was fast nice to see it implemented

Is it already implemented?? :o
I'm gonna try it...

EDIT: no it's not implemented.
.
Title: Re: Anti-2shot
Post by: iMJets on October 31, 2010, 08:03:53 PM
yes it is gryphus it freezes u if u 2 shot and u can take damage
Title: Re: Anti-2shot
Post by: Simon on November 01, 2010, 01:51:28 AM
Nice work, some small (should be fixable) annoyances though.

If you fire 2 bullets out of your sawn off then change weapons 10 seconds later (or any amount of time) you will still freeze. If you fire 2-shots then use your other weapon (while not taking advantage of the 2-shot rapid fire) then you will still also freeze, both are related to the same thing.

I think the issue could be resolved by moving the freeze trigger to when they shoot again, then adding a time check i.e. only freeze when they switch from and to sawnoff within x milliseconds. Yes, it probably wouldn't prevent 2-shot for laggers (shot fired sent before trigger and freeze animation*) but it'd still kill the advantages a player tried to gain from using the bug.

I'm not sure if this is with your updated version. I'm not sure if dugi put your older or newer version on the main server for testing.

(*You could try a return 0 to desync the 2-shot fired for other players. I'm not sure if that will cause some sort of desynced aftermath though.)
Title: Re: Anti-2shot
Post by: iMJets on November 01, 2010, 03:56:34 AM
i found a bug but i didnt know how to do it again i think slice figured it out though i wont say it here but very nice work overall
Title: Re: Anti-2shot
Post by: BikeDriver on November 01, 2010, 06:14:56 AM
i found a bug but i didnt know how to do it again i think slice figured it out though i wont say it here but very nice work overall

i like it too if the best LW RF fight000000r likes it :)
Title: Re: Anti-2shot
Post by: n1K on November 01, 2010, 08:34:22 AM
Erhm Hazard, as you said it freezes you if you 2 shot and then change your weapon. I guess that aint a bug and is still 2 shot.
I have seen people shooting 2 sawns and then switching for uzis. This is not allowed on lw as i have seen admins warning others for it.
Correct me if i am wrong
Title: Re: Anti-2shot
Post by: Slice on November 01, 2010, 08:49:21 AM
Erhm Hazard, as you said it freezes you if you 2 shot and then change your weapon. I guess that aint a bug and is still 2 shot.
I have seen people shooting 2 sawns and then switching for uzis. This is not allowed on lw as i have seen admins warning others for it.
Correct me if i am wrong
Yeah. The rule is shoot all sawn-off bullets before switching to another weapon.

Nice work, some small (should be fixable) annoyances though.

If you fire 2 bullets out of your sawn off then change weapons 10 seconds later (or any amount of time) you will still freeze. If you fire 2-shots then use your other weapon (while not taking advantage of the 2-shot rapid fire) then you will still also freeze, both are related to the same thing.

I think the issue could be resolved by moving the freeze trigger to when they shoot again, then adding a time check i.e. only freeze when they switch from and to sawnoff within x milliseconds. Yes, it probably wouldn't prevent 2-shot for laggers (shot fired sent before trigger and freeze animation*) but it'd still kill the advantages a player tried to gain from using the bug.

I'm not sure if this is with your updated version. I'm not sure if dugi put your older or newer version on the main server for testing.

(*You could try a return 0 to desync the 2-shot fired for other players. I'm not sure if that will cause some sort of desynced aftermath though.)
How about if the player doesn't switch back the weapon in 2-3 seconds, ignore the player's not reloading. Returning 0 would be tricky; I'd have to make the script return 0 to several player updates in order to desync the shot.
Title: Re: Anti-2shot
Post by: Disco on November 01, 2010, 09:06:51 AM
it sometimes happens in fights that u do a single 2 shot without wanting it and then it gets a weird fight ..
that script sux ...
Title: Re: Anti-2shot
Post by: Slice on November 01, 2010, 09:10:17 AM
it sometimes happens in fights that u do a single 2 shot without wanting it and then it gets a weird fight ..
that script sux ...
there's a post right above yours with a suggested solution to that. maybe you should start actually reading the topic before posting crap as usual.
Title: Re: Anti-2shot
Post by: Simon on November 01, 2010, 09:17:09 AM
Erhm Hazard, as you said it freezes you if you 2 shot and then change your weapon. I guess that aint a bug and is still 2 shot.
I have seen people shooting 2 sawns and then switching for uzis. This is not allowed on lw as i have seen admins warning others for it.
Correct me if i am wrong
Yeah. The rule is shoot all sawn-off bullets before switching to another weapon.

I've always been under the impression that the 2-shot rule was added it was there to stop people unnaturally increasing their rate of fire, to create an effect like an infinite sawn-off.

I guess the rule has morphed over time and admins have just told players to shoot all shots so there's no confusion, however if there's a systematic way of detecting 2-shot (as there is) then I do not see why you HAVE to shoot all four bullets.

What if you want to simply conserve ammo (yeah I know, rich players think of bullets as peanuts. New players however may want to conserve the spawn sawnoffs) or as Disco said, you accidentally shot a couple of bullets (e.g. you tapped shoot, but then realised in the same moment that you wanted to use uzi's, or get the guy with M4 as he's running away)?

edit:

Please don't say stupid things like "script sux". It's degrading and annoying when people say that sort of stuff when constructive criticisms could be given instead
Title: Re: Anti-2shot
Post by: Slice on November 01, 2010, 09:20:51 AM
Erhm Hazard, as you said it freezes you if you 2 shot and then change your weapon. I guess that aint a bug and is still 2 shot.
I have seen people shooting 2 sawns and then switching for uzis. This is not allowed on lw as i have seen admins warning others for it.
Correct me if i am wrong
Yeah. The rule is shoot all sawn-off bullets before switching to another weapon.

I've always been under the impression that the 2-shot rule was added it was there to stop people unnaturally increasing their rate of fire, to create an effect like an infinite sawn-off.

I guess the rule has morphed over time and admins have just told players to shoot all shots so there's no confusion, however if there's a systematic way of detecting 2-shot (as there is) then I do not see why you HAVE to shoot all four bullets.

What if you want to simply conserve ammo (I know, I know... you rich players think of bullets as peanuts) or as Disco said, you accidentally shot a couple of bullets (e.g. you tapped shoot, but then realised in the same moment that you wanted to use uzi's, or get the guy with M4 as he's running away)?
What I meant with the 2-3 second delay is it would basically determine if the sawnoff would have been reloaded when you switch it back. That way, people switching back to sawn-offs quickly will get punished for evading the sawnoff reload - others won't.
Title: Re: Anti-2shot
Post by: Simon on November 01, 2010, 09:23:58 AM
Erhm Hazard, as you said it freezes you if you 2 shot and then change your weapon. I guess that aint a bug and is still 2 shot.
I have seen people shooting 2 sawns and then switching for uzis. This is not allowed on lw as i have seen admins warning others for it.
Correct me if i am wrong
Yeah. The rule is shoot all sawn-off bullets before switching to another weapon.

I've always been under the impression that the 2-shot rule was added it was there to stop people unnaturally increasing their rate of fire, to create an effect like an infinite sawn-off.

I guess the rule has morphed over time and admins have just told players to shoot all shots so there's no confusion, however if there's a systematic way of detecting 2-shot (as there is) then I do not see why you HAVE to shoot all four bullets.

What if you want to simply conserve ammo (I know, I know... you rich players think of bullets as peanuts) or as Disco said, you accidentally shot a couple of bullets (e.g. you tapped shoot, but then realised in the same moment that you wanted to use uzi's, or get the guy with M4 as he's running away)?
What I meant with the 2-3 second delay is it would basically determine if the sawnoff would have been reloaded when you switch it back. That way, people switching back to sawn-offs quickly will get punished for evading the sawnoff reload - others won't.

It sounds perfect.
Title: Re: Anti-2shot
Post by: Slice on November 02, 2010, 07:44:06 AM
Could someone try this:
Remember, it needs y_bit.inc from YSI (http://www.y-less.com/YSI/YSI_1.0.zip).

Code: [Select]
#include <a_samp>
#include <YSI/y_bit.inc>

#define FREEZE_TIME       (650) // The time a player will get froze after evading reload and switching back.
#define PUNISH_THRESOLD  (2500) // If the player doesn't switch back the weapon in <PUNISH_THRESOLD> ms, ignore it.
#define iPlayer  playerid

#pragma tabsize 0

new
BitArray:g_abIsSawnoffClipUsed< MAX_PLAYERS >,
BitArray:g_abThisBitchDidntReload< MAX_PLAYERS >,
g_iReloadEvadeTime[ MAX_PLAYERS ],
g_iSawnoffAmmo[ MAX_PLAYERS ],
g_cFiredShots[ MAX_PLAYERS char ],
g_cPreviousWeapon[ MAX_PLAYERS char ]
;

public OnPlayerSpawn( iPlayer )
{
g_iSawnoffAmmo[ iPlayer ] = -1;
g_cFiredShots{ iPlayer } = 0;
g_cPreviousWeapon{ iPlayer } = 0;

Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );
Bit_Vet( g_abThisBitchDidntReload, iPlayer );
}

public OnPlayerUpdate( iPlayer )
{
static
s_iState,
s_iSpecialAction
;

s_iState = GetPlayerState( iPlayer );
s_iSpecialAction = GetPlayerSpecialAction( iPlayer );

if ( s_iState == PLAYER_STATE_ONFOOT && ( s_iSpecialAction == SPECIAL_ACTION_NONE || s_iSpecialAction == SPECIAL_ACTION_DUCK ) )
{
static
s_iWeapon,
s_iAmmo
;

s_iWeapon = GetPlayerWeapon( iPlayer );
s_iAmmo = GetPlayerAmmo( iPlayer );

if ( g_cPreviousWeapon{ iPlayer } != s_iWeapon )
{
if ( g_cPreviousWeapon{ iPlayer } == WEAPON_SAWEDOFF )
{
if ( Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
{
static
s_iWeaponState
;

s_iWeaponState = GetPlayerWeaponState( iPlayer );

if ( ( s_iWeaponState == WEAPONSTATE_MORE_BULLETS || s_iWeaponState == WEAPONSTATE_LAST_BULLET ) && g_cFiredShots{ iPlayer } != 4 )
{
Bit_Let( g_abThisBitchDidntReload, iPlayer );

g_iReloadEvadeTime[ iPlayer ] = GetTickCount( );
}
}

g_cFiredShots{ iPlayer } = 0;
}
else if ( s_iWeapon == WEAPON_SAWEDOFF )
{
if ( Bit_Get( g_abThisBitchDidntReload, iPlayer ) )
{
if ( GetTickCount( ) - g_iReloadEvadeTime[ iPlayer ] < PUNISH_THRESOLD )
{
new
Float:fVX,
Float:fVY,
Float:fVZ
;

GetPlayerVelocity( iPlayer, fVX, fVY, fVZ );

if ( floatabs( fVZ ) < 0.15 )
{
ClearAnimations( iPlayer, 1 );

ApplyAnimation( playerid, "PED", "XPRESSscratch", 0.0, 1, 0, 0, 0, FREEZE_TIME, 1 );
}
}

Bit_Vet( g_abThisBitchDidntReload, iPlayer );
}
}

g_cPreviousWeapon{ iPlayer } = s_iWeapon;
}

if ( s_iWeapon == WEAPON_SAWEDOFF )
{
if ( g_iSawnoffAmmo[ iPlayer ] == -1 )
g_iSawnoffAmmo[ iPlayer ] = GetPlayerAmmo( iPlayer );
else
{
if ( GetPlayerWeaponState( iPlayer ) == WEAPONSTATE_RELOADING )
{
if ( Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );
}
else
{
if ( g_iSawnoffAmmo[ iPlayer ] != s_iAmmo )
{
if ( s_iAmmo < g_iSawnoffAmmo[ iPlayer ] )
{
Bit_Let( g_abIsSawnoffClipUsed, iPlayer );

g_cFiredShots{ iPlayer } += g_iSawnoffAmmo[ iPlayer ] - s_iAmmo;
}
else
{
g_cFiredShots{ iPlayer } = 0;

Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );
}

g_iSawnoffAmmo[ iPlayer ] = s_iAmmo;
}
}
}
}
else if ( g_iSawnoffAmmo[ iPlayer ] != -1 || Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
{
g_iSawnoffAmmo[ iPlayer ] = -1;

Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );

g_cFiredShots{ iPlayer } = 0;
}
}
else if ( g_iSawnoffAmmo[ iPlayer ] != -1 || Bit_Get( g_abIsSawnoffClipUsed, iPlayer ) )
{
g_iSawnoffAmmo[ iPlayer ] = -1;

Bit_Vet( g_abIsSawnoffClipUsed, iPlayer );

g_cFiredShots{ iPlayer } = 0;
}

return 1;
}
Title: Re: Anti-2shot
Post by: Fuse on November 02, 2010, 12:07:23 PM
Tried it.

When you 2shot and change to uzi nothing special happens.
But when you switch back to sawnoffs faster than about 2.5 seconds you get freezed.
If you change back to sawnoffs later than those 2.5 seconds you don't get freezed.
Title: Re: Anti-2shot
Post by: Slice on November 02, 2010, 02:03:07 PM
I guess it's working then, cheers.
Title: Re: Anti-2shot
Post by: [JOKER]Ya$N on November 06, 2010, 04:09:11 PM
Nice Script slice but i do not like freezing for example Check MTA anti 2shot
Title: Re: Anti-2shot
Post by: Slice on November 06, 2010, 04:41:47 PM
Nice Script slice but i do not like freezing for example Check MTA anti 2shot
I'm guessing the "anti-2shot" is their removal of quick reload. You can't do that with scripting in SA-MP..


PUNISH_THRESOLD should be lowered to 2000.
Title: Re: Anti-2shot
Post by: iMJets on November 07, 2010, 02:28:59 AM
im liking this a lot but sometimes i noticed if u 3 shot it does same thing (if u lag for a sec) but thats normal i would guess keep up the good work.
Title: Re: Anti-2shot
Post by: [JOKER]Miczi on November 08, 2010, 09:31:48 PM
I never looked on scripting this way xD


Code: [Select]
#include <a_samp>
 BitArray:g_abIsSawnoffClipUsed< MAX_PLAYERS >,
   BitArray:g_ab[b]ThisBitchDidntReload[/b]< MAX_PLAYERS >,
}


Back on topic: As Hazard I always thougt that 2 shot (double shot or two shot btw?) is about shooting infinite ammount of sawn bullets, I never seen a problem in 2shot-uzi-2shot-uzi. The script doesn't harm me in any way, same with others regulars, but what about newbies? When I was learning how to switch properly for a long time I made mistakes and shot only 2 bullets... They may be confused.
Title: Re: Anti-2shot
Post by: Gryphus_One on November 08, 2010, 09:58:20 PM
but what about newbies? When I was learning how to switch properly for a long time I made mistakes and shot only 2 bullets... They may be confused.

Hey this is an interesting point of view. Why don't you make the script to detect if you have shot more than 4 cartridges in a short time? This would also be useful against noreload cheaters.
.
Title: Re: Anti-2shot
Post by: [R]phil_mitchel on November 12, 2010, 12:05:17 PM
er, are u sure this is working cos about 6 diff idiots wer 2 shotting me yesterday n they didnt freeaze?
Title: Re: Anti-2shot
Post by: legolas3983 on November 12, 2010, 12:49:25 PM
er, are u sure this is working cos about 6 diff idiots wer 2 shotting me yesterday n they didnt freeaze?
I'm sure this working try it :P
Title: Re: Anti-2shot
Post by: Slice on November 12, 2010, 02:36:30 PM
I never looked on scripting this way xD


Code: [Select]
#include <a_samp>
 BitArray:g_abIsSawnoffClipUsed< MAX_PLAYERS >,
   BitArray:g_ab[b]ThisBitchDidntReload[/b]< MAX_PLAYERS >,
}


Back on topic: As Hazard I always thougt that 2 shot (double shot or two shot btw?) is about shooting infinite ammount of sawn bullets, I never seen a problem in 2shot-uzi-2shot-uzi. The script doesn't harm me in any way, same with others regulars, but what about newbies? When I was learning how to switch properly for a long time I made mistakes and shot only 2 bullets... They may be confused.
Good point; what about a simple message such as: "You were frozen for not reloading your sawnoff." ?
Title: Re: Anti-2shot
Post by: iMJets on November 12, 2010, 05:30:39 PM
yah the message would for sure help new people i would think. Plus you can always help them if there confused i like it
Title: Re: Anti-2shot
Post by: AJP on November 13, 2010, 01:07:14 AM
I'm guessing Slice will add this when he wants, since he's in the scripting team, Accepted.
Title: Re: Anti-2shot
Post by: Reny on November 13, 2010, 10:03:57 AM
I'm guessing Slice will add this when he wants, since he's in the scripting team, Accepted.
It has been implented for 2 weeks already.
Title: Re: [N]Anti-2shot
Post by: Disco on November 13, 2010, 10:14:39 AM
i like ponies