wanted level in module and hooked functions (completely server sided). You can use GetPlayerWantedLevel, SetPlayerWantedLevel or GivePlayerWantedLevel
This commit is contained in:
parent
68a890d747
commit
08474974bf
@ -17,6 +17,7 @@
|
|||||||
#include "irresistible\cnr\dialog_ids.pwn"
|
#include "irresistible\cnr\dialog_ids.pwn"
|
||||||
#include "irresistible\cnr\entrances.pwn"
|
#include "irresistible\cnr\entrances.pwn"
|
||||||
#include "irresistible\cnr\checkpoints.pwn"
|
#include "irresistible\cnr\checkpoints.pwn"
|
||||||
|
#include "irresistible\cnr\wanted_level.pwn"
|
||||||
|
|
||||||
// reliant on core definitions
|
// reliant on core definitions
|
||||||
#include "irresistible\cnr\vip\_vip.pwn"
|
#include "irresistible\cnr\vip\_vip.pwn"
|
||||||
|
@ -28,7 +28,6 @@ new
|
|||||||
p_AdminJailed [ MAX_PLAYERS char ],
|
p_AdminJailed [ MAX_PLAYERS char ],
|
||||||
p_JailTimer [ MAX_PLAYERS ],
|
p_JailTimer [ MAX_PLAYERS ],
|
||||||
bool: p_Jailed [ MAX_PLAYERS char ],
|
bool: p_Jailed [ MAX_PLAYERS char ],
|
||||||
p_WantedLevel [ MAX_PLAYERS ],
|
|
||||||
bool: p_Tazed [ MAX_PLAYERS char ],
|
bool: p_Tazed [ MAX_PLAYERS char ],
|
||||||
p_LastVehicle [ MAX_PLAYERS ] = { INVALID_VEHICLE_ID, ... },
|
p_LastVehicle [ MAX_PLAYERS ] = { INVALID_VEHICLE_ID, ... },
|
||||||
bool: p_Cuffed [ MAX_PLAYERS char ],
|
bool: p_Cuffed [ MAX_PLAYERS char ],
|
||||||
|
111
gamemodes/irresistible/cnr/wanted_level.pwn
Normal file
111
gamemodes/irresistible/cnr/wanted_level.pwn
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* Irresistible Gaming (c) 2018
|
||||||
|
* Developed by Lorenc Pekaj
|
||||||
|
* Module:
|
||||||
|
* Purpose:
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ** Includes ** */
|
||||||
|
#include < YSI\y_hooks >
|
||||||
|
|
||||||
|
/* ** Definitions ** */
|
||||||
|
|
||||||
|
/* ** Variables ** */
|
||||||
|
new
|
||||||
|
p_WantedLevel [ MAX_PLAYERS ];
|
||||||
|
|
||||||
|
/* ** Hooks ** */
|
||||||
|
hook OnPlayerConnect( playerid )
|
||||||
|
{
|
||||||
|
ClearPlayerWantedLevel( playerid );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined AC_INCLUDED
|
||||||
|
hook OnPlayerDeathEx( playerid, killerid, reason, Float: damage, bodypart )
|
||||||
|
#else
|
||||||
|
hook OnPlayerDeath( playerid, killerid, reason )
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
ClearPlayerWantedLevel( playerid );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ** Hooked Functions ** */
|
||||||
|
stock CNR_GetPlayerWantedLevel( playerid )
|
||||||
|
{
|
||||||
|
return p_WantedLevel[ playerid ]; // force the variable
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined _ALS_GetPlayerWantedLevel
|
||||||
|
#undef GetPlayerWantedLevel
|
||||||
|
#else
|
||||||
|
#define _ALS_GetPlayerWantedLevel
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define GetPlayerWantedLevel CNR_GetPlayerWantedLevel
|
||||||
|
|
||||||
|
stock CNR_SetPlayerWantedLevel( playerid, level )
|
||||||
|
{
|
||||||
|
if ( ( p_WantedLevel[ playerid ] = level ) < 0 ) // prevent negative wanted level
|
||||||
|
p_WantedLevel[ playerid ] = 0;
|
||||||
|
|
||||||
|
if ( p_WantedLevel[ playerid ] > 0 )
|
||||||
|
{
|
||||||
|
if ( IsPlayerSpawned( playerid ) )
|
||||||
|
{
|
||||||
|
PlayerTextDrawSetString( playerid, p_WantedLevelTD[ playerid ], sprintf( "] %d ]", p_WantedLevel[ playerid ] ) );
|
||||||
|
if ( ! IsPlayerMovieMode( playerid ) ) PlayerTextDrawShow( playerid, p_WantedLevelTD[ playerid ] );
|
||||||
|
ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // remove passive mode if the player is wanted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] );
|
||||||
|
Uncuff( playerid ); // player is not wanted, so auto uncuff
|
||||||
|
}
|
||||||
|
|
||||||
|
// regulate player color
|
||||||
|
SetPlayerColorToTeam( playerid );
|
||||||
|
|
||||||
|
/*if ( p_WantedLevel[ playerid ] > 2000 ) { // 8hska7082bmahu
|
||||||
|
p_WantedLevel[ playerid ] = 2000;
|
||||||
|
SendClientMessageFormatted( playerid, -1, ""COL_GOLD"[WANTED LEVEL]{FFFFFF} Your wanted level has reached its maximum. Further wanted levels will not append.", wantedlevel, p_WantedLevel[ playerid ] );
|
||||||
|
|
||||||
|
format( szBigString, 256, "[0xA1] %s(%d) :: %d :: %d\r\n", ReturnPlayerName( playerid ), playerid, p_WantedLevel[ playerid ], g_iTime );
|
||||||
|
AddFileLogLine( "security.txt", szBigString );
|
||||||
|
return 1;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// set it to the variable value
|
||||||
|
return SetPlayerWantedLevel( playerid, p_WantedLevel[ playerid ] );
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined _ALS_SetPlayerWantedLevel
|
||||||
|
#undef SetPlayerWantedLevel
|
||||||
|
#else
|
||||||
|
#define _ALS_SetPlayerWantedLevel
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SetPlayerWantedLevel CNR_SetPlayerWantedLevel
|
||||||
|
|
||||||
|
/* ** Functions ** */
|
||||||
|
stock GivePlayerWantedLevel( playerid, level )
|
||||||
|
{
|
||||||
|
if ( ! IsPlayerConnected( playerid ) || IsPlayerNPC( playerid ) || IsPlayerJailed( playerid ) || level == 0 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
new
|
||||||
|
current_wanted = GetPlayerWantedLevel( playerid );
|
||||||
|
|
||||||
|
SendClientMessageFormatted( playerid, -1, ""COL_GOLD"[CRIME]{FFFFFF} Your wanted level has been %s by %d! Wanted level: %d", current_wanted + level > current_wanted ? ( "increased" ) : ( "decreased" ), level < 0 ? level * -1 : level, current_wanted );
|
||||||
|
return SetPlayerWantedLevel( playerid, current_wanted + level );
|
||||||
|
}
|
||||||
|
|
||||||
|
stock ClearPlayerWantedLevel( playerid )
|
||||||
|
{
|
||||||
|
PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] );
|
||||||
|
p_WantedLevel[ playerid ] = 0;
|
||||||
|
SetPlayerWantedLevel( playerid, 0 );
|
||||||
|
SetPlayerColorToTeam( playerid );
|
||||||
|
}
|
@ -1901,7 +1901,6 @@ public OnPlayerConnect( playerid )
|
|||||||
mysql_function_query( dbHandle, Query, true, "OnPlayerBanCheck", "i", playerid );
|
mysql_function_query( dbHandle, Query, true, "OnPlayerBanCheck", "i", playerid );
|
||||||
|
|
||||||
TogglePlayerClock( playerid, 1 );
|
TogglePlayerClock( playerid, 1 );
|
||||||
ClearPlayerWantedLevel( playerid );
|
|
||||||
SetPlayerColor( playerid, COLOR_GREY );
|
SetPlayerColor( playerid, COLOR_GREY );
|
||||||
ResetPlayerCash( playerid );
|
ResetPlayerCash( playerid );
|
||||||
|
|
||||||
@ -2260,7 +2259,6 @@ public OnPlayerDisconnect( playerid, reason )
|
|||||||
DestroyDynamicRaceCP( p_MiningExport[ playerid ] );
|
DestroyDynamicRaceCP( p_MiningExport[ playerid ] );
|
||||||
p_MiningExport[ playerid ] = 0xFFFF;
|
p_MiningExport[ playerid ] = 0xFFFF;
|
||||||
p_ContractedAmount[ playerid ] = 0;
|
p_ContractedAmount[ playerid ] = 0;
|
||||||
ClearPlayerWantedLevel( playerid );
|
|
||||||
Delete3DTextLabel( p_InfoLabel[ playerid ] );
|
Delete3DTextLabel( p_InfoLabel[ playerid ] );
|
||||||
p_InfoLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
|
p_InfoLabel[ playerid ] = Text3D: INVALID_3DTEXT_ID;
|
||||||
p_LabelColor[ playerid ] = COLOR_GREY;
|
p_LabelColor[ playerid ] = COLOR_GREY;
|
||||||
@ -2412,12 +2410,12 @@ public OnPlayerSpawn( playerid )
|
|||||||
// Show welcome messsage
|
// Show welcome messsage
|
||||||
ShowPlayerHelpDialog( playerid, 10000, "Welcome %s!~n~~n~If you have any questions, ~g~/ask!~w~~h~~n~~n~If you see anyone being unfair, report them with ~r~/report!~w~~n~~n~Have fun playing and don't forget to invite your friends! :)", ReturnPlayerName( playerid ) );
|
ShowPlayerHelpDialog( playerid, 10000, "Welcome %s!~n~~n~If you have any questions, ~g~/ask!~w~~h~~n~~n~If you see anyone being unfair, report them with ~r~/report!~w~~n~~n~Have fun playing and don't forget to invite your friends! :)", ReturnPlayerName( playerid ) );
|
||||||
}
|
}
|
||||||
else
|
/*else
|
||||||
{
|
{
|
||||||
// Reset wanted level when a player spawns
|
// Reset wanted level when a player spawns
|
||||||
if ( p_LastPlayerState{ playerid } != PLAYER_STATE_SPECTATING )
|
if ( p_LastPlayerState{ playerid } != PLAYER_STATE_SPECTATING )
|
||||||
ClearPlayerWantedLevel( playerid );
|
ClearPlayerWantedLevel( playerid );
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if ( p_Jailed{ playerid } ) // Because some people can still exit the jail and play...
|
if ( p_Jailed{ playerid } ) // Because some people can still exit the jail and play...
|
||||||
return SetPlayerHealth( playerid, INVALID_PLAYER_ID ), SetPlayerPosToPrison( playerid );
|
return SetPlayerHealth( playerid, INVALID_PLAYER_ID ), SetPlayerPosToPrison( playerid );
|
||||||
@ -3253,8 +3251,6 @@ public OnPlayerDeath( playerid, killerid, reason )
|
|||||||
p_Deaths[ playerid ] ++; // Usually other events do nothing
|
p_Deaths[ playerid ] ++; // Usually other events do nothing
|
||||||
GivePlayerSeasonalXP( playerid, -10.0 ); // Deduct points, it's meant to be hard!!!
|
GivePlayerSeasonalXP( playerid, -10.0 ); // Deduct points, it's meant to be hard!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearPlayerWantedLevel( playerid );
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8916,7 +8912,6 @@ public OnPlayerStateChange(playerid, newstate, oldstate)
|
|||||||
|
|
||||||
p_LastPlayerState{ playerid } = oldstate;
|
p_LastPlayerState{ playerid } = oldstate;
|
||||||
|
|
||||||
|
|
||||||
if ( oldstate == PLAYER_STATE_SPECTATING )
|
if ( oldstate == PLAYER_STATE_SPECTATING )
|
||||||
{
|
{
|
||||||
ResetPlayerWeapons( playerid );
|
ResetPlayerWeapons( playerid );
|
||||||
@ -10131,7 +10126,11 @@ thread OnAttemptPlayerLogin( playerid, password[ ] )
|
|||||||
SetPlayerCash ( playerid, iCash );
|
SetPlayerCash ( playerid, iCash );
|
||||||
SetPlayerScore ( playerid, iScore );
|
SetPlayerScore ( playerid, iScore );
|
||||||
SetPlayerFightingStyle ( playerid, iFightStyle );
|
SetPlayerFightingStyle ( playerid, iFightStyle );
|
||||||
GivePlayerWantedLevel ( playerid, iWanted, true );
|
|
||||||
|
if ( iWanted ) {
|
||||||
|
SetPlayerWantedLevel( playerid, iWanted );
|
||||||
|
SendClientMessageFormatted( playerid, -1, ""COL_GOLD"[RESUME]{FFFFFF} Your wanted level has been set to %d as you are resuming your life.", GetPlayerWantedLevel( playerid ) );
|
||||||
|
}
|
||||||
|
|
||||||
p_AdminLevel[ playerid ] = cache_get_field_content_int( 0, "ADMINLEVEL", dbHandle );
|
p_AdminLevel[ playerid ] = cache_get_field_content_int( 0, "ADMINLEVEL", dbHandle );
|
||||||
p_BankMoney[ playerid ] = cache_get_field_content_int( 0, "BANKMONEY", dbHandle );
|
p_BankMoney[ playerid ] = cache_get_field_content_int( 0, "BANKMONEY", dbHandle );
|
||||||
@ -13556,71 +13555,6 @@ stock IsPlayerInPoliceCar( playerid )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
stock GivePlayerWantedLevel( playerid, wantedlevel, bool:loadingstats = false )
|
|
||||||
{
|
|
||||||
static
|
|
||||||
szWanted[ 12 ];
|
|
||||||
|
|
||||||
if ( ! IsPlayerConnected( playerid ) || IsPlayerNPC( playerid ) )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ( IsPlayerJailed( playerid ) )
|
|
||||||
{
|
|
||||||
SendClientMessageFormatted( playerid, -1, ""COL_GOLD"[WANTED LEVEL]{FFFFFF} As you're jailed, wanted levels will not append.", wantedlevel, p_WantedLevel[ playerid ] );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( wantedlevel == 0 )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if ( ( p_WantedLevel[ playerid ] += wantedlevel ) < 0 )
|
|
||||||
p_WantedLevel[ playerid ] = 0; // Negative wanted level?
|
|
||||||
|
|
||||||
if ( ( wantedlevel < 0 && p_WantedLevel[ playerid ] < 6 ) || wantedlevel > 0 )
|
|
||||||
SetPlayerWantedLevel( playerid, p_WantedLevel[ playerid ] );
|
|
||||||
|
|
||||||
if ( p_WantedLevel[ playerid ] > 0 )
|
|
||||||
{
|
|
||||||
if ( IsPlayerSpawned( playerid ) )
|
|
||||||
{
|
|
||||||
format( szWanted, sizeof( szWanted ), "] %d ]", p_WantedLevel[ playerid ] );
|
|
||||||
PlayerTextDrawSetString( playerid, p_WantedLevelTD[ playerid ], szWanted );
|
|
||||||
if ( ! p_inMovieMode{ playerid } ) PlayerTextDrawShow( playerid, p_WantedLevelTD[ playerid ] );
|
|
||||||
ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // remove passive mode if the player is wanted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] );
|
|
||||||
Uncuff( playerid );
|
|
||||||
}
|
|
||||||
|
|
||||||
// regulate player color
|
|
||||||
SetPlayerColorToTeam( playerid );
|
|
||||||
|
|
||||||
/*if ( p_WantedLevel[ playerid ] > 2000 ) // 8hska7082bmahu
|
|
||||||
{
|
|
||||||
p_WantedLevel[ playerid ] = 2000;
|
|
||||||
SendClientMessageFormatted( playerid, -1, ""COL_GOLD"[WANTED LEVEL]{FFFFFF} Your wanted level has reached its maximum. Further wanted levels will not append.", wantedlevel, p_WantedLevel[ playerid ] );
|
|
||||||
|
|
||||||
format( szBigString, 256, "[0xA1] %s(%d) :: %d :: %d\r\n", ReturnPlayerName( playerid ), playerid, p_WantedLevel[ playerid ], g_iTime );
|
|
||||||
AddFileLogLine( "security.txt", szBigString );
|
|
||||||
return 1;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if ( !loadingstats ) SendClientMessageFormatted( playerid, -1, ""COL_GOLD"[CRIME]{FFFFFF} Your wanted level has been modified by %d! Wanted level: %d", wantedlevel, p_WantedLevel[ playerid ] );
|
|
||||||
else SendClientMessageFormatted( playerid, -1, ""COL_GOLD"[RESUME]{FFFFFF} Your wanted level has been set to %d as you are resuming your life.", p_WantedLevel[ playerid ] );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
stock ClearPlayerWantedLevel( playerid )
|
|
||||||
{
|
|
||||||
PlayerTextDrawHide( playerid, p_WantedLevelTD[ playerid ] );
|
|
||||||
p_WantedLevel[ playerid ] = 0;
|
|
||||||
SetPlayerWantedLevel( playerid, 0 );
|
|
||||||
SetPlayerColorToTeam( playerid );
|
|
||||||
}
|
|
||||||
|
|
||||||
stock IsWeaponBanned( weaponid ) {
|
stock IsWeaponBanned( weaponid ) {
|
||||||
return 0 <= weaponid < MAX_WEAPONS && ( weaponid == 36 || weaponid == 37 || weaponid == 38 || weaponid == 39 || weaponid == 44 || weaponid == 45 );
|
return 0 <= weaponid < MAX_WEAPONS && ( weaponid == 36 || weaponid == 37 || weaponid == 38 || weaponid == 39 || weaponid == 44 || weaponid == 45 );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user