irresistible guard as component
This commit is contained in:
parent
d67e2ae6a0
commit
51c281878a
@ -12,9 +12,8 @@
|
|||||||
#include "irresistible\cnr\global.pwn"
|
#include "irresistible\cnr\global.pwn"
|
||||||
#include "irresistible\cnr\classes.pwn"
|
#include "irresistible\cnr\classes.pwn"
|
||||||
#include "irresistible\cnr\textdraws.pwn"
|
#include "irresistible\cnr\textdraws.pwn"
|
||||||
#include "irresistible\cnr\cities.pwn"
|
#include "irresistible\cnr\spawn.pwn"
|
||||||
#include "irresistible\cnr\dialog_ids.pwn"
|
#include "irresistible\cnr\dialog_ids.pwn"
|
||||||
#include "irresistible\cnr\vip.pwn"
|
|
||||||
|
|
||||||
// static cnr features
|
// static cnr features
|
||||||
#include "irresistible\cnr\static\_cnr_static.pwn"
|
#include "irresistible\cnr\static\_cnr_static.pwn"
|
||||||
|
@ -8,10 +8,13 @@
|
|||||||
/* ** Includes ** */
|
/* ** Includes ** */
|
||||||
|
|
||||||
// core
|
// core
|
||||||
|
#include "irresistible\cnr\features\vip.pwn"
|
||||||
|
#include "irresistible\cnr\features\irresistibleguard.pwn"
|
||||||
|
|
||||||
|
// other
|
||||||
#include "irresistible\cnr\features\fps.pwn"
|
#include "irresistible\cnr\features\fps.pwn"
|
||||||
#include "irresistible\cnr\features\radio.pwn"
|
#include "irresistible\cnr\features\radio.pwn"
|
||||||
#include "irresistible\cnr\features\cash_cards.pwn"
|
#include "irresistible\cnr\features\cash_cards.pwn"
|
||||||
#include "irresistible\cnr\features\furniture.pwn"
|
|
||||||
#include "irresistible\cnr\features\weapon_drop.pwn"
|
#include "irresistible\cnr\features\weapon_drop.pwn"
|
||||||
#include "irresistible\cnr\features\ammunation.pwn"
|
#include "irresistible\cnr\features\ammunation.pwn"
|
||||||
#include "irresistible\cnr\features\duel.pwn"
|
#include "irresistible\cnr\features\duel.pwn"
|
||||||
|
127
gamemodes/irresistible/cnr/features/irresistibleguard.pwn
Normal file
127
gamemodes/irresistible/cnr/features/irresistibleguard.pwn
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* Irresistible Gaming (c) 2018
|
||||||
|
* Developed by Lorenc Pekaj
|
||||||
|
* Module: cnr\irresistibleguard.pwn
|
||||||
|
* Purpose: provides account protection in the form of email securing
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ** Includes ** */
|
||||||
|
#include < YSI\y_hooks >
|
||||||
|
|
||||||
|
/* ** Definitions ** */
|
||||||
|
#define SECURITY_MODE_MILD ( 0 )
|
||||||
|
#define SECURITY_MODE_PARANOID ( 1 )
|
||||||
|
#define SECURITY_MODE_DISABLED ( 2 )
|
||||||
|
|
||||||
|
/* ** Variables ** */
|
||||||
|
enum E_IRRESISTIBLE_GUARD
|
||||||
|
{
|
||||||
|
E_ID, E_EMAIL[ 64 ], E_MODE,
|
||||||
|
bool: E_VERIFIED, E_LAST_DISABLED
|
||||||
|
};
|
||||||
|
|
||||||
|
new
|
||||||
|
p_accountSecurityData [ MAX_PLAYERS ] [ E_IRRESISTIBLE_GUARD ]
|
||||||
|
;
|
||||||
|
|
||||||
|
/* ** Hooks ** */
|
||||||
|
hook OnPlayerDisconnect( playerid, reason )
|
||||||
|
{
|
||||||
|
p_accountSecurityData[ playerid ] [ E_VERIFIED ] = false;
|
||||||
|
p_accountSecurityData[ playerid ] [ E_ID ] = 0;
|
||||||
|
p_accountSecurityData[ playerid ] [ E_LAST_DISABLED ] = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
|
||||||
|
{
|
||||||
|
if ( ( dialogid == DIALOG_ACC_GUARD ) && response )
|
||||||
|
{
|
||||||
|
if ( p_accountSecurityData[ playerid ] [ E_ID ] && ! p_accountSecurityData[ playerid ] [ E_VERIFIED ] && p_accountSecurityData[ playerid ] [ E_MODE ] != SECURITY_MODE_DISABLED )
|
||||||
|
return SendError( playerid, "You must be verified to use this feature." );
|
||||||
|
|
||||||
|
switch ( listitem )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if ( p_accountSecurityData[ playerid ] [ E_ID ] )
|
||||||
|
return SendError( playerid, "Your email is already confirmed!" ), ShowPlayerAccountGuard( playerid ), 1;
|
||||||
|
|
||||||
|
format( szNormalString, sizeof( szNormalString ), "SELECT * FROM `EMAILS` WHERE `USER_ID`=%d", p_AccountID[ playerid ] );
|
||||||
|
mysql_function_query( dbHandle, szNormalString, true, "OnEmailConfirm", "d", playerid );
|
||||||
|
}
|
||||||
|
case 1: ShowPlayerDialog( playerid, DIALOG_ACC_GUARD_MODE, DIALOG_STYLE_TABLIST, "{FFFFFF}Irresistible Guard - Mode", "Mild\t"COL_GREY"Must verify IP before making transactions\nParanoid\t"COL_GREY"Must verify IP after logging in\nDisable\t"COL_GREY"No form of verification", "Select", "Back" );
|
||||||
|
case 2:
|
||||||
|
{
|
||||||
|
format( szBigString, sizeof( szBigString ), "SELECT * FROM `EMAILS` WHERE `ID`=%d", p_accountSecurityData[ playerid ] [ E_ID ] );
|
||||||
|
mysql_function_query( dbHandle, szBigString, true, "OnAccountGuardDelete", "d", playerid );
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
if ( p_AddedEmail{ playerid } )
|
||||||
|
return SendError( playerid, "You already added an email to your account before." );
|
||||||
|
|
||||||
|
if ( GetPlayerScore( playerid ) < 1000 )
|
||||||
|
return SendServerMessage( playerid, "Get at least 1000 score, then use this feature." );
|
||||||
|
|
||||||
|
Beep( playerid );
|
||||||
|
p_AddedEmail{ playerid } = true;
|
||||||
|
SetPlayerVipLevel( playerid, VIP_REGULAR, .interval = 259560 ); // 3 days of vip
|
||||||
|
mysql_single_query( sprintf( "UPDATE `USERS` SET `USED_EMAIL`=1 WHERE `ID`=%d", p_AccountID[ playerid ] ) );
|
||||||
|
SendGlobalMessage( COLOR_GOLD, "[EMAIL CONFIRMED]"COL_GREY" %s(%d) has confirmed their "COL_GOLD"/email"COL_GREY" and received 3 days of V.I.P!", ReturnPlayerName( playerid ), playerid );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( dialogid == DIALOG_ACC_GUARD_CONFIRM )
|
||||||
|
{
|
||||||
|
if ( ! response )
|
||||||
|
{
|
||||||
|
if ( p_accountSecurityData[ playerid ] [ E_MODE ] == SECURITY_MODE_PARANOID ) {
|
||||||
|
return Kick( playerid );
|
||||||
|
}
|
||||||
|
|
||||||
|
// allow other modes
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
szInput[ 10 ];
|
||||||
|
|
||||||
|
format( szInput, sizeof( szInput ), "%s", inputtext );
|
||||||
|
trimString( szInput ); // gotta take out the whitespace
|
||||||
|
|
||||||
|
if ( strlen( szInput ) != 8 )
|
||||||
|
return SendError( playerid, "The verification code must be 8 characters." ), ShowPlayerAccountVerification( playerid );
|
||||||
|
|
||||||
|
mysql_format( dbHandle, szBigString, sizeof( szBigString ), "SELECT * FROM `USER_CONFIRMED_IPS` WHERE `USER_ID`=%d AND `IP`='%e' AND `TOKEN`='%e'", p_AccountID[ playerid ], ReturnPlayerIP( playerid ), szInput );
|
||||||
|
mysql_function_query( dbHandle, szBigString, true, "OnAccountGuardVerify", "d", playerid );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if ( dialogid == DIALOG_ACC_GUARD_DEL_CANCEL )
|
||||||
|
{
|
||||||
|
if ( !response )
|
||||||
|
return ShowPlayerAccountGuard( playerid );
|
||||||
|
|
||||||
|
p_accountSecurityData[ playerid ] [ E_LAST_DISABLED ] = 0;
|
||||||
|
mysql_single_query( sprintf( "UPDATE `EMAILS` SET `LAST_CHANGED`=%d,`LAST_DISABLED`=0 WHERE `ID`=%d", g_iTime, p_accountSecurityData[ playerid ] [ E_ID ] ) );
|
||||||
|
return SendServerMessage( playerid, "You have cancelled the process to removing Irresistible Guard." );
|
||||||
|
}
|
||||||
|
else if ( dialogid == DIALOG_ACC_GUARD_MODE )
|
||||||
|
{
|
||||||
|
if ( !response )
|
||||||
|
return ShowPlayerAccountGuard( playerid );
|
||||||
|
|
||||||
|
if ( ! p_accountSecurityData[ playerid ] [ E_ID ] )
|
||||||
|
return SendError( playerid, "You need to assign an email to your account." );
|
||||||
|
|
||||||
|
p_accountSecurityData[ playerid ] [ E_MODE ] = listitem;
|
||||||
|
mysql_single_query( sprintf( "UPDATE `EMAILS` SET `MODE`=%d WHERE `ID`=%d", listitem, p_accountSecurityData[ playerid ] [ E_ID ] ) );
|
||||||
|
SendServerMessage( playerid, "Your Irresistible Guard mode is now set to "COL_GREY"%s"COL_WHITE".", SecurityModeToString( listitem ) );
|
||||||
|
return ShowPlayerAccountGuard( playerid );
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ** Functions ** */
|
1267
gamemodes/sf-cnr.pwn
1267
gamemodes/sf-cnr.pwn
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user