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 ** */
|
2019-04-09 05:40:28 +00:00
|
|
|
#define MAX_SETTINGS ( 13 )
|
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 )
|
2019-01-01 11:46:57 +00:00
|
|
|
#define SETTING_CHAT_ID ( 5 )
|
2018-09-23 05:03:37 +00:00
|
|
|
#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 )
|
2019-04-09 05:40:28 +00:00
|
|
|
#define SETTING_HIDE_GAMB_MSG ( 12 )
|
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" },
|
2019-01-01 11:46:57 +00:00
|
|
|
{ "Display User ID In Chat" }, { "Display Connection Log" }, { "Display Hitmarker" }, { "Set V.I.P Skin" }, { "Hide Total Coin Bar" }, { "Hide Last Donor Text" },
|
2019-04-09 05:40:28 +00:00
|
|
|
{ "Manual Pickup Weapon" }, { "Hide Gambling Win Msgs" }
|
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 ** */
|
2019-01-01 13:19:17 +00:00
|
|
|
hook OnPlayerRegister( playerid )
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-09-23 04:56:34 +00:00
|
|
|
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 ) {
|
2023-12-28 23:47:25 +00:00
|
|
|
return SendError( playerid, "You are not a V.I.P, to become one please discuss with admins" );
|
2018-09-24 08:18:07 +00:00
|
|
|
}
|
|
|
|
|
2020-05-27 21:30:40 +00:00
|
|
|
// save setting
|
|
|
|
TogglePlayerSetting( playerid, settingid, ! p_PlayerSettings[ playerid ] { settingid } );
|
|
|
|
// setting is not being toggled
|
2018-12-27 01:46:00 +00:00
|
|
|
if ( ! p_PlayerSettings[ playerid ] { settingid } == true )
|
2020-05-27 21:30:40 +00:00
|
|
|
{
|
|
|
|
if ( settingid == SETTING_COINS_BAR || settingid == SETTING_TOP_DONOR ) {
|
|
|
|
ShowPlayerTogglableTextdraws( playerid, .force = false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // setting is being toggled ... then
|
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
|
|
|
if ( settingid == SETTING_COINS_BAR || settingid == SETTING_TOP_DONOR ) {
|
|
|
|
HidePlayerTogglableTextdraws( playerid, .force = false );
|
|
|
|
}
|
2018-09-23 04:56:34 +00:00
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2019-01-01 06:27:00 +00:00
|
|
|
hook OnPlayerLoadTextdraws( playerid ) {
|
|
|
|
ShowPlayerTogglableTextdraws( playerid );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
hook OnPlayerUnloadTextdraws( playerid ) {
|
|
|
|
HidePlayerTogglableTextdraws( playerid );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-09-23 04:56:34 +00:00
|
|
|
/* ** 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ** Functions ** */
|
2019-01-01 06:27:00 +00:00
|
|
|
static stock ShowPlayerTogglableTextdraws( playerid, bool: force = false )
|
|
|
|
{
|
|
|
|
// Current Coins
|
|
|
|
if ( ! IsPlayerSettingToggled( playerid, SETTING_COINS_BAR ) || force ) {
|
|
|
|
TextDrawShowForPlayer( playerid, g_CurrentCoinsTD );
|
|
|
|
PlayerTextDrawShow( playerid, p_CoinsTD[ playerid ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Top donor
|
|
|
|
if ( ! IsPlayerSettingToggled( playerid, SETTING_TOP_DONOR ) || force ) {
|
|
|
|
TextDrawShowForPlayer( playerid, g_TopDonorTD );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static stock HidePlayerTogglableTextdraws( playerid, bool: force = true )
|
|
|
|
{
|
|
|
|
// Current Coins
|
|
|
|
if ( IsPlayerSettingToggled( playerid, SETTING_COINS_BAR ) || force ) {
|
|
|
|
TextDrawHideForPlayer( playerid, g_CurrentCoinsTD );
|
|
|
|
PlayerTextDrawHide( playerid, p_CoinsTD[ playerid ] );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Top donor
|
|
|
|
if ( IsPlayerSettingToggled( playerid, SETTING_TOP_DONOR ) || force ) {
|
|
|
|
TextDrawHideForPlayer( playerid, g_TopDonorTD );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 };
|
2020-05-27 21:30:40 +00:00
|
|
|
}
|