2018-04-13 04:50:25 +00:00
|
|
|
/*
|
|
|
|
* Irresistible Gaming (c) 2018
|
|
|
|
* Developed by Lorenc Pekaj
|
|
|
|
* Module: gangs.inc
|
|
|
|
* Purpose: gang system
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ** Includes ** */
|
2018-05-24 20:29:21 +00:00
|
|
|
#include < YSI\y_hooks >
|
2018-04-13 04:50:25 +00:00
|
|
|
|
|
|
|
/* ** Definitions ** */
|
|
|
|
#define MAX_GANGS ( MAX_PLAYERS ) // safest is MAX_PLAYERS
|
|
|
|
#define INVALID_GANG_ID ( -1 )
|
|
|
|
|
|
|
|
#define MAX_COLEADERS ( 3 )
|
2018-05-12 16:25:47 +00:00
|
|
|
|
2018-06-23 07:54:55 +00:00
|
|
|
/* ** Macros ** */
|
|
|
|
#define IsGangPrivate(%0) ( g_gangData[ %0 ] [ E_INVITE_ONLY ] )
|
|
|
|
|
2018-05-12 16:25:47 +00:00
|
|
|
/* ** Variables ** */
|
|
|
|
enum e_gang_data
|
|
|
|
{
|
|
|
|
E_SQL_ID, E_NAME[ 30 ], E_LEADER,
|
|
|
|
E_COLOR, E_SOFT_DELETE_TS,
|
|
|
|
|
|
|
|
E_BANK, E_KILLS, E_DEATHS,
|
|
|
|
E_SCORE, E_RESPECT,
|
|
|
|
|
|
|
|
E_COLEADER[ MAX_COLEADERS ], bool: E_INVITE_ONLY, E_JOIN_MSG[ 96 ],
|
|
|
|
|
|
|
|
bool: E_HAS_FACILITY
|
|
|
|
};
|
|
|
|
|
|
|
|
enum E_GANG_LEAVE_REASON
|
|
|
|
{
|
|
|
|
GANG_LEAVE_QUIT,
|
|
|
|
GANG_LEAVE_KICK,
|
|
|
|
GANG_LEAVE_UNKNOWN
|
|
|
|
};
|
|
|
|
|
|
|
|
new
|
|
|
|
g_gangColors[ ] = { 0x99FF00FF, 0x00CC00FF, 0x009999FF, 0x0033CCFF, 0x330099FF, 0x660099FF, 0xCC0099FF },
|
|
|
|
|
|
|
|
g_gangData [ MAX_GANGS ] [ e_gang_data ],
|
|
|
|
g_sortedGangData [ MAX_GANGS ] [ e_gang_data ], // used for sorting only
|
|
|
|
p_GangID [ MAX_PLAYERS ],
|
|
|
|
|
|
|
|
bool: p_gangInvited [ MAX_PLAYERS ] [ MAX_GANGS ],
|
|
|
|
p_gangInviteTick [ MAX_PLAYERS ],
|
|
|
|
|
|
|
|
Iterator:gangs<MAX_GANGS>
|
|
|
|
;
|
|
|
|
|
|
|
|
/* ** Forwards ** */
|
|
|
|
forward OnPlayerLeaveGang( playerid, gangid, reason );
|
|
|
|
forward ZoneTimer( );
|
|
|
|
|
|
|
|
/* ** Hooks ** */
|
|
|
|
hook OnGameModeInit( )
|
|
|
|
{
|
|
|
|
#if !defined DEBUG_MODE
|
|
|
|
// Remove inactive gang members
|
2018-06-23 07:54:55 +00:00
|
|
|
// mysql_single_query( "UPDATE `USERS` SET `GANG_ID`=-1 WHERE UNIX_TIMESTAMP()-`USERS`.`LASTLOGGED` > 1209600" );
|
2018-05-12 16:25:47 +00:00
|
|
|
|
|
|
|
// Remove gangs with a non existant gang leader / unmatched player gang id to gang leader id
|
|
|
|
mysql_single_query( "DELETE g FROM GANGS g LEFT JOIN USERS u ON g.LEADER = u.ID WHERE u.GANG_ID != g.ID OR u.ID IS NULL" );
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|