2018-09-23 04:56:34 +00:00
|
|
|
/*
|
|
|
|
* Irresistible Gaming (c) 2018
|
2018-12-12 08:21:57 +00:00
|
|
|
* Developed by Lorenc
|
2018-09-23 05:03:37 +00:00
|
|
|
* Module: cnr\player_settings.pwn
|
|
|
|
* Purpose: player settings that can be easily configured via /controlpanel (/cp)
|
2018-09-23 04:56:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* ** Includes ** */
|
|
|
|
#include < YSI\y_hooks >
|
|
|
|
|
|
|
|
/* ** Definitions ** */
|
2018-12-26 10:02:48 +00:00
|
|
|
#define MAX_SETTINGS ( 14 )
|
2018-09-23 05:03:37 +00:00
|
|
|
|
|
|
|
#define SETTING_BAILOFFERS ( 0 )
|
|
|
|
#define SETTING_EVENT_TP ( 1 )
|
|
|
|
#define SETTING_GANG_INVITES ( 2 )
|
|
|
|
#define SETTING_CHAT_PREFIXES ( 3 )
|
|
|
|
#define SETTING_RANSOMS ( 4 )
|
|
|
|
#define SETTING_AUTOSAVE ( 5 )
|
|
|
|
#define SETTING_CONNECTION_LOG ( 6 )
|
|
|
|
#define SETTING_HITMARKER ( 7 )
|
|
|
|
#define SETTING_VIPSKIN ( 8 )
|
|
|
|
#define SETTING_COINS_BAR ( 9 )
|
|
|
|
#define SETTING_TOP_DONOR ( 10 )
|
|
|
|
#define SETTING_WEAPON_PICKUP ( 11 )
|
2018-09-24 08:18:07 +00:00
|
|
|
#define SETTING_PASSIVE_MODE ( 12 )
|
2018-12-26 10:02:48 +00:00
|
|
|
#define SETTING_CHAT_ID ( 13 )
|
2018-09-23 04:56:34 +00:00
|
|
|
|
|
|
|
/* ** Variables ** */
|
2018-09-23 04:59:55 +00:00
|
|
|
static stock
|
2018-09-24 08:18:07 +00:00
|
|
|
g_PlayerSettings [ MAX_SETTINGS ] [ 24 ] = {
|
|
|
|
{ "Prevent Bail Offers" }, { "Prevent Event Teleports" }, { "Prevent Gang Invites" }, { "Prevent Chat Prefixes" }, { "Prevent Ransom Offers" },
|
|
|
|
{ "Prevent Auto-Save" }, { "Display Connection Log" }, { "Display Hitmarker" }, { "Set V.I.P Skin" }, { "Hide Total Coin Bar" }, { "Hide Last Donor Text" },
|
2018-12-27 07:08:12 +00:00
|
|
|
{ "Manual Pickup Weapon" }, { "Prevent Passive Mode" }, { "Display User ID In Chat" }
|
2018-09-23 04:56:34 +00:00
|
|
|
},
|
2018-09-23 05:03:37 +00:00
|
|
|
bool: p_PlayerSettings [ MAX_PLAYERS ] [ MAX_SETTINGS char ]
|
2018-09-23 04:56:34 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
/* ** Hooks ** */
|
|
|
|
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
|
|
|
|
{
|
|
|
|
if ( dialogid == DIALOG_CP_MENU && response )
|
|
|
|
{
|
|
|
|
if ( IsPlayerInEvent( playerid ) ) {
|
|
|
|
return SendError( playerid, "You cannot modify your player settings within an event." );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( listitem == 0 ) {
|
|
|
|
return ShowPlayerAccountGuard( playerid );
|
|
|
|
}
|
|
|
|
|
|
|
|
new
|
|
|
|
settingid = listitem - 1;
|
|
|
|
|
2018-09-24 08:18:07 +00:00
|
|
|
if ( settingid == SETTING_VIPSKIN && p_VIPLevel[ playerid ] < VIP_REGULAR ) {
|
|
|
|
return SendError( playerid, "You are not a V.I.P, to become one visit "COL_GREY"donate.sfcnr.com" );
|
|
|
|
}
|
|
|
|
|
2018-12-27 01:46:00 +00:00
|
|
|
// setting is being toggled ... then
|
|
|
|
if ( ! p_PlayerSettings[ playerid ] { settingid } == true )
|
2018-09-23 04:56:34 +00:00
|
|
|
{
|
2018-09-24 08:18:07 +00:00
|
|
|
if ( settingid == SETTING_VIPSKIN ) {
|
2018-09-23 04:56:34 +00:00
|
|
|
SyncObject( playerid );
|
|
|
|
ClearAnimations( playerid );
|
|
|
|
SetPlayerSkin( playerid, p_LastSkin[ playerid ] );
|
|
|
|
}
|
|
|
|
|
2018-09-24 08:18:07 +00:00
|
|
|
else if ( settingid == SETTING_COINS_BAR || settingid == SETTING_TOP_DONOR ) {
|
|
|
|
HidePlayerTogglableTextdraws( playerid, .force = false );
|
|
|
|
ShowPlayerTogglableTextdraws( playerid, .force = false );
|
|
|
|
}
|
2018-09-23 04:56:34 +00:00
|
|
|
|
2018-10-14 06:28:52 +00:00
|
|
|
/*else if ( settingid == SETTING_PASSIVE_MODE ) {
|
2018-09-24 12:51:05 +00:00
|
|
|
ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // avoid abusing
|
2018-10-14 06:28:52 +00:00
|
|
|
}*/
|
2018-09-23 04:56:34 +00:00
|
|
|
}
|
2018-12-27 01:46:00 +00:00
|
|
|
else // setting is not being toggled
|
2018-09-23 04:56:34 +00:00
|
|
|
{
|
2018-09-24 08:18:07 +00:00
|
|
|
if ( settingid == SETTING_COINS_BAR || settingid == SETTING_TOP_DONOR ) {
|
|
|
|
HidePlayerTogglableTextdraws( playerid, .force = false );
|
2018-09-23 04:56:34 +00:00
|
|
|
ShowPlayerTogglableTextdraws( playerid, .force = false );
|
2018-09-24 08:18:07 +00:00
|
|
|
}
|
2018-10-14 06:28:52 +00:00
|
|
|
/*else if ( settingid == SETTING_PASSIVE_MODE ) {
|
2018-09-24 12:51:05 +00:00
|
|
|
ResetPlayerPassiveMode( playerid, .passive_disabled = true ); // avoid abusing
|
2018-10-14 06:28:52 +00:00
|
|
|
}*/
|
2018-09-23 04:56:34 +00:00
|
|
|
}
|
2018-09-24 12:51:05 +00:00
|
|
|
|
2018-12-27 01:46:00 +00:00
|
|
|
TogglePlayerSetting( playerid, settingid, ! p_PlayerSettings[ playerid ] { settingid } );
|
2018-10-14 06:28:52 +00:00
|
|
|
SendServerMessage( playerid, ""COL_ORANGE"%s"COL_WHITE" is now %s. Changes may take effect after spawning/relogging.", g_PlayerSettings[ settingid ], p_PlayerSettings[ playerid ] { settingid } ? ( "enabled" ) : ( "disabled" ) );
|
2018-09-24 12:51:05 +00:00
|
|
|
|
|
|
|
if ( ! strmatch( inputtext, "ignore" )) {
|
|
|
|
cmd_cp( playerid, "" ); // Redirect to control panel again...
|
|
|
|
}
|
2018-09-23 04:56:34 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
hook OnPlayerConnect( playerid ) {
|
|
|
|
for ( new i = 0; i < MAX_SETTINGS; i ++ ) {
|
2018-09-24 08:18:07 +00:00
|
|
|
p_PlayerSettings[ playerid ] { i } = false;
|
2018-09-23 04:56:34 +00:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-09-27 23:07:58 +00:00
|
|
|
hook OnPlayerLogin( playerid )
|
2018-09-23 04:56:34 +00:00
|
|
|
{
|
2018-09-27 23:07:58 +00:00
|
|
|
format( szNormalString, sizeof( szNormalString ), "SELECT * FROM `SETTINGS` WHERE `USER_ID`=%d", GetPlayerAccountID( playerid ) );
|
2018-09-23 04:56:34 +00:00
|
|
|
mysql_function_query( dbHandle, szNormalString, true, "OnSettingsLoad", "d", playerid );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ** SQL Threads ** */
|
|
|
|
thread OnSettingsLoad( playerid )
|
|
|
|
{
|
|
|
|
if ( !IsPlayerConnected( playerid ) )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
new
|
|
|
|
rows = cache_get_row_count( );
|
|
|
|
|
|
|
|
if ( rows )
|
|
|
|
{
|
|
|
|
new
|
|
|
|
i = -1;
|
|
|
|
|
|
|
|
while( ++ i < rows )
|
|
|
|
{
|
|
|
|
new
|
|
|
|
settingid = cache_get_field_content_int( i, "SETTING_ID", dbHandle );
|
|
|
|
|
|
|
|
if ( settingid < MAX_SETTINGS ) // Must be something wrong otherwise...
|
|
|
|
p_PlayerSettings[ playerid ] { settingid } = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ** Commands ** */
|
|
|
|
CMD:cp( playerid, params[ ] ) return cmd_controlpanel( playerid, params );
|
2018-09-24 08:18:07 +00:00
|
|
|
CMD:settings( playerid, params[ ] ) return cmd_controlpanel( playerid, params );
|
2018-09-23 04:56:34 +00:00
|
|
|
CMD:controlpanel( playerid, params[ ] )
|
|
|
|
{
|
2018-09-24 08:18:07 +00:00
|
|
|
szLargeString = ""COL_WHITE"Setting\t"COL_WHITE"Status\n"COL_GREY"Irresistible Guard\t"COL_ORANGE">>>\n";
|
2018-09-23 04:56:34 +00:00
|
|
|
|
|
|
|
for( new i = 0; i < MAX_SETTINGS; i++ ) {
|
2018-09-24 08:18:07 +00:00
|
|
|
format( szLargeString, sizeof( szLargeString ), "%s%s\t%s\n", szLargeString, g_PlayerSettings[ i ], p_PlayerSettings[ playerid ] { i } ? ( ""#COL_GREEN"YES" ) : ( ""#COL_RED"NO" ) );
|
2018-09-23 04:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ShowPlayerDialog( playerid, DIALOG_CP_MENU, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}Control Panel", szLargeString, "Select", "Cancel" );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-09-25 04:00:37 +00:00
|
|
|
CMD:rpmode( playerid, params[ ] ) return cmd_passive( playerid, params );
|
2018-09-24 12:51:05 +00:00
|
|
|
CMD:passivemode( playerid, params[ ] ) return cmd_passive( playerid, params );
|
|
|
|
CMD:passive( playerid, params[ ] )
|
|
|
|
{
|
|
|
|
CallLocalFunction( "OnDialogResponse", "dddds", playerid, DIALOG_CP_MENU, 1, SETTING_PASSIVE_MODE + 1, "ignore" ); // cunning way
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-12-26 10:02:48 +00:00
|
|
|
CMD:passivelist( playerid, params[ ] )
|
2018-09-25 15:17:34 +00:00
|
|
|
{
|
2018-09-27 23:07:58 +00:00
|
|
|
new
|
2018-09-25 15:17:34 +00:00
|
|
|
count = 0;
|
2018-09-27 23:07:58 +00:00
|
|
|
|
2018-09-25 15:17:34 +00:00
|
|
|
szBigString[ 0 ] = '\0';
|
2018-09-27 23:07:58 +00:00
|
|
|
|
2018-09-25 15:17:34 +00:00
|
|
|
foreach ( new i : Player )
|
|
|
|
{
|
|
|
|
if ( IsPlayerPassive( i ) )
|
|
|
|
{
|
|
|
|
format( szBigString, sizeof( szBigString ), "%s%s(%d)\n", szBigString, ReturnPlayerName( i ), i );
|
|
|
|
count ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( count == 0 )
|
|
|
|
return SendError( playerid, "There is currently no players in passive mode." );
|
2018-09-27 23:07:58 +00:00
|
|
|
else
|
2018-09-25 15:17:34 +00:00
|
|
|
return ShowPlayerDialog(playerid, DIALOG_NULL, DIALOG_STYLE_LIST, ""COL_WHITE"Passive List", szBigString, "Close", "" ), 1;
|
|
|
|
}
|
|
|
|
|
2018-09-23 04:56:34 +00:00
|
|
|
/* ** Functions ** */
|
2018-12-27 01:46:00 +00:00
|
|
|
stock TogglePlayerSetting( playerid, settingid, bool: toggle )
|
|
|
|
{
|
|
|
|
if ( ( p_PlayerSettings[ playerid ] { settingid } = toggle ) == true ) {
|
|
|
|
mysql_single_query( sprintf( "INSERT INTO `SETTINGS`(`USER_ID`, `SETTING_ID`) VALUES (%d, %d)", p_AccountID[ playerid ], settingid ) );
|
|
|
|
} else {
|
|
|
|
mysql_single_query( sprintf( "DELETE FROM `SETTINGS` WHERE `USER_ID`=%d AND `SETTING_ID`=%d", p_AccountID[ playerid ], settingid ) );
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-09-23 04:56:34 +00:00
|
|
|
stock IsPlayerSettingToggled( playerid, settingid ) {
|
2018-09-24 08:18:07 +00:00
|
|
|
return p_PlayerSettings[ playerid ] { settingid };
|
2018-09-23 04:56:34 +00:00
|
|
|
}
|
2018-11-23 16:47:20 +00:00
|
|
|
|
|
|
|
stock IsPlayerVIPSkinToggled( playerid ) {
|
|
|
|
return p_PlayerSettings[ playerid ] { SETTING_VIPSKIN };
|
2018-12-27 07:08:12 +00:00
|
|
|
}
|