passive mode (and spawn protection) placed in passive_mode.pwn

This commit is contained in:
Lorenc Pekaj 2018-12-22 23:08:20 +11:00
parent 1736bfd849
commit e6996d4bb0
7 changed files with 184 additions and 223 deletions

View File

@ -52,3 +52,5 @@
- Called when a player is unloading textdraws (on death, request class...)
- `OnPlayerC4Blown( playerid, Float: X, Float: Y, Float: Z, worldid )`
- Called when a player C4 is blown
- `OnPlayerUnjailed( playerid, reasonid )`
- Called when a player is unjailed for a reason id

View File

@ -23,6 +23,7 @@
// #include "irresistible\cnr\features\eastereggs.pwn"
// other
#include "irresistible\cnr\features\passive_mode.pwn"
#include "irresistible\cnr\features\toys.pwn"
#include "irresistible\cnr\features\fps.pwn"
#include "irresistible\cnr\features\radio.pwn"

View File

@ -526,7 +526,7 @@ stock Turf_IsAbleToTakeover( i ) {
Float: Z;
GetPlayerPos( i, Z, Z, Z );
return p_Class[ i ] == CLASS_CIVILIAN && ! p_AntiSpawnKillEnabled{ i } && ! IsPlayerPassive( i ) && ! IsPlayerAdminOnDuty( i ) && GetPlayerState( i ) != PLAYER_STATE_SPECTATING && ! IsPlayerAFK( i ) && Z <= 250.0;
return p_Class[ i ] == CLASS_CIVILIAN && ! IsPlayerSpawnProtected( i ) && ! IsPlayerPassive( i ) && ! IsPlayerAdminOnDuty( i ) && GetPlayerState( i ) != PLAYER_STATE_SPECTATING && ! IsPlayerAFK( i ) && Z <= 250.0;
}
stock Turf_RedrawPlayerGangZones( playerid )

View File

@ -90,6 +90,33 @@ hook OnPlayerUpdateEx( playerid )
}
return 1;
}
hook OnPlayerFirstSpawn( playerid )
{
// Jail people that left jailed
if ( p_JailTime[ playerid ] ) // We load this when the player logs in.
{
JailPlayer( playerid, p_JailTime[ playerid ], p_AdminJailed{ playerid } );
SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been sent to jail "COL_LRED"[Left as a jailed person]", ReturnPlayerName( playerid ), playerid );
return 0;
}
// Jail quit to avoiders
if ( p_LeftCuffed{ playerid } )
{
new
szServing = 100 + GetPlayerScore( playerid );
if ( szServing > 1000 ) szServing = 1000;
p_LeftCuffed{ playerid } = false;
JailPlayer( playerid, szServing, 1 );
SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been sent to jail for %d seconds by the server "COL_LRED"[Quit To Avoid]", ReturnPlayerName( playerid ), playerid, szServing );
return 0;
}
return 1;
}
hook OnPlayerC4Blown( playerid, Float: X, Float: Y, Float: Z, worldid )
{
// check if blown up alcatraz rock

View File

@ -0,0 +1,141 @@
/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc
* Module: cnr\features\passive_mode.pwn
* Purpose: passive mode feature (and anti-spawn kill)
*/
/* ** Includes ** */
#include < YSI\y_hooks >
/* ** Variables ** */
static stock
Text3D: p_SpawnKillLabel [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID, ... },
p_AntiSpawnKill [ MAX_PLAYERS ],
bool: p_AntiSpawnKillEnabled [ MAX_PLAYERS char ]
;
/* ** Hooks ** */
hook OnPlayerUpdateEx( playerid )
{
// Remove Anti-Spawn Kill
if ( p_AntiSpawnKillEnabled{ playerid } && g_iTime > p_AntiSpawnKill[ playerid ] ) {
DisablePlayerSpawnProtection( playerid );
}
return 1;
}
hook OnPlayerSpawn( playerid )
{
// Toggle Anti Spawn Kill
DisableRemoteVehicleCollisions( playerid, p_AdminOnDuty{ playerid } );
SetPlayerHealth( playerid, INVALID_PLAYER_ID );
Delete3DTextLabel( p_SpawnKillLabel[ playerid ] );
p_SpawnKillLabel[ playerid ] = Create3DTextLabel( "Spawn Protected!", COLOR_GOLD, 0.0, 0.0, 0.0, 15.0, 0 );
p_AntiSpawnKill[ playerid ] = g_iTime + 15;
Attach3DTextLabelToPlayer( p_SpawnKillLabel[ playerid ], playerid, 0.0, 0.0, 0.3 );
p_AntiSpawnKillEnabled{ playerid } = true;
// Toggle Passive Mode
SetPlayerPassiveMode( playerid );
return 1;
}
hook OnPlayerDisconnect( playerid, reason )
{
ResetPlayerPassiveMode( playerid );
Delete3DTextLabel( p_SpawnKillLabel[ playerid ] );
p_SpawnKillLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
p_AntiSpawnKillEnabled{ playerid } = false;
return 1;
}
#if defined AC_INCLUDED
hook OnPlayerDeathEx( playerid, killerid, reason, Float: damage, bodypart )
#else
hook OnPlayerDeath( playerid, killerid, reason )
#endif
{
ResetPlayerPassiveMode( playerid );
return 1;
}
hook OnPlayerUnjailed( playerid, reasonid )
{
SetPlayerPassiveMode( playerid );
return 1;
}
/* ** Functions ** */
stock DisablePlayerSpawnProtection( playerid )
{
if ( p_AntiSpawnKillEnabled{ playerid } )
{
SetPlayerHealth( playerid, p_AdminOnDuty{ playerid } ? float( INVALID_PLAYER_ID ) : 100.0 );
DisableRemoteVehicleCollisions( playerid, p_AdminOnDuty{ playerid } );
Delete3DTextLabel( p_SpawnKillLabel[ playerid ] );
p_SpawnKillLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
p_AntiSpawnKillEnabled{ playerid } = false;
}
return 1;
}
stock SetPlayerPassiveMode( playerid )
{
if ( IsPlayerSettingToggled( playerid, SETTING_PASSIVE_MODE ) )
{
ResetPlayerPassiveMode( playerid, .passive_disabled = true );
return 0;
}
// reset any labels etc
ResetPlayerPassiveMode( playerid );
// place label
if ( ! p_WantedLevel[ playerid ] && ! IsPlayerInPaintBall( playerid ) && GetPlayerClass( playerid ) != CLASS_POLICE ) {
p_PassiveModeLabel[ playerid ] = CreateDynamic3DTextLabel( "Passive Mode", COLOR_GREEN, 0.0, 0.0, -0.6, 15.0, .attachedplayer = playerid );
TextDrawShowForPlayer( playerid, g_PassiveModeTD );
}
return 1;
}
stock IsPlayerPassive( playerid )
{
return ! p_WantedLevel[ playerid ] && p_Class[ playerid ] != CLASS_POLICE && ! p_PassiveModeDisabled{ playerid };
}
stock ResetPlayerPassiveMode( playerid, bool: passive_disabled = false )
{
DestroyDynamic3DTextLabel( p_PassiveModeLabel[ playerid ] );
//KillTimer( p_PassiveModeExpireTimer[ playerid ] );
p_PassiveModeLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
//p_PassiveModeExpireTimer[ playerid ] = -1;
p_PassiveModeDisabled{ playerid } = passive_disabled;
TextDrawHideForPlayer( playerid, g_PassiveModeTD );
return 1;
}
/*function PassiveMode_Reset( playerid, time_left )
{
// if you happen to die then have a shot synced ... just reset normally
if ( GetPlayerState( playerid ) == PLAYER_STATE_WASTED ) {
return ResetPlayerPassiveMode( playerid );
}
if ( p_WantedLevel[ playerid ] > 0 || p_Class[ playerid ] != CLASS_CIVILIAN || -- time_left <= 0 )
{
ResetPlayerPassiveMode( playerid, .passive_disabled = true );
ShowPlayerHelpDialog( playerid, 2000, "Passive mode is ~r~disabled." );
}
else
{
UpdateDynamic3DTextLabelText( p_PassiveModeLabel[ playerid ], COLOR_RED, sprintf( "Passive Mode Disabled In %d Seconds", time_left ) );
p_PassiveModeExpireTimer[ playerid ] = SetTimerEx( "PassiveMode_Reset", 980, false, "dd", playerid, time_left );
ShowPlayerHelpDialog( playerid, 1500, "Passive mode disabled in ~r~%d seconds.", time_left );
}
return 1;
}*/
stock IsPlayerSpawnProtected( playerid ) {
return p_AntiSpawnKillEnabled{ playerid };
}

View File

@ -128,9 +128,6 @@ new
p_RansomPlacer [ MAX_PLAYERS ] = { INVALID_PLAYER_ID, ... },
p_RansomAmount [ MAX_PLAYERS ],
p_LastDrovenPoliceVeh [ MAX_PLAYERS ] = { INVALID_VEHICLE_ID, ... },
Text3D: p_SpawnKillLabel [ MAX_PLAYERS ] = { Text3D: INVALID_3DTEXT_ID, ... },
p_AntiSpawnKill [ MAX_PLAYERS ],
bool: p_AntiSpawnKillEnabled [ MAX_PLAYERS char ],
p_HitsComplete [ MAX_PLAYERS ],
/*p_CopTutorial [ MAX_PLAYERS char ],
p_CopTutorialProgress [ MAX_PLAYERS char ],
@ -241,8 +238,6 @@ stock IsPlayerJailed( playerid ) return p_Jailed{ playerid };
stock IsPlayerAdminOnDuty( playerid ) return p_AdminOnDuty{ playerid };
stock IsPlayerSpawnProtected( playerid ) return p_AntiSpawnKillEnabled{ playerid };
stock IsPlayerLoggedIn( playerid ) return p_PlayerLogged{ playerid };
stock GivePlayerBankMoney( playerid, money ) {

View File

@ -614,11 +614,6 @@ public OnServerSecondTick( )
SetPlayerWeather( playerid, ( GetPlayerInterior( playerid ) || GetPlayerVirtualWorld( playerid ) ) ? 1 : g_WorldWeather );
UpdatePlayerTime( playerid );
// Remove Anti-Spawn Kill
if ( p_AntiSpawnKillEnabled{ playerid } && g_iTime > p_AntiSpawnKill[ playerid ] ) {
DisablePlayerSpawnProtection( playerid );
}
// Increment Variables Whilst Not AFK
if ( !IsPlayerAFK( playerid ) ) // New addition
{
@ -996,7 +991,6 @@ public OnPlayerDisconnect( playerid, reason )
CutSpectation( playerid );
LeavePlayerPaintball( playerid );
RemovePlayerFromRace( playerid );
ResetPlayerPassiveMode( playerid );
//p_Detained { playerid } = false;
p_Tied { playerid } = false;
p_Kidnapped { playerid } = false;
@ -1112,8 +1106,6 @@ public OnPlayerDisconnect( playerid, reason )
p_IncorrectLogins{ playerid } = 0;
p_VehicleBringCooldown[ playerid ] = 0;
p_AntiTextSpamCount{ playerid } = 0;
Delete3DTextLabel( p_SpawnKillLabel[ playerid ] );
p_SpawnKillLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
Delete3DTextLabel( p_AdminLabel[ playerid ] );
p_AdminLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
//Delete3DTextLabel( p_DetainedLabel[ playerid ] );
@ -1122,7 +1114,6 @@ public OnPlayerDisconnect( playerid, reason )
p_TiedLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
DestroyDynamic3DTextLabel( p_WeedLabel[ playerid ] );
p_WeedLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
p_AntiSpawnKillEnabled{ playerid } = false;
//p_CopTutorialProgress{ playerid } = 0;
DestroyDynamicRaceCP( p_MiningExport[ playerid ] );
p_MiningExport[ playerid ] = 0xFFFF;
@ -1228,29 +1219,9 @@ public OnPlayerSpawn( playerid )
StopAudioStreamForPlayer( playerid );
// Callback
CallLocalFunction( "OnPlayerFirstSpawn", "d", playerid );
// Jail people that left jailed
if ( p_JailTime[ playerid ] ) // We load this when the player logs in.
{
JailPlayer( playerid, p_JailTime[ playerid ], p_AdminJailed{ playerid } );
SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been sent to jail "COL_LRED"[Left as a jailed person]", ReturnPlayerName( playerid ), playerid );
return 1;
}
// Jail quit to avoiders
if ( p_LeftCuffed{ playerid } )
{
new
szServing = 100 + GetPlayerScore( playerid );
if ( szServing > 1000 ) szServing = 1000;
p_LeftCuffed{ playerid } = false;
JailPlayer( playerid, szServing, 1 );
SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has been sent to jail for %d seconds by the server "COL_LRED"[Quit To Avoid]", ReturnPlayerName( playerid ), playerid, szServing );
return 1;
}
if ( ! CallLocalFunction( "OnPlayerFirstSpawn", "d", playerid ) ) {
return 1; // prevent the player from spawning if the first spawn requires the player not to
}
// Show wanted level
if ( p_WantedLevel[ playerid ] )
@ -1287,19 +1258,6 @@ public OnPlayerSpawn( playerid )
return 1;
}
/* ** Anti-Spawn Kill ** */
DisableRemoteVehicleCollisions( playerid, p_AdminOnDuty{ playerid } );
SetPlayerHealth( playerid, INVALID_PLAYER_ID );
Delete3DTextLabel( p_SpawnKillLabel[ playerid ] );
p_SpawnKillLabel[ playerid ] = Create3DTextLabel( "Spawn Protected!", COLOR_GOLD, 0.0, 0.0, 0.0, 15.0, 0 );
p_AntiSpawnKill[ playerid ] = g_iTime + 15;
Attach3DTextLabelToPlayer( p_SpawnKillLabel[ playerid ], playerid, 0.0, 0.0, 0.3 );
p_AntiSpawnKillEnabled{ playerid } = true;
/* ** Anti-Spawn Kill ** */
// passive mode
SetPlayerPassiveMode( playerid );
if ( p_Class[ playerid ] == CLASS_CIVILIAN )
{
if ( !p_JobSet{ playerid } )
@ -1421,10 +1379,10 @@ public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float: fX, Float:
if ( IsPlayerAdminOnDuty( playerid ) )
return 0;
if ( IsPlayerConnected( hitid ) && ( IsPlayerTazed( hitid ) || IsPlayerCuffed( hitid ) || IsPlayerKidnapped( hitid ) || IsPlayerTied( hitid ) || IsPlayerLoadingObjects( hitid ) || IsPlayerAdminOnDuty( hitid ) || p_AntiSpawnKillEnabled{ hitid } ) )
if ( IsPlayerConnected( hitid ) && ( IsPlayerTazed( hitid ) || IsPlayerCuffed( hitid ) || IsPlayerKidnapped( hitid ) || IsPlayerTied( hitid ) || IsPlayerLoadingObjects( hitid ) || IsPlayerAdminOnDuty( hitid ) || IsPlayerSpawnProtected( hitid ) ) )
return 0;
if ( p_AntiSpawnKill[ playerid ] > g_iTime && p_AntiSpawnKillEnabled{ playerid } ) {
if ( IsPlayerSpawnProtected( playerid ) ) {
return DisablePlayerSpawnProtection( playerid ), SendServerMessage( playerid, "Your spawn protection is no longer active!" ), 0;
}
}
@ -1608,7 +1566,7 @@ public OnPlayerTakePlayerDamage( playerid, issuerid, &Float: amount, weaponid, b
if ( ( IsPlayerOnSlotMachine( playerid ) || IsPlayerMining( playerid ) ) && ! p_WantedLevel[ playerid ] )
return ShowPlayerHelpDialog( issuerid, 2000, "This player cannot be killed as they are doing something!" ), 0;
if ( IsPlayerTazed( playerid ) || IsPlayerCuffed( playerid ) || IsPlayerKidnapped( playerid ) || IsPlayerTied( playerid ) || IsPlayerLoadingObjects( playerid ) || IsPlayerAdminOnDuty( playerid ) || p_AntiSpawnKillEnabled{ playerid } )
if ( IsPlayerTazed( playerid ) || IsPlayerCuffed( playerid ) || IsPlayerKidnapped( playerid ) || IsPlayerTied( playerid ) || IsPlayerLoadingObjects( playerid ) || IsPlayerAdminOnDuty( playerid ) || IsPlayerSpawnProtected( playerid ) )
return 0;
// Rhino damage invulnerable
@ -1824,7 +1782,6 @@ public OnPlayerDeath( playerid, killerid, reason )
RemovePlayerStolensFromHands( playerid );
RemoveEquippedOre( playerid );
KillTimer( p_CuffAbuseTimer[ playerid ] );
ResetPlayerPassiveMode( playerid );
PlayerTextDrawHide( playerid, p_LocationTD[ playerid ] );
p_Tazed{ playerid } = false;
p_WeaponDealing{ playerid } = false;
@ -2151,7 +2108,6 @@ public OnPlayerUnjailed( playerid, reasonid )
PlainUnjailPlayer ( playerid );
SetPlayerColorToTeam ( playerid );
ClearPlayerWantedLevel ( playerid );
SetPlayerPassiveMode ( playerid );
return 1;
}
@ -4626,7 +4582,7 @@ CMD:kill( playerid, params[ ] )
if ( IsPlayerGettingBlowed( playerid ) ) return SendError( playerid, "You cannot use this command since you're getting blowed." );
if ( IsPlayerBlowingCock( playerid ) ) return SendError( playerid, "You cannot use this command since you're giving oral sex." );
if ( p_Spectating{ playerid } == true ) return SendError( playerid, "You cannot use this command since you're spectating." );
if ( p_AntiSpawnKillEnabled{ playerid } ) return SendError( playerid, "You cannot use this command while anti-spawn kill is activated." );
if ( IsPlayerSpawnProtected( playerid ) ) return SendError( playerid, "You cannot use this command while anti-spawn kill is activated." );
SetPVarInt( playerid, "used_cmd_kill", 1 );
SetPlayerHealth( playerid, -1 );
return 1;
@ -4645,7 +4601,7 @@ CMD:changeclass( playerid, params[ ] )
if ( IsPlayerGettingBlowed( playerid ) ) return SendError( playerid, "You cannot use this command since you're getting blowed." );
if ( IsPlayerBlowingCock( playerid ) ) return SendError( playerid, "You cannot use this command since you're giving oral sex." );
if ( p_Spectating{ playerid } == true ) return SendError( playerid, "You cannot use this command since you're spectating." );
if ( p_AntiSpawnKillEnabled{ playerid } ) return SendError( playerid, "You cannot use this command while anti-spawn kill is activated." );
if ( IsPlayerSpawnProtected( playerid ) ) return SendError( playerid, "You cannot use this command while anti-spawn kill is activated." );
SetPVarInt( playerid, "used_cmd_kill", 1 );
ForceClassSelection( playerid );
SetPlayerHealth( playerid, -1 );
@ -4769,7 +4725,7 @@ CMD:tie( playerid, params[ ] )
if ( GetPlayerState( victimid ) == PLAYER_STATE_WASTED ) return SendError( playerid, "You cannot tie wasted players." );
if ( IsPlayerInEvent( playerid ) ) return SendError( playerid, "You cannot use this command since you're in an event." );
if ( IsPlayerInPlayerGang( playerid, victimid ) ) return SendError( playerid, "You cannot use this command on your homies!" );
if ( p_AntiSpawnKillEnabled{ victimid } ) return SendError( playerid, "You cannot use this command on spawn protected players." );
if ( IsPlayerSpawnProtected( victimid ) ) return SendError( playerid, "You cannot use this command on spawn protected players." );
if ( IsPlayerPassive( victimid ) ) return SendError( playerid, "You cannot use this command on passive mode players." );
if ( IsPlayerInCasino( victimid ) && ! p_WantedLevel[ victimid ] ) return SendError( playerid, "The innocent person you're trying to tie is in a casino." );
@ -5205,7 +5161,7 @@ CMD:rape( playerid, params[ ] )
if ( IsPlayerJailed( victimid ) ) return SendError( playerid, "This player is jailed. He may be paused." );
if ( IsPlayerInCasino( victimid ) && ! p_WantedLevel[ victimid ] ) return SendError( playerid, "The innocent person you're trying to rape is in a casino." );
if ( IsPlayerLoadingObjects( victimid ) ) return SendError( playerid, "This player is in a object-loading state." );
if ( p_AntiSpawnKillEnabled{ victimid } ) return SendError( playerid, "This player is in a anti-spawn-kill state." );
if ( IsPlayerSpawnProtected( victimid ) ) return SendError( playerid, "This player is in a anti-spawn-kill state." );
if ( IsPlayerPassive( victimid ) ) return SendError( playerid, "You cannot use this command on passive mode players." );
if ( p_ClassSelection{ victimid } ) return SendError( playerid, "This player is currently in class selection." );
if ( IsPlayerInEvent( playerid ) ) return SendError( playerid, "You cannot use this command since you're in an event." );
@ -6561,7 +6517,7 @@ public OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
// taze mechanism
else if ( PRESSED( KEY_LOOK_BEHIND ) )
{
if ( p_Class[ playerid ] == CLASS_POLICE && !p_AntiSpawnKillEnabled{ playerid } )
if ( p_Class[ playerid ] == CLASS_POLICE && !IsPlayerSpawnProtected( playerid ) )
{
new
closestid = GetClosestPlayer( playerid );
@ -7166,7 +7122,6 @@ public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
}
}
if ( dialogid == DIALOG_PASSIVE_MODE )
{
if ( ! response || ! listitem ) {
@ -10989,166 +10944,6 @@ stock ShowPlayerSpawnMenu( playerid ) {
return ShowPlayerDialog( playerid, DIALOG_SPAWN, DIALOG_STYLE_LIST, "{FFFFFF}Spawn Location", ""COL_GREY"Reset Back To Default\nHouse\nBusiness\nGang Facility\nVisage Casino", "Select", "Cancel" );
}
stock TazePlayer( victimid, playerid )
{
if ( p_Class[ playerid ] != CLASS_POLICE ) return SendError( playerid, "This is restricted to police only." );
//else if ( sscanf( params, "u", victimid ) ) return SendUsage( playerid, "/taze [PLAYER_ID]" );
//else if ( victimid == playerid ) return SendError( playerid, "You cannot taze yourself." );
else if ( !IsPlayerConnected( victimid ) ) return SendError( playerid, "There are no players around to taze." );
else if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." );
else if ( GetDistanceBetweenPlayers( playerid, victimid ) < 5.0 && IsPlayerConnected( victimid ) )
{
if ( p_Class[ victimid ] == p_Class[ playerid ] ) return SendError( playerid, "This player is in your team." );
if ( p_WantedLevel[ victimid ] == 0 ) return SendError( playerid, "This player is innocent!" );
if ( IsPlayerInAnyVehicle( victimid ) ) return SendError( playerid, "This player is in a vehicle " );
if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You cannot do this while you're inside a vehicle." );
if ( IsPlayerTazed( victimid ) ) return SendError( playerid, "This player is already tazed." );
//if ( IsPlayerCuffed( victimid ) ) return SendError( playerid, "This player is already cuffed." );
//if ( IsPlayerDetained( victimid ) ) return SendError( playerid, "This player is already detained." );
if ( IsPlayerGettingBlowed( playerid ) ) return SendError( playerid, "You cannot use this command since you're getting blowed." );
if ( IsPlayerBlowingCock( playerid ) ) return SendError( playerid, "You cannot use this command since you're giving oral sex." );
if ( IsPlayerKidnapped( playerid ) ) return SendError( playerid, "You are kidnapped, you cannot do this." );
if ( IsPlayerTied( playerid ) ) return SendError( playerid, "You are tied, you cannot do this." );
if ( IsPlayerAdminOnDuty( victimid ) ) return SendError( playerid, "You cannot use this command on admins that are on duty." );
if ( IsPlayerJailed( victimid ) ) return SendError( playerid, "This player is jailed. He may be paused." );
if ( IsPlayerJailed( playerid ) ) return SendError( playerid, "You cannot use this command while in jail." );
if ( IsPlayerTied( victimid ) ) return SendError( playerid, "Tazing a tied player is pretty useless, though you can use /untie for a harder job!" );
if ( IsPlayerLoadingObjects( victimid ) ) return SendError( playerid, "This player is in a object-loading state." );
if ( IsPlayerInEvent( playerid ) ) return SendError( playerid, "You cannot use this command since you're in an event." );
if ( GetPlayerState( playerid ) == PLAYER_STATE_WASTED ) return SendError( playerid, "You cannot use this command since you are dead." );
if ( p_TazingImmunity[ victimid ] > g_iTime ) return SendError( playerid, "You must wait %d seconds before tazing this player.", p_TazingImmunity[ victimid ] - g_iTime );
if ( random( 101 ) < 90 )
{
GameTextForPlayer( victimid, "~n~~r~TAZED!", 2000, 4 );
GameTextForPlayer( playerid, "~n~~y~~h~/cuff", 2000, 4 );
SendClientMessageFormatted( victimid, -1, ""COL_RED"[TAZED]{FFFFFF} You have been tazed by %s(%d) for 3 seconds!", ReturnPlayerName( playerid ), playerid );
SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[TAZED]{FFFFFF} You have tazed %s(%d) for 3 seconds!", ReturnPlayerName( victimid ), victimid );
SetTimerEx( "Untaze", 2000, false, "dd", victimid, 6 ); // previous 3000
TogglePlayerControllable( victimid, 0 );
ApplyAnimation( victimid, "CRACK", "crckdeth2", 5.0, 1, 1, 1, 0, 0 );
p_Tazed{ victimid } = true;
}
else
{
SendClientMessageFormatted( playerid, -1, ""COL_RED"[TAZE FAIL]{FFFFFF} You have failed to taze %s(%d)!", ReturnPlayerName( victimid ), victimid );
SendClientMessageFormatted( victimid, -1, ""COL_GREEN"[TAZE FAIL]{FFFFFF} %s(%d) has failed to taze you!", ReturnPlayerName( playerid ), playerid );
}
p_TazingImmunity[ victimid ] = g_iTime + 6;
return 1;
} else {
return SendError( playerid, "There are no players around to taze." );
}
}
stock ArrestPlayer( victimid, playerid )
{
if ( p_Class[ playerid ] != CLASS_POLICE ) return SendError( playerid, "This is restricted to police only." );
else if ( IsPlayerJailed( playerid ) ) return SendError( playerid, "You cannot use this command since you're jailed." );
//else if ( GetPlayerScore( playerid ) > 200 ) return SendError( playerid, "This feature is no longer available to you. Please use /detain." );
// else if ( sscanf( params, "u", victimid ) ) return SendUsage( playerid, "/ar(rest) [PLAYER_ID]" );
// else if ( victimid == playerid ) return SendError( playerid, "You cannot arrest yourself." );
else if ( !IsPlayerConnected( victimid ) ) return SendError( playerid, "This player is not connected." );
else if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." );
else if ( GetDistanceBetweenPlayers( playerid, victimid ) < 4.0 && IsPlayerConnected( victimid ) )
{
if ( p_Class[ victimid ] == p_Class[ playerid ] ) return SendError( playerid, "This player is in your team." );
if ( p_WantedLevel[ victimid ] == 0 ) return SendError( playerid, "This player is innocent!" );
if ( !IsPlayerCuffed( victimid ) ) return SendError( playerid, "This player is not cuffed." );
if ( IsPlayerKidnapped( playerid ) ) return SendError( playerid, "You are kidnapped, you cannot do this." );
//if ( IsPlayerDetained( victimid ) ) return SendError( playerid, "This player is detained, you cannot arrest them." );
if ( IsPlayerTied( playerid ) ) return SendError( playerid, "You are tied, you cannot do this." );
if ( IsPlayerJailed( victimid ) ) return SendError( playerid, "This player is jailed. He may be paused." );
if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You cannot arrest this person inside a vehicle." );
if ( IsPlayerInAnyVehicle( victimid ) ) return SendError( playerid, "You cannot arrest a person that is inside a vehicle." );
if ( IsPlayerAdminOnDuty( victimid ) ) return SendError( playerid, "You cannot use this command on admins that are on duty." );
if ( GetPlayerState( playerid ) == PLAYER_STATE_WASTED ) return SendError( playerid, "You cannot use this command since you are dead." );
new totalCash = ( p_WantedLevel[ victimid ] < MAX_WANTED_LVL ? p_WantedLevel[ victimid ] : MAX_WANTED_LVL ) * ( 300 );
new totalSeconds = p_WantedLevel[ victimid ] * ( JAIL_SECONDS_MULTIPLIER );
GivePlayerScore( playerid, 2 );
GivePlayerExperience( playerid, E_POLICE );
GivePlayerCash( playerid, totalCash );
StockMarket_UpdateEarnings( E_STOCK_GOVERNMENT, totalCash, 0.1 );
if ( totalCash > 20000 ) printf("[police arrest] %s -> %s - %s", ReturnPlayerName( playerid ), ReturnPlayerName( victimid ), cash_format( totalCash ) ); // 8hska7082bmahu
SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[ACHIEVE]{FFFFFF} You have earned "COL_GOLD"%s{FFFFFF} dollars and 2 score for arresting %s(%d)!", cash_format( totalCash ), ReturnPlayerName( victimid ), victimid );
GameTextForPlayer( victimid, "~r~Busted!", 4000, 0 );
CallLocalFunction( "OnPlayerArrested", "dddd", playerid, victimid, p_Arrests[ playerid ], 1 );
Untaze( victimid, 6 );
GivePlayerSeasonalXP( victimid, -20.0 );
SendGlobalMessage( -1, ""COL_GOLD"[JAIL]{FFFFFF} %s(%d) has sent %s(%d) to jail for %d seconds!", ReturnPlayerName( playerid ), playerid, ReturnPlayerName( victimid ), victimid, totalSeconds );
JailPlayer( victimid, totalSeconds );
return 1;
}
else return SendError( playerid, "There are no players around to arrest." );
}
stock CuffPlayer( victimid, playerid )
{
if ( p_Class[ playerid ] != CLASS_POLICE ) return SendError( playerid, "This is restricted to police only." );
else if ( IsPlayerJailed( playerid ) ) return SendError( playerid, "You cannot use this command since you're jailed." );
//else if ( sscanf( params, "u", victimid ) ) return SendUsage( playerid, "/cuff [PLAYER_ID]" );
//else if ( victimid == playerid ) return SendError( playerid, "You cannot cuff yourself." );
else if ( !IsPlayerConnected( victimid ) || IsPlayerNPC( victimid ) ) return SendError( playerid, "This player is not connected." );
else if ( p_Spectating{ playerid } ) return SendError( playerid, "You cannot use such commands while you're spectating." );
else if ( GetDistanceBetweenPlayers( playerid, victimid ) < 4.0 && IsPlayerConnected( victimid ) )
{
if ( p_Class[ victimid ] == p_Class[ playerid ] ) return SendError( playerid, "This player is in your team." );
if ( p_WantedLevel[ victimid ] == 0 ) return SendError( playerid, "This player is innocent!" );
if ( p_WantedLevel[ victimid ] < 6 ) return SendError( playerid, "This person isn't worth cuffing, ticket them." );
if ( IsPlayerInAnyVehicle( victimid ) ) return SendError( playerid, "This player is in a vehicle " );
//if ( IsPlayerDetained( victimid ) ) return SendError( playerid, "This player is already detained." );
if ( IsPlayerInAnyVehicle( playerid ) ) return SendError( playerid, "You cannot do this while you're inside a vehicle." );
if ( IsPlayerCuffed( victimid ) ) return SendError( playerid, "This player is already cuffed." );
if ( IsPlayerJailed( victimid ) ) return SendError( playerid, "This player is jailed. He may be paused." );
if ( !IsPlayerTazed( victimid ) ) return SendError( playerid, "You must taze this player before cuffing them." );
if ( IsPlayerGettingBlowed( playerid ) ) return SendError( playerid, "You cannot use this command since you're getting blowed." );
if ( IsPlayerBlowingCock( playerid ) ) return SendError( playerid, "You cannot use this command since you're giving oral sex." );
if ( IsPlayerKidnapped( playerid ) ) return SendError( playerid, "You are kidnapped, you cannot do this." );
if ( IsPlayerTied( playerid ) ) return SendError( playerid, "You are tied, you cannot do this." );
if ( IsPlayerAdminOnDuty( victimid ) ) return SendError( playerid, "You cannot use this command on admins that are on duty." );
if ( IsPlayerJailed( victimid ) ) return SendError( playerid, "This player is jailed. He may be paused." );
if ( IsPlayerLoadingObjects( victimid ) ) return SendError( playerid, "This player is in a object-loading state." );
if ( GetPlayerState( playerid ) == PLAYER_STATE_WASTED ) return SendError( playerid, "You cannot use this command since you are dead." );
if ( !IsPlayerSpawned( victimid ) ) return SendError( playerid, "The player must be spawned." );
new
break_attempts = 0;
if ( ! BreakPlayerCuffs( victimid, break_attempts ) )
{
GameTextForPlayer( victimid, "~n~~r~CUFFED!", 2000, 4 );
//GameTextForPlayer( playerid, sprintf( "~n~~y~~h~/arrest %d", victimid ), 2000, 4 );
GameTextForPlayer( playerid, "~n~~y~~h~/arrest", 2000, 4 );
SendClientMessageFormatted( victimid, -1, ""COL_RED"[CUFFED]{FFFFFF} You have been cuffed by %s(%d)!", ReturnPlayerName( playerid ), playerid );
SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[CUFFED]{FFFFFF} You have cuffed %s(%d)!", ReturnPlayerName( victimid ), victimid );
KillTimer( p_CuffAbuseTimer[ victimid ] );
p_CuffAbuseTimer[ victimid ] = SetTimerEx( "Uncuff", ( 60 * 1000 ), false, "d", victimid );
//ApplyAnimation( victimid, "ped", "cower", 5.0, 1, 1, 1, 0, 0 );
//TogglePlayerControllable( victimid, 0 );
p_Cuffed{ victimid } = true;
p_QuitToAvoidTimestamp[ victimid ] = g_iTime + 3;
SetPlayerAttachedObject( victimid, 2, 19418, 6, -0.011000, 0.028000, -0.022000, -15.600012, -33.699977, -81.700035, 0.891999, 1.000000, 1.168000 );
SetPlayerSpecialAction( victimid, SPECIAL_ACTION_CUFFED );
ShowPlayerHelpDialog( victimid, 4000, "You can buy bobby pins at Supa Save or a 24/7 store to break cuffs." );
}
else
{
if ( break_attempts )
{
new
money_dropped = RandomEx( 200, 400 ) * break_attempts;
SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[CUFFED]{FFFFFF} %s(%d) just broke their cuffs off, and dropped %s!", ReturnPlayerName( victimid ), victimid, cash_format( money_dropped ) );
GivePlayerCash( playerid, money_dropped );
}
else
{
SendClientMessageFormatted( playerid, -1, ""COL_GREEN"[CUFFED]{FFFFFF} %s(%d) just broke their cuffs off!", ReturnPlayerName( victimid ), victimid );
}
}
return 1;
}
else return SendError( playerid, "There are no players around to cuff." );
}
stock BreakPlayerCuffs( playerid, &attempts = 0 )
{