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
-
No more 2shot with this! Needs y_bit.inc from YSI (http://www.y-less.com/YSI/YSI_1.0.zip).
#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.
-
i suggested this along time ago and it was said to be not possible i knew it was lol
-
+10²³²³
The question is now: Does this work?
-
+10²³²³
The question is now: Does this work?
If Slice scripted it,there's no doubt about it :)
Good job.
-
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
-
That is very good for server and bad for abuser :P gj ;)
-
Nice work slice, you think in smart ways that i would never be able do :)
Cool script
-
slaice gw
-
that was fast nice to see it implemented
-
that was fast nice to see it implemented
Is it already implemented?? :o
I'm gonna try it...
EDIT: no it's not implemented.
.
-
yes it is gryphus it freezes u if u 2 shot and u can take damage
-
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.)
-
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 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 :)
-
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
-
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.
-
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 ...
-
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.
-
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
-
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.
-
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.
-
Could someone try this:
Remember, it needs y_bit.inc from YSI (http://www.y-less.com/YSI/YSI_1.0.zip).
#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;
}
-
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.
-
I guess it's working then, cheers.
-
Nice Script slice but i do not like freezing for example Check MTA anti 2shot
-
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.
-
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.
-
I never looked on scripting this way xD
#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.
-
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.
.
-
er, are u sure this is working cos about 6 diff idiots wer 2 shotting me yesterday n they didnt freeaze?
-
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
-
I never looked on scripting this way xD
#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." ?
-
yah the message would for sure help new people i would think. Plus you can always help them if there confused i like it
-
I'm guessing Slice will add this when he wants, since he's in the scripting team, Accepted.
-
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.
-
i like ponies