[FilterScript] anti weapon change when realoding!
#1

Hi,

I made a little protect of course post where is mistakes or buggs:

Код:
new Currentweaponrealong[ MAX_PLAYERS ];
new bool:Isrealoding[ MAX_PLAYERS ];
new Printttime[ MAX_PLAYERS ];
public OnPlayerUpdate(playerid)
{
	if(!IsPlayerConnected(playerid)) return 0;
	if(IsPlayerNPC(playerid)) return 1;
	
	if( GetPlayerWeaponState(playerid) == WEAPONSTATE_RELOADING )
	{
	    if( Isrealoding[ playerid ] == false )
	    {
	        Printttime[ playerid ] = gettime( );
		    Isrealoding[ playerid ] = true;
		    Currentweaponrealong[ playerid ] = GetPlayerWeapon( playerid );
		}
	}
	else
	{
	    if( Isrealoding[ playerid ] == true )
	    {
	        if( IsWeaponFireable( Currentweaponrealong[ playerid ] ) )
		    {
		        if( gettime( ) - Printttime[ playerid ] < 2 )
		        {
		            DoActionsForSwitchWeapons( playerid );
		        }
		    }
	        Isrealoding[ playerid ] = false;
	    }
	}
}
Somewhere in end of gamemode near other stocks:

Код:
new Warningsforswitchingsweapons[ MAX_PLAYERS ];
stock DoActionsForSwitchWeapons( playerid )
{
	if( GetPlayerWeapon( playerid ) != Currentweaponrealong[ playerid ] )
 	{
  		new weapons[13][2];
		new bool:IsThereThatweapon;
		for (new i = 0; i <= 12; i++)
		{
  			GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);

			if( weapons[i][0] == Currentweaponrealong[ playerid ] )
   			{
      			IsThereThatweapon = true;
   			}
		}
		if( IsThereThatweapon == true )
		{
			SetPlayerArmedWeapon( playerid, Currentweaponrealong[ playerid ] );
			
			if( GetPlayerWeapon( playerid ) != Currentweaponrealong[ playerid ] )
			{
			    Kick( playerid );
			}
			else
			{
				SendClientMessage( playerid, COLOR_RED,"* Please do not change your weapons when realoding! Otherwise you will by kicked");

				Warningsforswitchingsweapons[ playerid ] ++;

				if( Warningsforswitchingsweapons[ playerid ] >= 10 )
				{
					Kick( playerid );
				}
			}
  		}
   	}
}
If weapon fireable function:

Код:
stock IsWeaponFireable(weaponid)
{
	switch (weaponid)
	{
		case 0..15, 40, 44..46: return false;
	}
	return true;
}
In OnPlayerConnect

Код:
Currentweaponrealong[ playerid ] = 0;
Isrealoding[ playerid ] = false;
Reply
#2

make them on pastebin or anything else..
bcz it's seems like Tut not filescript
anyway goodjob
Reply
#3

I'm quite sure it's copied from somewhere
Reply
#4

Quote:
Originally Posted by Shinja
Посмотреть сообщение
I'm quite sure it's copied from somewhere
100 proc. no. Please find similar
Reply
#5

Код:
new Printttime[ playerid ];
needs to be

Код:
new Printttime[ MAX_PLAYERS ];
Reply
#6

Good Job!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)