move house, biz, entrance cp handling into module

This commit is contained in:
Lorenc Pekaj 2019-01-02 00:51:00 +11:00
parent 8fae418c13
commit f1b41098c3
4 changed files with 100 additions and 129 deletions

View File

@ -59,6 +59,7 @@
#include "irresistible\cnr\features\hotel_da_novic.pwn"
#include "irresistible\cnr\features\random_hits.pwn"
#include "irresistible\cnr\features\c4.pwn"
#include "irresistible\cnr\features\tax.pwn"
// pool
#include "irresistible\cnr\features\pool.pwn"

View File

@ -1274,6 +1274,50 @@ hook OnPlayerDisconnect( playerid, reason )
return 1;
}
hook OnPlayerEnterDynamicCP( playerid, checkpointid )
{
if ( CanPlayerExitEntrance( playerid ) && ! IsPlayerInAnyVehicle( playerid ) )
{
// Enter Business
foreach ( new b : business )
{
if ( checkpointid == g_businessData[ b ] [ E_ENTER_CP ] )
{
if ( p_Class[ playerid ] != CLASS_CIVILIAN )
return SendError( playerid, "You must be a civilian to access this business." );
if ( g_iTime > g_businessData[ b ] [ E_CRACKED_TS ] && g_businessData[ b ] [ E_CRACKED ] )
g_businessData[ b ] [ E_CRACKED ] = false; // The Virus Is Disabled.
if ( ! g_businessData[ b ] [ E_CRACKED ] && ! IsBusinessAssociate( playerid, b ) ) {
CallLocalFunction( "OnPlayerAttemptBreakIn", "ddd", playerid, -1, b ); // attempting a break in as a burglar/cop
return SendError( playerid, "You cannot access this business as you are not an associate of it." );
}
new
bType = g_businessData[ b ] [ E_INTERIOR_TYPE ];
pauseToLoad( playerid );
p_InBusiness[ playerid ] = b;
UpdatePlayerEntranceExitTick( playerid );
SetPlayerPos( playerid, g_businessInteriorData[ bType ] [ E_X ], g_businessInteriorData[ bType ] [ E_Y ], g_businessInteriorData[ bType ] [ E_Z ] );
SetPlayerVirtualWorld( playerid, g_businessData[ b ] [ E_WORLD ] );
SetPlayerInterior( playerid, g_businessData[ b ] [ E_INTERIOR_TYPE ] + 20 );
return 1;
}
else if ( checkpointid == g_businessData[ b ] [ E_EXIT_CP ] )
{
p_InBusiness[ playerid ] = -1;
TogglePlayerControllable( playerid, 0 );
UpdatePlayerEntranceExitTick( playerid );
SetTimerEx( "ope_Unfreeze", 1250, false, "d", playerid );
SetPlayerPosEx( playerid, g_businessData[ b ] [ E_X ], g_businessData[ b ] [ E_Y ], g_businessData[ b ] [ E_Z ], 0 ), SetPlayerVirtualWorld( playerid, 0 );
}
}
}
return 1;
}
/* ** Threads ** */
thread OnBusinessLoad( )
{

View File

@ -368,6 +368,61 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
return 1;
}
hook OnPlayerEnterDynamicCP( playerid, checkpointid )
{
if ( CanPlayerExitEntrance( playerid ) && ! IsPlayerInAnyVehicle( playerid ) )
{
// Enter Houses
foreach ( new i : houses )
{
if ( checkpointid == g_houseData[ i ] [ E_CHECKPOINT ] [ 0 ] )
{
ClearAnimations( playerid ); // clear-fix
if ( IsHouseOnFire( i ) ) {
return SendError( playerid, "This house is on fire, you cannot enter it!" ), 1;
}
if ( GetPlayerSpecialAction( playerid ) == SPECIAL_ACTION_CUFFED ) {
return SendError( playerid, "You can't do anything as you are cuffed." ), 1;
}
if ( g_iTime > g_houseData[ i ] [ E_CRACKED_TS ] && g_houseData[ i ] [ E_CRACKED ] )
g_houseData[ i ] [ E_CRACKED ] = false; // The Virus Is Disabled.
new is_owner = strmatch( g_houseData[ i ] [ E_OWNER ], ReturnPlayerName( playerid ) );
if ( ! g_houseData[ i ] [ E_CRACKED ] && ! strmatch( g_houseData[ i ] [ E_PASSWORD ], "N/A" ) && ! is_owner )
{
p_PasswordedHouse[ playerid ] = i;
CallLocalFunction( "OnPlayerAttemptBreakIn", "ddd", playerid, i, -1 ); // attempting a break in as a burglar/cop
ShowPlayerDialog( playerid, DIALOG_HOUSE_PW, DIALOG_STYLE_PASSWORD, "{FFFFFF}House Authentication", ""COL_GREEN"This house is password locked!\n"COL_WHITE"You may only enter this house if you enter the correct password.", "Enter", "Cancel" );
return 1;
}
p_InHouse[ playerid ] = i;
UpdatePlayerEntranceExitTick( playerid );
SetPlayerVirtualWorld( playerid, g_houseData[ i ] [ E_WORLD ] );
SetPlayerInterior( playerid, g_houseData[ i ] [ E_INTERIOR_ID ] );
SetPlayerPos( playerid, g_houseData[ i ] [ E_TX ], g_houseData[ i ] [ E_TY ], g_houseData[ i ] [ E_TZ ] );
CallLocalFunction( "OnPlayerEnterHouse", "dd", playerid, i );
return 1;
}
else if ( checkpointid == g_houseData[ i ] [ E_CHECKPOINT ] [ 1 ] )
{
p_InHouse[ playerid ] = -1;
CancelEdit( playerid );
TogglePlayerControllable( playerid, 0 );
UpdatePlayerEntranceExitTick( playerid );
SetTimerEx( "ope_Unfreeze", 1250, false, "d", playerid );
SetPlayerPosEx( playerid, g_houseData[ i ] [ E_EX ], g_houseData[ i ] [ E_EY ], g_houseData[ i ] [ E_EZ ], 0 ), SetPlayerVirtualWorld( playerid, 0 );
return 1;
}
}
}
return 1;
}
/* ** Commands ** */
CMD:house( playerid, params[ ] ) return cmd_h( playerid, params );
CMD:h( playerid, params[ ] )

View File

@ -4494,135 +4494,6 @@ public OnPlayerEnterDynamicCP( playerid, checkpointid )
if ( checkpointid == g_Checkpoints[ CP_PAINTBALL ] )
return listPaintBallLobbies( playerid );
if ( CanPlayerExitEntrance( playerid ) )
{
if ( ! IsPlayerInAnyVehicle( playerid ) )
{
// Enter Business
foreach ( new b : business )
{
if ( checkpointid == g_businessData[ b ] [ E_ENTER_CP ] )
{
if ( p_Class[ playerid ] != CLASS_CIVILIAN )
return SendError( playerid, "You must be a civilian to access this business." );
if ( g_iTime > g_businessData[ b ] [ E_CRACKED_TS ] && g_businessData[ b ] [ E_CRACKED ] )
g_businessData[ b ] [ E_CRACKED ] = false; // The Virus Is Disabled.
if ( ! g_businessData[ b ] [ E_CRACKED ] && ! IsBusinessAssociate( playerid, b ) ) {
CallLocalFunction( "OnPlayerAttemptBreakIn", "ddd", playerid, -1, b ); // attempting a break in as a burglar/cop
return SendError( playerid, "You cannot access this business as you are not an associate of it." );
}
new
bType = g_businessData[ b ] [ E_INTERIOR_TYPE ];
pauseToLoad( playerid );
p_InBusiness[ playerid ] = b;
UpdatePlayerEntranceExitTick( playerid );
SetPlayerPos( playerid, g_businessInteriorData[ bType ] [ E_X ], g_businessInteriorData[ bType ] [ E_Y ], g_businessInteriorData[ bType ] [ E_Z ] );
SetPlayerVirtualWorld( playerid, g_businessData[ b ] [ E_WORLD ] );
SetPlayerInterior( playerid, g_businessData[ b ] [ E_INTERIOR_TYPE ] + 20 );
return 1;
}
else if ( checkpointid == g_businessData[ b ] [ E_EXIT_CP ] )
{
p_InBusiness[ playerid ] = -1;
TogglePlayerControllable( playerid, 0 );
UpdatePlayerEntranceExitTick( playerid );
SetTimerEx( "ope_Unfreeze", 1250, false, "d", playerid );
SetPlayerPosEx( playerid, g_businessData[ b ] [ E_X ], g_businessData[ b ] [ E_Y ], g_businessData[ b ] [ E_Z ], 0 ), SetPlayerVirtualWorld( playerid, 0 );
}
}
// Enter Houses
foreach ( new i : houses )
{
if ( checkpointid == g_houseData[ i ] [ E_CHECKPOINT ] [ 0 ] )
{
ClearAnimations( playerid ); // clear-fix
if ( IsHouseOnFire( i ) ) {
return SendError( playerid, "This house is on fire, you cannot enter it!" ), 1;
}
if ( GetPlayerSpecialAction( playerid ) == SPECIAL_ACTION_CUFFED ) {
return SendError( playerid, "You can't do anything as you are cuffed." ), 1;
}
if ( g_iTime > g_houseData[ i ] [ E_CRACKED_TS ] && g_houseData[ i ] [ E_CRACKED ] )
g_houseData[ i ] [ E_CRACKED ] = false; // The Virus Is Disabled.
new is_owner = strmatch( g_houseData[ i ] [ E_OWNER ], ReturnPlayerName( playerid ) );
if ( ! g_houseData[ i ] [ E_CRACKED ] && ! strmatch( g_houseData[ i ] [ E_PASSWORD ], "N/A" ) && ! is_owner )
{
p_PasswordedHouse[ playerid ] = i;
CallLocalFunction( "OnPlayerAttemptBreakIn", "ddd", playerid, i, -1 ); // attempting a break in as a burglar/cop
ShowPlayerDialog( playerid, DIALOG_HOUSE_PW, DIALOG_STYLE_PASSWORD, "{FFFFFF}House Authentication", ""COL_GREEN"This house is password locked!\n"COL_WHITE"You may only enter this house if you enter the correct password.", "Enter", "Cancel" );
return 1;
}
p_InHouse[ playerid ] = i;
UpdatePlayerEntranceExitTick( playerid );
SetPlayerVirtualWorld( playerid, g_houseData[ i ] [ E_WORLD ] );
SetPlayerInterior( playerid, g_houseData[ i ] [ E_INTERIOR_ID ] );
SetPlayerPos( playerid, g_houseData[ i ] [ E_TX ], g_houseData[ i ] [ E_TY ], g_houseData[ i ] [ E_TZ ] );
CallLocalFunction( "OnPlayerEnterHouse", "dd", playerid, i );
return 1;
}
else if ( checkpointid == g_houseData[ i ] [ E_CHECKPOINT ] [ 1 ] )
{
p_InHouse[ playerid ] = -1;
CancelEdit( playerid );
TogglePlayerControllable( playerid, 0 );
UpdatePlayerEntranceExitTick( playerid );
SetTimerEx( "ope_Unfreeze", 1250, false, "d", playerid );
SetPlayerPosEx( playerid, g_houseData[ i ] [ E_EX ], g_houseData[ i ] [ E_EY ], g_houseData[ i ] [ E_EZ ], 0 ), SetPlayerVirtualWorld( playerid, 0 );
return 1;
}
}
foreach ( new i : entrances )
{
if ( checkpointid == g_entranceData[ i ] [ E_ENTER ] )
{
if ( ! CallLocalFunction( "OnPlayerAccessEntrance", "dddd", playerid, i, g_entranceData[ i ] [ E_WORLD ], g_entranceData[ i ] [ E_INTERIOR ] ) ) break;
p_LastEnteredEntrance[ playerid ] = i;
SetPlayerInterior( playerid, g_entranceData[ i ] [ E_INTERIOR ] );
SetPlayerVirtualWorld( playerid, g_entranceData[ i ] [ E_WORLD ] );
SetPlayerPos( playerid, g_entranceData[ i ] [ E_LX ], g_entranceData[ i ] [ E_LY ], g_entranceData[ i ] [ E_LZ ] );
UpdatePlayerEntranceExitTick( playerid );
if ( g_entranceData[ i ] [ E_CUSTOM ] )
{
pauseToLoad( playerid );
p_BulletInvulnerbility[ playerid ] = g_iTime + 6; // Additional 3 because of pausetoload
}
else
{
TogglePlayerControllable( playerid, 0 );
SetTimerEx( "ope_Unfreeze", 1250, false, "d", playerid );
p_BulletInvulnerbility[ playerid ] = g_iTime + 3;
}
SyncSpectation( playerid );
return 1;
}
else if ( checkpointid == g_entranceData[ i ] [ E_EXIT ] )
{
p_BulletInvulnerbility[ playerid ] = 0;
p_LastEnteredEntrance[ playerid ] = -1;
SetPlayerPos( playerid, g_entranceData[ i ] [ E_EX ], g_entranceData[ i ] [ E_EY ], g_entranceData[ i ] [ E_EZ ] );
SetPlayerInterior( playerid, 0 );
TogglePlayerControllable( playerid, 0 );
SetTimerEx( "ope_Unfreeze", 1250, false, "d", playerid );
SetPlayerVirtualWorld( playerid, 0 );
UpdatePlayerEntranceExitTick( playerid );
SyncSpectation( playerid );
return 1;
}
}
}
}
return 1;
}