made a start on auth modulization but WIP

This commit is contained in:
Lorenc Pekaj 2018-12-23 00:06:42 +11:00
parent c0ecf96158
commit 8d25432f6e
6 changed files with 134 additions and 95 deletions

View File

@ -52,6 +52,8 @@
- Called when a player is unloading textdraws (on death, request class...) - Called when a player is unloading textdraws (on death, request class...)
- `OnPlayerC4Blown( playerid, Float: X, Float: Y, Float: Z, worldid )` - `OnPlayerC4Blown( playerid, Float: X, Float: Y, Float: Z, worldid )`
- Called when a player C4 is blown - Called when a player C4 is blown
- `OnPlayerJailed( playerid )`
- Called when a player is jailed
- `OnPlayerUnjailed( playerid, reasonid )` - `OnPlayerUnjailed( playerid, reasonid )`
- Called when a player is unjailed for a reason id - Called when a player is unjailed for a reason id
- `OnPlayerArrested( playerid, victimid, totalarrests, totalpeople )` - `OnPlayerArrested( playerid, victimid, totalarrests, totalpeople )`

View File

@ -20,6 +20,7 @@
#include "irresistible\cnr\wanted_level.pwn" #include "irresistible\cnr\wanted_level.pwn"
// reliant on core definitions // reliant on core definitions
#include "irresistible\cnr\auth\_auth.pwn"
#include "irresistible\cnr\vip\_vip.pwn" #include "irresistible\cnr\vip\_vip.pwn"
#include "irresistible\cnr\jobs.pwn" #include "irresistible\cnr\jobs.pwn"
#include "irresistible\cnr\experience.pwn" #include "irresistible\cnr\experience.pwn"

View File

@ -0,0 +1,9 @@
/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc
* Module: cnr\vip\_vip.pwn
* Purpose: encloses all authentication modules & components (cnr)
*/
/* ** Includes ** */
#include "irresistible\cnr\auth\login.pwn"

View File

@ -0,0 +1,27 @@
/*
* Irresistible Gaming (c) 2018
* Developed by Lorenc
* Module: cnr\auth\login.pwn
* Purpose: module associated with login componenets
*/
/* ** Includes ** */
#include < YSI\y_hooks >
/* ** Definitions ** */
/* ** Variables ** */
/* ** Hooks ** */
hook OnPlayerText( playerid, text[ ] )
{
if ( GetPlayerScore( playerid ) < 10 )
return SendServerMessage( playerid, "You need at least 10 score to talk. "COL_GREY"Use /ask or /report to talk to an admin in the meanwhile." ), Y_HOOKS_BREAK_RETURN_1;
if ( ! IsPlayerLoggedIn( playerid ) )
return SendError( playerid, "You must be logged in to talk." ), Y_HOOKS_BREAK_RETURN_1;
return Y_HOOKS_CONTINUE_RETURN_1;
}
/* ** Functions ** */

View File

@ -37,6 +37,10 @@ static stock
g_alcatrazTimestamp = 0 g_alcatrazTimestamp = 0
; ;
/* ** Forwards ** */
forward OnPlayerJailed( playerid );
forward OnPlayerUnjailed( playerid, reasonid );
/* ** Hooks ** */ /* ** Hooks ** */
hook OnPlayerEnterDynamicCP( playerid, checkpointid ) { hook OnPlayerEnterDynamicCP( playerid, checkpointid ) {
if ( IsPlayerJailed( playerid ) ) { if ( IsPlayerJailed( playerid ) ) {
@ -192,6 +196,96 @@ CMD:pdjail( playerid, params[ ] )
} }
/* ** Functions ** */ /* ** Functions ** */
stock JailPlayer( playerid, seconds, admin = 0 )
{
if ( playerid == INVALID_PLAYER_ID )
return 0;
static
Query[ 72 ], Float: armour;
// Neccessary Checks
if ( IsPlayerInMethlab( playerid ) ) {
haltMethamphetamine( playerid, GetPlayerMethLabVehicle( playerid ) );
}
// Callback
CallLocalFunction( "OnPlayerJailed", "d", playerid );
// Neccessary Functions
KillTimer ( p_JailTimer[ playerid ] );
KillTimer ( p_CuffAbuseTimer[ playerid ] );
PlayerTextDrawSetString ( playerid, p_JailTimeTD[ playerid ], "_" );
PlayerTextDrawShow ( playerid, p_JailTimeTD[ playerid ] );
// External Variables to Jail (resetting)
p_TicketIssuer [ playerid ] = INVALID_PLAYER_ID; // Reset Tickets
p_TicketTimestamp [ playerid ] = 0; // Reset Tickets
p_Cuffed { playerid } = false;
p_InfectedHIV { playerid } = false;
//p_Detained { playerid } = false;
//Delete3DTextLabel ( p_DetainedLabel[ playerid ] );
//p_DetainedLabel [ playerid ] = Text3D: INVALID_3DTEXT_ID;
//p_DetainedBy [ playerid ] = INVALID_PLAYER_ID;
// Primary Jail Variables
p_Jailed { playerid } = true;
p_JailTime [ playerid ] = seconds;
p_AdminJailed { playerid } = admin;
p_JailTimer [ playerid ] = SetTimerEx( "Unjail", 950, true, "d", playerid );
CancelEdit ( playerid );
RemovePlayerStolensFromHands( playerid );
StopPlayerUsingSlotMachine ( playerid );
RemoveEquippedOre ( playerid );
ClearPlayerWantedLevel ( playerid );
ResetPlayerWeapons ( playerid );
UntiePlayer ( playerid );
jailDoors ( playerid, false, true );
SetPlayerPosToPrison ( playerid );
Player_CheckPokerGame ( playerid, "Jailed" );
// External Functions
SetPlayerSpecialAction ( playerid, SPECIAL_ACTION_NONE );
ClearAnimations ( playerid );
RemovePlayerAttachedObject ( playerid, 2 );
SetPlayerHealth ( playerid, INVALID_PLAYER_ID );
if ( ! IsPlayerAdminJailed( playerid ) ) {
if ( p_MetalMelter[ playerid ] ) {
ShowPlayerHelpDialog( playerid, 4000, "You can break yourself out of prison with ~p~/breakout." );
} else {
ShowPlayerHelpDialog( playerid, 4000, "You can buy metal melters at Supa Save or a 24/7 store." );
}
}
format( Query, sizeof( Query ), "UPDATE `USERS` SET JAIL_TIME=%d,JAIL_ADMIN=%d WHERE `ID`=%d", seconds, admin, p_AccountID[ playerid ] );
mysql_single_query( Query );
if ( GetPlayerArmour( playerid, armour ) && armour ) {
SetPlayerArmour( playerid, 0.0 );
}
return 1;
}
function Unjail( playerid )
{
static
Query[ 64 ];
if ( !IsPlayerConnected( playerid ) ) return KillTimer( p_JailTimer[ playerid ] ), 0;
p_JailTime[ playerid ] --;
format( Query, sizeof( Query ), "Time Remaining:~n~%d seconds", p_JailTime[ playerid ] );
PlayerTextDrawSetString( playerid, p_JailTimeTD[ playerid ], Query );
if ( p_JailTime[ playerid ] < 1 )
CallLocalFunction( "OnPlayerUnjailed", "dd", playerid, 0 );
return 1;
}
stock SetPlayerPosToPrison( playerid ) stock SetPlayerPosToPrison( playerid )
{ {
static const static const

View File

@ -90,7 +90,6 @@ public OnServerSecondTick( );
public OnHelpHTTPResponse( index, response_code, data[ ] ); public OnHelpHTTPResponse( index, response_code, data[ ] );
public OnRulesHTTPResponse( index, response_code, data[ ] ); public OnRulesHTTPResponse( index, response_code, data[ ] );
public OnTwitterHTTPResponse( index, response_code, data[ ] ); public OnTwitterHTTPResponse( index, response_code, data[ ] );
public OnPlayerUnjailed( playerid, reasonid );
public OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid ); public OnPlayerAccessEntrance( playerid, entranceid, worldid, interiorid );
main() main()
@ -2011,12 +2010,6 @@ public OnPlayerText( playerid, text[ ] )
new new
time = g_iTime; time = g_iTime;
if ( GetPlayerScore( playerid ) < 10 )
return SendServerMessage( playerid, "You need at least 10 score to talk. "COL_GREY"Use /ask or /report to talk to an admin in the meanwhile." ), 0;
if ( !p_PlayerLogged{ playerid } )
return SendError( playerid, "You must be logged in to talk." ), 0;
if ( textContainsIP( text ) ) if ( textContainsIP( text ) )
return SendServerMessage( playerid, "Please do not advertise." ), 0; return SendServerMessage( playerid, "Please do not advertise." ), 0;
@ -7794,98 +7787,11 @@ public OnPlayerClickPlayer(playerid, clickedplayerid, source)
///////////////////////// /////////////////////////
// Functions // // Functions //
///////////////////////// /////////////////////////
stock SetServerRule( const rule[ ], const value[ ] ) stock SetServerRule( const rule[ ], const value[ ] )
{ {
return SendRconCommand( sprintf( "%s %s", rule, value ) ); return SendRconCommand( sprintf( "%s %s", rule, value ) );
} }
stock JailPlayer( playerid, seconds, admin = 0 )
{
if ( playerid == INVALID_PLAYER_ID )
return 0;
static
Query[ 72 ], Float: armour
;
// Neccessary Checks
if ( IsPlayerInMethlab( playerid ) )
haltMethamphetamine( playerid, GetPlayerMethLabVehicle( playerid ) );
// Neccessary Functions
KillTimer ( p_JailTimer[ playerid ] );
KillTimer ( p_CuffAbuseTimer[ playerid ] );
PlayerTextDrawSetString ( playerid, p_JailTimeTD[ playerid ], "_" );
PlayerTextDrawShow ( playerid, p_JailTimeTD[ playerid ] );
// External Variables to Jail (resetting)
p_TicketIssuer [ playerid ] = INVALID_PLAYER_ID; // Reset Tickets
p_TicketTimestamp [ playerid ] = 0; // Reset Tickets
p_Cuffed { playerid } = false;
//p_Detained { playerid } = false;
p_InfectedHIV { playerid } = false;
//Delete3DTextLabel ( p_DetainedLabel[ playerid ] );
//p_DetainedLabel [ playerid ] = Text3D: INVALID_3DTEXT_ID;
//p_DetainedBy [ playerid ] = INVALID_PLAYER_ID;
// Primary Jail Variables
p_Jailed { playerid } = true;
p_JailTime [ playerid ] = seconds;
p_AdminJailed { playerid } = admin;
p_JailTimer [ playerid ] = SetTimerEx( "Unjail", 950, true, "d", playerid );
CancelEdit ( playerid );
RemovePlayerStolensFromHands( playerid );
StopPlayerUsingSlotMachine ( playerid );
RemoveEquippedOre ( playerid );
ClearPlayerWantedLevel ( playerid );
ResetPlayerWeapons ( playerid );
UntiePlayer ( playerid );
jailDoors ( playerid, false, true );
SetPlayerPosToPrison ( playerid );
Player_CheckPokerGame ( playerid, "Jailed" );
// External Functions
SetPlayerSpecialAction ( playerid, SPECIAL_ACTION_NONE );
ClearAnimations ( playerid );
RemovePlayerAttachedObject ( playerid, 2 );
SetPlayerHealth ( playerid, INVALID_PLAYER_ID );
if ( !IsPlayerAdminJailed( playerid ) )
{
if ( p_MetalMelter[ playerid ] )
ShowPlayerHelpDialog( playerid, 4000, "You can break yourself out of prison with ~p~/breakout." );
else
ShowPlayerHelpDialog( playerid, 4000, "You can buy metal melters at Supa Save or a 24/7 store." );
}
format( Query, sizeof( Query ), "UPDATE `USERS` SET JAIL_TIME=%d,JAIL_ADMIN=%d WHERE `ID`=%d", seconds, admin, p_AccountID[ playerid ] );
mysql_single_query( Query );
if ( GetPlayerArmour( playerid, armour ) && armour )
SetPlayerArmour( playerid, 0.0 );
return 1;
}
function Unjail( playerid )
{
static
Query[ 64 ];
if ( !IsPlayerConnected( playerid ) ) return KillTimer( p_JailTimer[ playerid ] ), 0;
p_JailTime[ playerid ] --;
format( Query, sizeof( Query ), "Time Remaining:~n~%d seconds", p_JailTime[ playerid ] );
PlayerTextDrawSetString( playerid, p_JailTimeTD[ playerid ], Query );
if ( p_JailTime[ playerid ] < 1 )
CallLocalFunction( "OnPlayerUnjailed", "dd", playerid, 0 );
return 1;
}
stock SavePlayerData( playerid, bool: logout = false ) stock SavePlayerData( playerid, bool: logout = false )
{ {
static static