05.08.2011, 22:19
can anyone plz make this protect cmd working with ladmin script i tried to do it although the rockkets work but the cmd /aaprotect is not plz help me this is the filterscript:
and by the way my game mode is satdm v9 .
pawn Код:
//==============================================================================
#include <a_samp>
//==============================================================================
#define ROCKET_FIRE_DISTANCE 350 // The distance at which the automatic rocket launchers fire
#define ROCKET_SPEED 200 // The speed the rockets travel at
new bool: ROCKET_SHOOT_ADMINS = true; // If false, admins will not be shot by these
//==============================================================================
new MAX_ROCKETS;
new RocketObjects [ 100 ];
new Float: RocketDestination [ 100 ] [ 3 ];
new Float: RocketPositions [ 100 ] [ 3 ];
//==============================================================================
new Attackable [ MAX_PLAYERS ];
//==============================================================================
new string [ 255 ];
//==============================================================================
forward RocketLaunchUpdate ( );
//==============================================================================
stock strtok(const str[], &index,seperator=' ')
{
new length = strlen(str);
new offset = index;
new result[255];
while ((index < length) && (str[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = str[index];
index++;
}
result[index - offset] = EOS;
if ((index < length) && (str[index] == seperator))
{
index++;
}
return result;
}
//==============================================================================
public OnFilterScriptInit ( )
{
print ( "||================================||" );
print ( "|| Anti Aircraft Launcher ||" );
print ( "|| Created By ||" );
print ( "|| WrathOfGenesis (FUDDS) ||" );
print ( "|| LOADED ||" );
print ( "||================================||" );
CreateRocketLauncher ( 237.6238 , 1696.6665 , 24.8484 ); // The following are the coords for the SAM launchers around A69
CreateRocketLauncher ( 237.6238 , 1696.6665 , 24.8484 ); // Each is written 4 times to allow each coord to fire 4 seperate rockets
CreateRocketLauncher ( 237.6238 , 1696.6665 , 24.8484 );
CreateRocketLauncher ( 237.6238 , 1696.6665 , 24.8484 );
CreateRocketLauncher ( 015.6360 , 1719.1989 , 24.8484 );
CreateRocketLauncher ( 015.6360 , 1719.1989 , 24.8484 );
CreateRocketLauncher ( 015.6360 , 1719.1989 , 24.8484 );
CreateRocketLauncher ( 015.6360 , 1719.1989 , 24.8484 );
CreateRocketLauncher ( 188.3158 , 2081.5789 , 24.8484 );
CreateRocketLauncher ( 188.3158 , 2081.5789 , 24.8484 );
CreateRocketLauncher ( 188.3158 , 2081.5789 , 24.8484 );
CreateRocketLauncher ( 188.3158 , 2081.5789 , 24.8484 );
CreateRocketLauncher ( 354.3714 , 2028.2911 , 24.8484 );
CreateRocketLauncher ( 354.3714 , 2028.2911 , 24.8484 );
CreateRocketLauncher ( 354.3714 , 2028.2911 , 24.8484 );
CreateRocketLauncher ( 354.3714 , 2028.2911 , 24.8484 );
SetTimer ( "RocketLaunchUpdate" , 250 , true );
return 1;
}
//==============================================================================
public OnFilterScriptExit ( )
{
print ( "||================================||" );
print ( "|| Anti Aircraft Launcher ||" );
print ( "|| UNLOADED ||" );
print ( "||================================||" );
for ( new rocketid = 0; rocketid < MAX_ROCKETS; rocketid ++ )
{
if ( IsValidObject ( RocketObjects [ rocketid ] ) )
{
DestroyObject ( RocketObjects [ rocketid ] );
}
}
return 1;
}
//==============================================================================
public OnPlayerConnect ( playerid )
{
Attackable [ playerid ] = 1;
return 1;
}
//==============================================================================
public OnPlayerDisconnect ( playerid )
{
Attackable [ playerid ] = 1;
return 1;
}
//==============================================================================
public OnPlayerCommandText ( playerid , cmdtext [ ] )
{
new cmd [ 256 ] , idx , tmp [ 256 ] , giveplayerid;
cmd = strtok ( cmdtext , idx );
tmp = strtok ( cmdtext , idx );
if ( strcmp ( cmd , "/AAProtect" , true ) == 0 && IsPlayerAdmin ( playerid ) )
{
if ( ! strlen ( tmp ) )
{
SendClientMessage ( playerid , 0xFF0000FF , "USAGE: '/AAProtect [playerid]'." );
return 1;
}
giveplayerid = strval ( tmp );
if ( ! IsPlayerConnected ( playerid ) )
{
SendClientMessage ( playerid , 0xFF0000FF , "Invalid playerid." );
return 1;
}
Attackable [ giveplayerid ] = 0;
format ( string , sizeof ( string ) , "* %s can no longer be attacked by the Anti Aircraft launchers." , GetName ( giveplayerid ) );
SendClientMessage ( playerid , 0x00FF00FF , string );
SendClientMessage ( giveplayerid , 0x00FF00FF , "* You can no longer be attacked by the Anti Aircraft launchers." );
return 1;
}
if ( strcmp ( cmd , "/AAUnprotect" , true ) == 0 && IsPlayerAdmin ( playerid ) )
{
if ( ! strlen ( tmp ) )
{
SendClientMessage ( playerid , 0xFF0000FF , "USAGE: '/AAUnprotect [playerid]'." );
return 1;
}
giveplayerid = strval ( tmp );
if ( ! IsPlayerConnected ( playerid ) )
{
SendClientMessage ( playerid , 0xFF0000FF , "Invalid playerid." );
return 1;
}
Attackable [ giveplayerid ] = 1;
format ( string , sizeof ( string ) , "* %s can now be attacked by the Anti Aircraft launchers." , GetName ( giveplayerid ) );
SendClientMessage ( playerid , 0xFF0000FF , string );
SendClientMessage ( giveplayerid , 0xFF0000FF , "* You can now be attacked by the Anti Aircraft launchers." );
return 1;
}
return 0;
}
//==============================================================================
stock GetName ( playerid )
{
GetPlayerName ( playerid , string , MAX_PLAYER_NAME );
return string ;
}
//==============================================================================
stock GetXYInFrontOfPlayer ( playerid , &Float: X , &Float: Y , Float: Distance )
{
new Float: Angle;
GetPlayerPos ( playerid , X , Y , Angle );
GetPlayerFacingAngle ( playerid , Angle );
if ( IsPlayerInAnyVehicle ( playerid ) )
{
GetVehicleZAngle ( GetPlayerVehicleID ( playerid ) , Angle );
}
X += ( Distance * floatsin ( - Angle , degrees ) );
Y += ( Distance * floatcos ( - Angle , degrees ) );
return 1;
}
//==============================================================================
stock IsAircraft ( vehicleid )
{
switch ( GetVehicleModel ( vehicleid ) )
{
case
465,425,417,497,563,592,
548,577,511,512,501,447,
460,513,520,469,487,488,
553,464,476,519,593,539
:
{
return 1;
}
}
return 0;
}
//==============================================================================
stock Float: GetDistanceBetweenTwoPoints ( Float: x1 , Float: y1 , Float: z1 , Float: x2 , Float: y2 , Float: z2 )
{
return floatsqroot ( floatpower ( floatabs ( floatsub ( x2 , x1 ) ) , 2 ) + floatpower ( floatabs ( floatsub ( y2 , y1 ) ) , 2 ) + floatpower ( floatabs ( floatsub ( z2 , z1 ) ) , 2 ) );
}
//==============================================================================
stock Float: GetDistanceToPoint ( playerid , Float: X ,Float: Y , Float: Z )
{
new Float: TempDist;
new Float: PX , Float: PY ,Float: PZ;
GetPlayerPos ( playerid , PX , PY , PZ );
TempDist = floatsqroot ( ( X - PX ) * ( X - PX ) + ( Y - PY ) * ( Y - PY ) + ( Z - PZ ) * ( Z - PZ ) );
return TempDist;
}
//==============================================================================
stock GetClosestPlayerToPosition ( Float: X , Float: Y , Float: Z )
{
new Float: TempDist , Float: Dist = 999999.99 , Closest = 999999;
for ( new playerid = 0; playerid < MAX_PLAYERS; playerid ++ )
{
if ( IsPlayerConnected ( playerid ) )
{
TempDist = GetDistanceToPoint ( playerid , X , Y , Z );
if ( TempDist < Dist )
{
Closest = playerid;
Dist = TempDist;
}
}
}
return Closest;
}
//==============================================================================
stock CreateRocketLauncher ( Float: X , Float: Y , Float: Z )
{
RocketPositions [ MAX_ROCKETS ] [ 0 ] = X;
RocketPositions [ MAX_ROCKETS ] [ 1 ] = Y;
RocketPositions [ MAX_ROCKETS ] [ 2 ] = Z;
MAX_ROCKETS = MAX_ROCKETS + 1;
return MAX_ROCKETS - 1;
}
//==============================================================================
public RocketLaunchUpdate ( )
{
new Float: X , Float: Y , Float: Z , Fired;
for ( new rocketid = 0; rocketid < MAX_ROCKETS; rocketid ++ )
{
if ( IsValidObject ( RocketObjects [ rocketid ] ) )
{
GetObjectPos ( RocketObjects [ rocketid ] , X , Y , Z );
if ( GetDistanceBetweenTwoPoints ( X , Y , Z , RocketDestination [ rocketid ] [ 0 ] , RocketDestination [ rocketid ] [ 1 ] , RocketDestination [ rocketid ] [ 2 ] ) < 5 )
{
DestroyObject ( RocketObjects [ rocketid ] );
CreateExplosion ( X , Y , Z , 00 , 5 );
CreateExplosion ( X , Y , Z , 07 , 5 );
CreateExplosion ( X , Y , Z , 06 , 5 );
CreateExplosion ( X , Y , Z , 13 , 5 );
}
}
else
{
if ( Fired == 0 )
{
if ( IsPlayerConnected ( GetClosestPlayerToPosition ( Float: X , Float: Y , Float: Z ) ) )
{
new playerid = GetClosestPlayerToPosition ( Float: X , Float: Y , Float: Z );
if ( GetDistanceToPoint ( playerid , RocketPositions [ rocketid ] [ 0 ] , RocketPositions [ rocketid ] [ 1 ] , RocketPositions [ rocketid ] [ 2 ] ) < ROCKET_FIRE_DISTANCE && IsAircraft ( GetPlayerVehicleID ( playerid ) ) && Attackable [ playerid ] == 1 )
{
if ( ! IsPlayerAdmin ( playerid ) || ROCKET_SHOOT_ADMINS == true )
{
GetPlayerPos ( playerid , X , Y , Z );
GetXYInFrontOfPlayer ( playerid , X , Y , 50 );
RocketDestination [ rocketid ] [ 0 ] = X - 20 + random ( 40 );
RocketDestination [ rocketid ] [ 1 ] = Y - 20 + random ( 40 );
RocketDestination [ rocketid ] [ 2 ] = Z - 20 + random ( 40 );
RocketObjects [ rocketid ] = CreateObject ( 354 , RocketPositions [ rocketid ] [ 0 ] , RocketPositions [ rocketid ] [ 1 ] , RocketPositions [ rocketid ] [ 2 ] , 0 , 0 , 0 );
MoveObject ( RocketObjects [ rocketid ] , RocketDestination [ rocketid ] [ 0 ] , RocketDestination [ rocketid ] [ 1 ] , RocketDestination [ rocketid ] [ 2 ] , ROCKET_SPEED );
Fired = 1;
}
}
}
}
}
}
return 1;
}
//==============================================================================