objects.pwn and secure guard script

This commit is contained in:
Lorenc 2016-12-21 02:28:30 +11:00
parent 32ed1002ee
commit b1d2089e18
2 changed files with 337 additions and 0 deletions

69
filterscripts/objects.pwn Normal file
View File

@ -0,0 +1,69 @@
/*
* SF Custom Objects
*
*
*/
#include <a_samp>
#include <streamer>
#include <zcmd>
#define SetObjectInvisible(%0) SetDynamicObjectMaterialText(%0, 0, " ", 140, "Arial", 64, 1, -32256, 0, 1)
stock tmpVariable;
public OnFilterScriptInit()
{
// Ignition.Von VIP LOUNGE ROOFTOP
CreateDynamicObject( 1569, -1855.294067, 862.399230, 34.210491, 0.000000, 0.000000, 0.000000 );
CreateDynamicObject( 1569, -1852.304077, 862.399230, 34.210491, 0.000000, 0.000000, 180.000000 );
CreateDynamicObject( 3524, -1853.853149, 862.732971, 34.907802, 6.899999, 0.000000, 0.000000 );
CreateDynamicObject( 1497, -1858.333862, 865.009277, 34.125236, 0.000000, 0.000000, 0.000000 );
CreateDynamicObject( 3525, -1851.911132, 862.262207, 35.646312, 0.000000, 0.000000, 0.000000 );
CreateDynamicObject( 3525, -1855.762329, 862.262207, 35.646312, 0.000000, 0.000000, 0.000000 );
CreateDynamicObject( 638, -1860.264160, 864.414672, 34.878009, 0.000000, 0.000000, 90.000000 );
CreateDynamicObject( 3850, -1860.221435, 863.861816, 34.721279, 0.000000, 0.000000, 90.000000 );
CreateDynamicObject( 3852, -1846.471069, 865.205017, 87.694641, 0.000000, 0.000000, 90.000000 );
CreateDynamicObject( 9241, -1831.487426, 889.527526, 87.865295, 0.000000, 0.000000, 0.000000 );
return 1;
}
CMD:dammenit(playerid, params[]) {
RemoveBuildingForPlayer(playerid, 713, -1920.1875, 882.1953, 34.1406, 0.25);
RemoveBuildingForPlayer(playerid, 649, -1990.3359, 866.3281, 45.2422, 0.25);
RemoveBuildingForPlayer(playerid, 649, -1990.3359, 863.8750, 45.2422, 0.25);
RemoveBuildingForPlayer(playerid, 1232, -1980.9063, 866.9375, 46.7813, 0.25);
RemoveBuildingForPlayer(playerid, 673, -1963.9375, 877.9766, 40.7266, 0.25);
RemoveBuildingForPlayer(playerid, 1232, -1961.0625, 875.3984, 43.6797, 0.25);
RemoveBuildingForPlayer(playerid, 715, -1956.3750, 877.7422, 49.0313, 0.25);
RemoveBuildingForPlayer(playerid, 673, -1950.0547, 876.2578, 37.2500, 0.25);
RemoveBuildingForPlayer(playerid, 1232, -1941.1875, 875.3984, 40.0469, 0.25);
RemoveBuildingForPlayer(playerid, 1232, -1928.0469, 875.3984, 37.0156, 0.25);
RemoveBuildingForPlayer(playerid, 673, -1926.3750, 878.5234, 34.1484, 0.25);
RemoveBuildingForPlayer(playerid, 649, -1913.0234, 868.8125, 36.4531, 0.25);
RemoveBuildingForPlayer(playerid, 649, -1913.0234, 864.8672, 36.4531, 0.25);
RemoveBuildingForPlayer(playerid, 649, -1913.0234, 870.9219, 36.4531, 0.25);
RemoveBuildingForPlayer(playerid, 1232, -1961.0625, 892.7266, 43.6797, 0.25);
RemoveBuildingForPlayer(playerid, 649, -1990.3359, 902.1250, 45.2422, 0.25);
RemoveBuildingForPlayer(playerid, 649, -1990.3359, 904.5781, 45.2422, 0.25);
RemoveBuildingForPlayer(playerid, 1232, -1980.9063, 901.7031, 46.7813, 0.25);
RemoveBuildingForPlayer(playerid, 673, -1956.5703, 886.2031, 40.7891, 0.25);
RemoveBuildingForPlayer(playerid, 673, -1950.0547, 887.5234, 37.2500, 0.25);
RemoveBuildingForPlayer(playerid, 673, -1927.5313, 888.5625, 34.1484, 0.25);
RemoveBuildingForPlayer(playerid, 1232, -1928.0469, 892.7266, 37.0156, 0.25);
RemoveBuildingForPlayer(playerid, 1232, -1941.1875, 892.7266, 40.0469, 0.25);
RemoveBuildingForPlayer(playerid, 1226, -1906.7188, 893.7422, 38.1484, 0.25);
RemoveBuildingForPlayer(playerid, 649, -1913.0234, 894.1094, 36.4531, 0.25);
RemoveBuildingForPlayer(playerid, 649, -1913.0234, 904.5781, 36.4531, 0.25);
RemoveBuildingForPlayer(playerid, 649, -1913.0234, 902.4688, 36.4531, 0.25);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}

268
npcmodes/secureguard.pwn Normal file
View File

@ -0,0 +1,268 @@
/*
*
*
* SECURITYGUARD01 - 04 = SF
* SECURITYGUARD05 - 07 = LV
* SECURITYGUARD08 - 10 = LS
*
*/
#include < a_npc >
#define IDLE_RECORDING ( "SECURITYGUARD_IDLE" )
#undef MAX_PLAYERS
#define MAX_PLAYERS ( 126 )
#define strmatch(%1,%2) (!strcmp(%1,%2,true))
/* ** Variables ** */
new t_NPCUpdate = 0xFFFF;
new bool: b_Paused = false;
new bool: b_Provoked = false;
new bool: b_Disabled = false;
new bool: b_Idle = false;
new bool: b_Robbed = false;
new iRecentTrack = -1;
new iIdleTS = 0;
new iRestartTS = 0;
/* ** Messages ** */
new
g_LeavingMessages[ ] [ ] =
{
{ "We've secured the security truck without any conflict." },
{ "Time for our team to take a coffee break." },
{ "Schedules have been met without conflict." },
{ "Our team is now going off-duty." }
},
g_JoiningMessages[ ] [ ] =
{
{ "We are now sending a security truck to deliver cash." },
{ "Our team has came back from their coffee break." },
{ "A new schedule to deliver cash to ATMs has been made." },
{ "Our team is now on duty and making deliveries." }
},
g_RobbedMessages[ ] [ ] =
{
{ "Our systems detect that our convoy have been intruded." },
{ "We have lost connection with our scheduled security truck." },
{ "Our security truck has went missing and failed its schedules." },
{ "We have had our security truck towed away due to a robbery." }
}
;
/* ** Events ** */
public OnSecurityGuardUpdate( );
main( ) { }
public OnNPCModeInit( )
{
t_NPCUpdate = SetTimer( "OnSecurityGuardUpdate", 500, true );
return 1;
}
public OnNPCModeExit( )
{
KillTimer( t_NPCUpdate );
return 1;
}
public OnNPCDisconnect( reason[ ] )
{
resetNPCData( );
return 1;
}
public OnRecordingPlaybackEnd( )
{
if( b_Idle ) {
// Constant idle at 2K, 2K, 2K
StartRecordingPlayback( PLAYER_RECORDING_TYPE_DRIVER, IDLE_RECORDING );
return 1;
}
SetMeIdleForRestart( );
return 1;
}
public OnNPCSpawn( )
{
GenerateNewPlayback( );
return 1;
}
public OnPlayerText( playerid, text[ ] )
{
return 1;
}
public OnClientMessage( color, text[ ] )
{
if( !strcmp( text, "[0x00][NPC] TRUCK DISABLED." ) && color == 0x112233FF )
{
if( !b_Disabled ) {
b_Disabled = true;
PauseRecordingPlayback( );
//SendChat( "I can't move my truck? What the hell..." );
}
return 1;
}
if( !strcmp( text, "[0x01][NPC] PROVOKED." ) && color == 0x112233FF )
{
if( !b_Provoked ) {
if( b_Paused ) {
b_Paused = false;
ResumeRecordingPlayback( );
}
b_Provoked = true;
//SendChat( "What...? Gunfire? Oh. Shit!" );
}
return 1;
}
if( !strcmp( text, "[0x02] RESTART." ) && color == 0x112233FF )
{
b_Robbed = true;
iIdleTS = gettime( ) + 10;
return 1;
}
if( !strcmp( text, "[0x03] 300 SECOND START." ) && color == 0x112233FF )
{
iRestartTS = gettime( ) + 300;
return 1;
}
return 1;
}
public OnSecurityGuardUpdate( )
{
new
time = gettime( );
if( !( b_Disabled || b_Provoked || b_Idle ) ) {
new
hasAnyPlayersInfront = IsAnyPlayerInfrontOfMe( )
;
if( hasAnyPlayersInfront )
{
if( b_Paused == false ) {
PauseRecordingPlayback( );
b_Paused = true;
}
}
else
{
if( b_Paused == true ) {
ResumeRecordingPlayback( );
b_Paused = false;
}
}
}
else
{
if( time > iRestartTS && iRestartTS != 0 && b_Idle == true ) {
GenerateNewPlayback( );
return 1;
}
if( time > iIdleTS && iIdleTS != 0 ) {
SetMeIdleForRestart( );
return 1;
}
}
return 1;
}
public OnNPCEnterVehicle( vehicleid, seatid )
{
return 1;
}
public OnNPCExitVehicle()
{
return 1;
}
// Functions
stock SetMeIdleForRestart( ) {
if( b_Idle )
return;
b_Idle = true;
iIdleTS = 0;
SendChat( "End Security Guard" );
if( !b_Robbed )
SendChat( g_LeavingMessages[ random( sizeof( g_LeavingMessages ) ) ] );
else
SendChat( g_RobbedMessages[ random( sizeof( g_RobbedMessages ) ) ] );
StopRecordingPlayback( );
StartRecordingPlayback( PLAYER_RECORDING_TYPE_DRIVER, IDLE_RECORDING );
}
stock resetNPCData( ) {
b_Paused = false;
b_Provoked = false;
b_Disabled = false;
b_Idle = false;
b_Robbed = false;
iRestartTS = 0;
iIdleTS = 0;
iRecentTrack= -1;
}
stock GenerateNewPlayback( ) {
new
szLocation[ 16 ], iRandom;
find_track:
if( ( iRandom = random( 11 ) ) == iRecentTrack ) {
goto find_track;
}
SendChat( g_JoiningMessages[ random( sizeof( g_JoiningMessages ) ) ] );
format( szLocation, sizeof( szLocation ), "SECURITYGUARD%02d", iRandom );
StopRecordingPlayback( );
StartRecordingPlayback( PLAYER_RECORDING_TYPE_DRIVER, szLocation );
resetNPCData( ); // Reset data last, because bugs can incur.
iRecentTrack = iRandom; // So unique plays each time.
}
stock IsAnyPlayerInfrontOfMe( )
{
new Float: X, Float: Y, Float: Z;
for ( new i = 0; i < MAX_PLAYERS; i++ )
{
if ( !IsPlayerConnected( i ) || !IsPlayerStreamedIn( i ) )
continue;
new
iState = GetPlayerState( i );
if( iState == PLAYER_STATE_ONFOOT || iState == PLAYER_STATE_DRIVER ) {
GetXYInfrontOfMe( 10.0, X, Y, Z );
return IsPlayerInRangeOfPoint( i, 10.0, X, Y, Z );
}
}
return 0;
}
stock GetXYInfrontOfMe( Float:distance, &Float: x, &Float: y, &Float: z )
{
static
Float: angle;
GetMyPos( x, y, z );
GetMyFacingAngle( angle );
x += ( distance * floatsin( -angle, degrees ) );
y += ( distance * floatcos( -angle, degrees ) );
}