Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Includes */
- #include < amxmodx >
- #include < amxmisc >
- #include < sqlvault_ex >
- #include < cstrike >
- #include < hamsandwich >
- #include < fakemeta_util >
- #include < regex >
- /* Defines */
- #define ADMIN_ACCESS ADMIN_IMMUNITY
- #define TASKID_GLOW 12654
- #define REGEX_STEAMID_PATTERN "^^STEAM_0:(0|1):\d+$"
- #define MAX_MEMBERS 15
- #define MAX_GANGS 13
- #define MAX_ADMINS 3
- #define GANG_COST 250000
- #define FILE_NAME "GangSaveFixed"
- /* Natives */
- native get_user_cash( const index );
- native set_user_cash( const index, setCash );
- native is_lr_active();
- native is_day();
- /* Constants */
- new const Info[ 5 ][ ] =
- {
- "Gang System",
- "1.0",
- "Built by Rejack || Edit by @.TheBomB`",
- "Top JailBreak",
- "Top Jailbreak"
- };
- enum _:GangInfo
- {
- Trie:GangMembers,
- GangName[ 64 ],
- GangRegen, // Regen
- GangBoost, // Cash Boost
- GangGetCash, // Get Cash
- GangNext, // Next Cash
- GangCash, // Cash
- NumMembers
- };
- enum
- {
- VALUE_REGEN, // Regen
- VALUE_BOOST, // Cash Boost
- VALUE_GETCASH, // Get Cash
- VALUE_NEXTCASH,
- VALUE_CASH
- }
- enum
- {
- STATUS_NONE,
- STATUS_MEMBER,
- STATUS_ADMIN,
- STATUS_LEADER
- };
- enum _:enSkills
- {
- skNum,
- skCost
- };
- enum _:enBasic
- {
- baseName[ 32 ],
- baseEnum,
- baseCharMax
- };
- enum _:enGangColors
- {
- rColor,
- gColor,
- bColor,
- ColorName[ 20 ]
- };
- new const g_szGangValues[ ][ ] =
- {
- "Regeneration", // Regen
- "CashBoost", // Cash Boost
- "GetCash", // Get Cash
- "NextCash",
- "Cash"
- };
- new const gHealth[ ][ enSkills ] =
- {
- { 0, 50000 },
- { 40, 85000 },
- { 35, 140000 },
- { 30, 200000 },
- { 20, 250000 },
- { 15, 0 }
- };
- new const gGetCash[ ][ enSkills ] =
- {
- { 0, 50000 },
- { 50, 150000 },
- { 100, 225000 },
- { 150, 325000 },
- { 200, 425000 },
- { 250, 550000 }
- };
- new const gCashBoost[ ][ enSkills ] =
- {
- { 0, 75000 },
- { 25, 140000 },
- { 50, 250000 },
- { 75, 325000 },
- { 100, 0 }
- };
- new const gNextCash[ ][ enSkills ] =
- {
- { 0, 125000 },
- { 100, 250000 },
- { 250, 380000 },
- { 325, 500000 },
- { 500, 0 }
- };
- new const szSkills[ ][ enBasic ] =
- {
- { "Health Regeneration", GangRegen, charsmax( gHealth ) },
- { "Get Cash", GangGetCash, charsmax( gGetCash ) },
- { "Extra Cash", GangBoost, charsmax( gCashBoost ) },
- { "Next Cash", GangNext, charsmax( gNextCash ) }
- };
- new g_iGangsColors[ MAX_GANGS ][ enGangColors ] =
- {
- { 255, 255, 255, "White" }, // White
- { 0, 80, 255, "Aqua" },
- { 255, 255, 0, "Yellow" }, // Yellow
- { 39, 25, 255, "Purple" }, // Purple
- { 255, 127, 0, "Orange" }, // Orange
- { 255, 0, 0, "Red" }, // Red
- { 0, 255, 0, "Green" }, // Green
- { 0, 0, 255, "Blue" }, // Blue
- { 127, 0, 255, "Violet" }, // Violet
- { 128, 128, 128, "Grey" }, // Navajo White 4
- { 46, 210, 125, "Turquoise" }, // LT Blue
- { 184, 195, 61, "Green Yellow" }, // Green Yellow // Aqua
- { 55, 42, 212, "Pink" } // Azure 3
- };
- /* Tries */
- new Trie:g_tGangNames;
- new Trie:g_tGangValues;
- /* Vault */
- new SQLVault:g_hVault;
- /* Arrays */
- new Array:g_aGangs, szItem[ 256 ];
- /* Integers */
- new g_iGang[ 33 ];
- /* Booleans */
- new bool: bGetCash[ 33 ], bool: bGlow;
- /* Floats */
- new Float: fRegen[ 33 ];
- /* Regex */
- new Regex:g_SteamID_pattern;
- new g_regex_return;
- #define IsValidAuthid(%1) (regex_match_c(%1, g_SteamID_pattern, g_regex_return) > 0)
- /* Costume Strings */
- enum StrType (<<= 1)
- {
- STRTYPE_NUM = 1,
- STRTYPE_ALPHA,
- STRTYPE_SPACE
- };
- #define is_str_alpha(%1) is_str_type((%1), STRTYPE_ALPHA)
- #define is_char(%1) (0 < (%1) <= 255)
- public plugin_init()
- {
- register_plugin( Info[ 0 ], Info[ 1 ], Info[ 2 ] );
- register_clcmd( "say /check", "CmdCheckCmd" );
- register_clcmd( "say", "CmdSay" );
- register_clcmd( "say /gang", "CmdGang" );
- register_clcmd( "_GangCreate_", "CmdCreateGang" );
- register_clcmd( "_GangDonate_", "CmdGangDonate" );
- register_forward( FM_PlayerPreThink, "FwdPreThink" );
- register_event( "DeathMsg", "evDeathMsg", "a" );
- register_logevent( "evRoundStart", 2, "1=Round_Start" );
- g_aGangs = ArrayCreate( GangInfo );
- g_tGangValues = TrieCreate();
- g_tGangNames = TrieCreate();
- g_hVault = sqlv_open_local( FILE_NAME, false );
- sqlv_init_ex( g_hVault );
- new error[ 2 ];
- g_SteamID_pattern = regex_compile(REGEX_STEAMID_PATTERN, g_regex_return, error, sizeof(error) - 1);
- for( new i; i < sizeof g_szGangValues; i++ )
- TrieSetCell( g_tGangValues, g_szGangValues[ i ], i );
- LoadGangs();
- }
- public CmdCheckCmd( index )
- {
- if( g_iGang[ index ] > -1 )
- {
- if( is_day() )
- fm_set_user_rendering( index, kRenderFxGlowShell, g_iGangsColors[ g_iGang[ index ] ][ 0 ], g_iGangsColors[ g_iGang[ index ] ][ 1 ], g_iGangsColors[ g_iGang[ index ] ][ 2 ], 48 );
- }
- return 1;
- }
- public plugin_natives()
- {
- register_library( "GangLibrary" );
- register_native( "set_glow", "_set_glow" );
- register_native( "remove_glow", "_remove_glow" );
- register_native( "get_user_gang_nextcash", "_get_user_gang_nextcash" );
- }
- public _get_user_gang_nextcash( plugin, params )
- {
- static index;
- index = get_param( 1 );
- if ( g_iGang[ index ] == -1 )
- return 0;
- static aData[ GangInfo ], lvl, cash;
- ArrayGetArray( g_aGangs, g_iGang[ index ], aData );
- lvl = aData[ GangNext ];
- cash = gNextCash[ lvl ][ skNum ];
- return cash;
- }
- public CmdCreateGang( client )
- {
- if ( get_user_cash( client ) < GANG_COST )
- return ColorChat( client, "You don't have enough cash." );
- if ( g_iGang[ client ] > -1 )
- return ColorChat( client, "You're already in a gang" );
- if ( ArraySize( g_aGangs ) >= MAX_GANGS - 1 )
- return ColorChat( client, "There are too many gangs." );
- static szArgs[ 64 ];
- read_args( szArgs, charsmax( szArgs ) );
- remove_quotes( szArgs );
- if ( TrieKeyExists( g_tGangNames, szArgs ) )
- {
- CmdGang( client );
- return ColorChat( client, "There's already a gang with that name." );
- }
- if ( strlen( szArgs ) < 3 )
- return ColorChat( client, "The name is too short." );
- if ( !is_str_alpha( szArgs ) )
- return ColorChat( client, "You need to use letters only." );
- static bData[ GangInfo ];
- for ( new i; i < ArraySize( g_aGangs ); i++ )
- {
- ArrayGetArray( g_aGangs, i, bData );
- if ( equali( bData[ GangName ], szArgs ) )
- return ColorChat( client, "Theres already a gang with that name." );
- }
- new aData[ GangInfo ];
- aData[ GangName ] = szArgs;
- aData[ GangRegen ] = 0;
- aData[ GangBoost ] = 0;
- aData[ GangGetCash ] = 0;
- aData[ GangNext ] = 0;
- aData[ GangCash ] = 0;
- aData[ NumMembers ] = 0;
- aData[ GangMembers ] = _:TrieCreate();
- ArrayPushArray( g_aGangs, aData );
- set_user_cash( client, get_user_cash( client ) - GANG_COST );
- set_user_gang( client, ArraySize( g_aGangs ) - 1, STATUS_LEADER );
- log_amx( "%s (%s|%s) opened the gang: %s (%i).", szName( client ), szAuth( client ), szAddress( client ), szArgs, g_iGang[ client ] );
- set_task(5.0, "SaveGangs");
- return ColorChat( 0, "^3%s^1 created the gang:^4 %s", szName( client ), szArgs );
- }
- public CmdGangDonate( client )
- {
- if ( !is_user_connected( client ) )
- return 1;
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- new aData[ GangInfo ];
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- static szArgs[ 32 ], iAmount;
- read_args( szArgs, charsmax( szArgs ) );
- remove_quotes( szArgs );
- iAmount = str_to_num( szArgs );
- if ( !is_str_num( szArgs ) )
- return 1;
- if ( iAmount < 1 )
- {
- client_cmd( client, "messagemode _GangDonate_" );
- return ColorChat( client, "You need to depoist at least^4 1 Cash^1." );
- }
- if ( iAmount > get_user_cash( client ) )
- {
- client_cmd( client, "messagemode _GangDonate_" );
- return ColorChat( client, "You don't have this amount of cash." );
- }
- new Players[ 32 ], iNum, iTemp;
- get_players( Players, iNum, "ch" );
- for ( new i; i < iNum; i++ )
- {
- iTemp = Players[ i ];
- if ( g_iGang[ iTemp ] != g_iGang[ client ] || iTemp == client )
- continue;
- ColorChat( iTemp, "^4%s^1 donated^3 %i^1 cash to the^3 %s^1 gang.", szName( client ), iAmount, aData[ GangName ]);
- }
- ColorChat( client, "You donated^3 %i^1 cash to the gang^3 %s^1.", iAmount, aData[ GangName ] );
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- aData[ GangCash ] += iAmount;
- ArraySetArray( g_aGangs, g_iGang[ client ], aData );
- set_user_cash( client, get_user_cash( client ) - iAmount );
- return 1;
- }
- public plugin_end()
- {
- SaveGangs();
- sqlv_close( g_hVault );
- }
- public client_putinserver( client )
- {
- g_iGang[ client ] = get_user_gang( client );
- bGetCash[ client ] = true;
- fRegen[ client ] = get_gametime();
- }
- public client_disconnect( client )
- {
- g_iGang[ client ] = -1;
- }
- public CmdGang( client )
- {
- static Menu, aData[ GangInfo ], szGangName[ 32 ];
- szGangName = "None";
- if ( g_iGang[ client ] > -1 )
- {
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- formatex( szGangName, charsmax( szGangName ), aData[ GangName ] );
- }
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gang Menu\r |\w Main Menu^n", Info[ 3 ])
- Menu = menu_create( szItem, "HandlerGangMenu" );
- formatex( szItem, charsmax( szItem ), "%sCreate Gang \r[ 250,000 cash ]", (g_iGang[ client ]>-1) ? "\d" : (get_user_cash( client )<GANG_COST) ? "\d" : "\w" );
- menu_additem( Menu, szItem );
- formatex( szItem, charsmax( szItem ), "%sLeave Gang", (g_iGang[ client ]==-1) ? "\d" : (getStatus( client, g_iGang[ client ] )==STATUS_LEADER) ? "\d" : "\w" );
- menu_additem( Menu, szItem );
- formatex( szItem, charsmax( szItem ), "%sMembers Menu", (g_iGang[ client ]==-1) ? "\d" : "\w" );
- menu_additem( Menu, szItem );
- formatex( szItem, charsmax( szItem ), "%sGang %sAdmins%s Menu ",
- (g_iGang[ client ]==-1) ? "\d" : (getStatus( client, g_iGang[ client ] )>=STATUS_ADMIN) ? "\w" : "\d",
- (g_iGang[ client ]==-1) ? "\d" : (getStatus( client, g_iGang[ client ] )>=STATUS_ADMIN) ? "\y" : "\d",
- (g_iGang[ client ]==-1) ? "\d" : (getStatus( client, g_iGang[ client ] )>=STATUS_ADMIN) ? "\w" : "\d");
- menu_additem( Menu, szItem );
- formatex( szItem, charsmax( szItem ), "%sGang %sLeader%s Menu",
- (g_iGang[ client ]==-1) ? "\d" : (getStatus( client, g_iGang[ client ] )>=STATUS_LEADER) ? "\w" : "\d",
- (g_iGang[ client ]==-1) ? "\d" : (getStatus( client, g_iGang[ client ] )>=STATUS_LEADER) ? "\r" : "\d",
- (g_iGang[ client ]==-1) ? "\d" : (getStatus( client, g_iGang[ client ] )>=STATUS_LEADER) ? "\w" : "\d");
- menu_additem( Menu, szItem );
- menu_additem( Menu, "View Server Gangs" );
- if(!(g_iGang[ client ] == -1))
- {
- formatex( szItem, charsmax( szItem ), "^n\dYour Gang Info:^n\r#################^n\wGang Name:\y %s^n\wGang Leader\y %s^n\wGang Color:\y %s^n\wGang Cash:\y %i Cash^n\wGang Members:\y %i/%i^n\wYour Rank:\y %s^n\r#################"
- ,aData[ GangName ], GetGangOwner( g_iGang[ client ] ), g_iGangsColors[ g_iGang[ client] ][ ColorName ], aData[ GangCash ], aData[ NumMembers ], MAX_MEMBERS, getRank( client ));
- menu_addtext(Menu, szItem);
- }
- menu_display( client, Menu );
- return 1;
- }
- public HandlerGangMenu( client, Menu, Item )
- {
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- static iStatus;
- iStatus = getStatus( client, g_iGang[ client ] );
- switch ( Item )
- {
- case 0:
- {
- if ( !(g_iGang[ client ] == -1) )
- {
- ColorChat(client, "You are in a^3 gang^1")
- return CmdGang( client );
- }
- else
- return CmdGang123( client );
- }
- case 1:
- {
- if ( g_iGang[ client ] == -1 )
- return CmdGang( client );
- else if ( iStatus == STATUS_LEADER )
- return CmdGang( client );
- return CmdLeaveConfirm( client );
- }
- case 2:
- {
- if ( g_iGang[ client ] == -1 )
- return CmdGang( client );
- return CmdMembersMenu( client );
- }
- case 3:
- {
- if ( g_iGang[ client ] == -1 )
- return CmdGang( client );
- else if ( iStatus < STATUS_ADMIN )
- return CmdGang( client );
- return CmdAdminMenu( client );
- }
- case 4:
- {
- if ( g_iGang[ client ] == -1 )
- return CmdGang( client );
- else if ( iStatus < STATUS_LEADER )
- return CmdGang( client );
- return CmdOwnerMenu( client );
- }
- case 5:
- return CmdGangsInfo( client );
- }
- menu_destroy( Menu );
- return 1;
- }
- public CmdTopGangs(client, Item)
- {
- static aData[ GangInfo ];
- new buffer[2048]
- new len = formatex(buffer, 2047, "<h1 align=center>Titaniums Top Gang</h1> <body bgcolor=#BBBBB><table width=80%% cellpaddinga=2 cellspaci=200 border=9")
- len += formatex(buffer[len], 2047-len, "<tr align=center bgcolor=#99999><th width=5%%> # <th width=20%% align=left> Name <th width=20%%> Leader")
- new iTotal;
- if( iTotal )
- {
- for (new i = 0; i < iTotal; i++)
- {
- len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %s <td align=center> %s <td> %d - [%s] <td> %d <td> %d <td> ", ((i%2)==0) ? "" : " bgcolor=#6699FF", (i+1), aData[ GangName ],GetGangOwner( Item ) );
- }
- }
- len += formatex(buffer[len], 2047-len, "</table></body>")
- new info[21]
- formatex(info,20," KnifeGame Top")
- show_motd(client, buffer, info)
- return PLUGIN_HANDLED
- }
- public CmdGang123( client )
- {
- static Menu1;
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gang Menu^nMain Menu", Info[ 3 ]);
- Menu1 = menu_create( szItem, "HandlerGangMenu1" );
- formatex( szItem, charsmax( szItem ), "%sChoose Your Gang Name\d - \wCost Gang\d: \r250,000", (g_iGang[ client ]>-1) ? "\d" : (get_user_cash( client )<GANG_COST) ? "\d" : "\w" );
- menu_additem( Menu1, szItem );
- menu_display( client, Menu1 );
- return 1;
- }
- public HandlerGangMenu1( client, Menu1, Item )
- {
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu1 );
- return 1;
- }
- static iStatus;
- iStatus = getStatus( client, g_iGang[ client ] );
- switch ( Item )
- {
- case 0:
- {
- if ( g_iGang[ client ] > -1 )
- return CmdGang( client );
- else if ( get_user_cash( client ) < GANG_COST )
- return CmdGang123( client );
- client_cmd( client, "messagemode _GangCreate_" );
- }
- case 1:
- {
- if ( g_iGang[ client ] > -1 )
- return CmdGang( client );
- else if ( get_user_cash( client ) < GANG_COST )
- return CmdGang( client );
- }
- case 2:
- {
- if ( g_iGang[ client ] == -1 )
- return CmdGang( client );
- return CmdMembersMenu( client );
- }
- case 3:
- {
- if ( g_iGang[ client ] == -1 )
- return CmdGang( client );
- else if ( iStatus < STATUS_ADMIN )
- return CmdGang( client );
- return CmdAdminMenu( client );
- }
- case 4:
- {
- if ( g_iGang[ client ] == -1 )
- return CmdGang( client );
- else if ( iStatus < STATUS_LEADER )
- return CmdGang( client );
- return CmdOwnerMenu( client );
- }
- case 5:
- return CmdGangsInfo( client );
- }
- menu_destroy( Menu1 );
- return 1;
- }
- public CmdMembersMenu( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- static aData[ GangInfo ], Menu;
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\y Gangs Menu^nMembers Menu^n^n\wGang Name:\y %s^n\wGang Leader\y %s^n\wGang Color:\y %s^n\wGang Cash:\y %i Cash^n\wGang Members:\y %i/%i^n\wYour Rank:\r %s",
- Info[ 3 ], aData[ GangName ], GetGangOwner( g_iGang[ client ] ), g_iGangsColors[ g_iGang[ client] ][ ColorName ], aData[ GangCash ], aData[ NumMembers ], MAX_MEMBERS, getRank( client )
- );
- Menu = menu_create( szItem, "SubMembersMenu" );
- formatex( szItem, charsmax( szItem ), "Online Friends \y[%i]", getOnlineMembers( g_iGang[ client ] ) );
- menu_additem( Menu, szItem );
- menu_additem( Menu, "View Gang Skills" );
- menu_additem( Menu, "Gang Donate" );
- menu_display( client, Menu );
- return 1;
- }
- stock GetGangOwner( iGang )
- {
- static aData[ GangInfo ], szKey1[ 128 ], szKey2[ 128 ], szData[ 128 ], szAuthID[ 35 ], szNameID[ 32 ], iData;
- ArrayGetArray( g_aGangs, iGang, aData );
- for ( new i; i < sqlv_size_ex( g_hVault ); i++ )
- {
- sqlv_read_ex( g_hVault, i, szKey1, charsmax( szKey1 ), szKey2, charsmax( szKey2 ), szData, charsmax( szData ) );
- iData = str_to_num( szData );
- if ( equal( szKey2, aData[ GangName ] ) && iData == 3 )
- {
- replace( szKey1, charsmax( szKey1 ), "@", " " );
- parse( szKey1, szAuthID, charsmax( szAuthID ), szNameID, charsmax( szNameID ) );
- break;
- }
- }
- return szNameID;
- }
- public SubMembersMenu( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return CmdGang( client );
- }
- switch ( Item )
- {
- case 0:
- return CmdOnlineMembers( client );
- case 1:
- return CmdGangSkills( client );
- case 2:
- client_cmd( client, "messagemode _GangDonate_" );
- }
- menu_destroy( Menu );
- return 1;
- }
- public CmdGangSkills( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- static Menu, aData[ GangInfo ], iData;
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\y Gang Menu^nUpgraded Skills^n\wCurrnet Gang:\y %s", Info[ 3 ], aData[ GangName ] );
- Menu = menu_create( szItem, "SubGangSkills" );
- /* Health Regen */
- iData = aData[ GangRegen ];
- if ( iData == charsmax( gHealth ) )
- formatex( szItem, charsmax( szItem ), "Health Regeneration:\y Max \r(\w%i\d seconds\r)", gHealth[ iData ][ skNum ] );
- else
- formatex( szItem, charsmax( szItem ), "Health Regeneration:\y %i \r(\w%i\d seconds\r)", iData, gHealth[ iData ][ skNum ] );
- menu_additem( Menu, szItem );
- /* Get Cash */
- iData = aData[ GangGetCash ];
- if ( iData == charsmax( gGetCash ) )
- formatex( szItem, charsmax( szItem ), "GetCash:\y Max \r(\w%i\d cash\r)", gGetCash[ iData ][ skNum ] );
- else
- formatex( szItem, charsmax( szItem ), "GetCash:\y %i \r(\w%i\d cash\r)", iData, gGetCash[ iData ][ skNum ] );
- menu_additem( Menu, szItem );
- /* Extra Cash */
- iData = aData[ GangBoost ];
- if ( iData == charsmax( gCashBoost ) )
- formatex( szItem, charsmax( szItem ), "Extra Cash:\y Max \r(\w%i\d cash\r)", gCashBoost[ iData ][ skNum ] );
- else
- formatex( szItem, charsmax( szItem ), "Extra Cash:\y %i \r(\w%i\d cash\r)", iData, gCashBoost[ iData ][ skNum ] );
- menu_additem( Menu, szItem );
- /* Next cash */
- iData = aData[ GangNext ];
- if ( iData == charsmax( gNextCash ) )
- formatex( szItem, charsmax( szItem ), "NextCash:\y Max \r(\w%i\d cash\r)^n", gNextCash[ iData ][ skNum ] );
- else
- formatex( szItem, charsmax( szItem ), "NextCash:\y %i \r(\w%i\d cash\r)^n", iData, gNextCash[ iData ][ skNum ] );
- menu_additem( Menu, szItem );
- menu_display( client, Menu );
- return 1;
- }
- public SubGangSkills( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return CmdMembersMenu( client );
- }
- menu_destroy( Menu );
- return CmdGangSkills( client );
- }
- stock getOnlineMembers( Gang )
- {
- static Players[ 32 ], iNum, iPlayer, gNum;
- gNum = 0;
- get_players( Players, iNum, "ch" );
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if ( !is_user_connected( iPlayer ) || Gang != g_iGang[ iPlayer ] )
- continue;
- gNum++;
- }
- return gNum;
- }
- stock getRank( const client )
- {
- static szRank[ 7 ];
- switch ( getStatus( client, g_iGang[ client ] ) )
- {
- case 1:
- szRank = "Member";
- case 2:
- szRank = "Admin";
- case 3:
- szRank = "Leader";
- }
- return szRank;
- }
- /* Invite Menu */
- public CmdShowInvite( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_ADMIN )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- static aData[ GangInfo ];
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- if ( aData[ NumMembers ] >= MAX_MEMBERS )
- return ColorChat( client, "The gang has already reached its^3 Maximum Members^1!" );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gang Menu^nInvite a Player!", Info[ 3 ] );
- new Menu = menu_create( szItem, "SubShowInvite" );
- new Players[ 32 ], iNum, iPlayer, szTempid[ 10 ];
- get_players( Players, iNum );
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if ( iPlayer == client || g_iGang[ iPlayer ] == g_iGang[ client ] )
- continue;
- num_to_str( iPlayer, szTempid, charsmax( szTempid ) );
- menu_additem( Menu, szName( iPlayer ), szTempid );
- }
- menu_display( client, Menu );
- return 1;
- }
- public SubShowInvite( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_ADMIN )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- static aData[ GangInfo ];
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- if ( aData[ NumMembers ] >= MAX_MEMBERS )
- return ColorChat( client, "The gang has already reached its^3 Maximum Members^1!" );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- new Trash, mData[ 6 ];
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _, _, Trash );
- new iPlayer = str_to_num( mData );
- if ( !is_user_connected( iPlayer ) )
- return ColorChat( client, "Player is no longer^3 Connected^1." );
- if ( g_iGang[ iPlayer ] > -1 )
- {
- CmdShowInvite( client );
- return ColorChat( client, "This user is already in a gang." );
- }
- ColorChat( client, "You invited^4 %s^1 to the gang^x03 %s^x01.", szName( iPlayer ), aData[ GangName ] );
- CmdInviteConfirm( client, iPlayer );
- CmdGang( client );
- return 1;
- }
- public CmdInviteConfirm( client, iPlayer )
- {
- if ( g_iGang[ iPlayer ] > -1 )
- return ColorChat( client, "This player is already in a gang." );
- new aData[ GangInfo ], szTempid[ 10 ];
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gang Menu^n\r%s\w Invited you to\y %s\w gang.", Info[ 3 ], szName( client ), aData[ GangName ] );
- new Menu = menu_create( szItem, "SubInviteConfirm" );
- num_to_str( g_iGang[ client ], szTempid, charsmax( szTempid ) );
- menu_additem( Menu, "Confirm", szTempid );
- menu_additem( Menu, "Decline", szTempid );
- menu_display( iPlayer, Menu );
- return 1;
- }
- public SubInviteConfirm( iPlayer, Menu, Item )
- {
- if ( g_iGang[ iPlayer ] > -1 )
- return ColorChat( iPlayer, "You're already in a gang." );
- if ( Item == MENU_EXIT || Item == 1 )
- {
- menu_destroy( Menu );
- ColorChat( iPlayer, "You^3 declined^1 the invitation." );
- return 1
- }
- new mData[ 6 ], Trash;
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _,_, Trash );
- new iGang = str_to_num( mData );
- if ( iGang == -1 )
- return 1;
- if ( g_iGang[ iPlayer ] > -1 )
- return ColorChat( iPlayer, "You're already in a gang." );
- set_user_gang( iPlayer, iGang );
- new aData[ GangInfo ];
- ArrayGetArray( g_aGangs, iGang, aData );
- if ( aData[ NumMembers ] >= MAX_MEMBERS )
- return ColorChat( iPlayer, "This gang has already reached its^3 Max Members^1!" );
- new Players[ 32 ], iNum, iTemp;
- get_players( Players, iNum );
- for ( new i; i < iNum; i++ )
- {
- iTemp = Players[ i ];
- if ( g_iGang[ iTemp ] != g_iGang[ iPlayer ] || iPlayer == iTemp )
- continue;
- ColorChat( iTemp, "^x03%s^x01 joined your gang!", szName( iPlayer ) );
- ArrayGetArray( g_aGangs, g_iGang[ iPlayer ], aData );
- }
- return ColorChat( iPlayer, "You joined the gang^x03 %s^x01.", aData[ GangName ] );
- }
- /* Leave Menu */
- public CmdLeaveConfirm( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- static aData[ GangInfo ];
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gang Menu^nAre you sure you want to leave the\y %s\w gang?", Info[ 3 ], aData[ GangName ] );
- new Menu = menu_create( szItem, "SubLeaveConfirm" );
- menu_additem( Menu, "Yes" );
- menu_additem( Menu, "No, Don't Leave" );
- menu_display( client, Menu );
- return 1;
- }
- public SubLeaveConfirm( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- switch ( Item )
- {
- case 0:
- {
- if ( getStatus( client, g_iGang[ client ] ) == STATUS_LEADER )
- return ColorChat( client, "You need to transfer the leadership first." );
- static Players[ 32 ], iNum, iPlayer, aData[ GangInfo ], szKey[ 128 ], szKey1[ 128 ];
- static szKey2[ 128 ], szData[ 128 ], szAuthID[ 35 ], szNameID[ 32 ];
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- for ( new i; i < sqlv_size_ex( g_hVault ); i++ )
- {
- sqlv_read_ex( g_hVault, i, szKey1, charsmax( szKey1 ), szKey2, charsmax( szKey2 ), szData, charsmax( szData ) );
- formatex( szKey, charsmax( szKey ), szKey1 );
- replace( szKey, charsmax( szKey ), "@", " " );
- parse( szKey, szAuthID, charsmax( szAuthID ), szNameID, charsmax( szNameID ) );
- if ( !( equal( szAuth( client ), szAuthID ) ) )
- continue;
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- TrieDeleteKey( aData[ GangMembers ], szKey1 );
- aData[ NumMembers ]--;
- ArraySetArray( g_aGangs, g_iGang[ client ], aData );
- sqlv_remove_ex( g_hVault, szKey1, szKey2 );
- get_players( Players, iNum );
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if( iPlayer == client || g_iGang[ iPlayer ] != g_iGang[ client ] )
- continue;
- ColorChat( 0, "^4%s^1 left the gang^3 %s^1.", szName( client ), aData[ GangName ] );
- }
- g_iGang[ client ] = -1;
- ColorChat( client, "You left the gang." );
- }
- }
- }
- menu_destroy( Menu );
- CmdGang( client );
- return 1;
- }
- /* Online Memebers */
- public CmdOnlineMembers( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Online Members", Info[ 3 ] );
- new Menu = menu_create( szItem, "SubOnlineMembers" );
- new Players[ 32 ], iNum, iPlayer;
- get_players( Players, iNum );
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if ( g_iGang[ client ] != g_iGang[ iPlayer ] )
- continue;
- formatex( szItem, charsmax( szItem ), "%s - \d[\r%s\d]", szName( iPlayer ), getRank( iPlayer ) );
- menu_additem( Menu, szItem );
- }
- menu_display( client, Menu );
- return 1;
- }
- public SubOnlineMembers( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return CmdMembersMenu( client );
- }
- menu_destroy( Menu );
- CmdOnlineMembers( client );
- return 1;
- }
- /* Disband Menu */
- public CmdDisbandConfirm( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_LEADER )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gang Menu^nAre you sure you want to\r Disband\w the gang?", Info[ 3 ] );
- new Menu = menu_create( szItem, "SubDisbandConfirm" );
- menu_additem( Menu, "Confirm" );
- menu_additem( Menu, "Decline" );
- menu_display( client, Menu );
- return 1;
- }
- public SubDisbandConfirm( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_LEADER )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- switch ( Item )
- {
- case 0:
- {
- new aData[ GangInfo ], Players[ 32 ], iNum, iPlayer, iGang;
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- ColorChat( 0, "^4%s^1 disabanded the gang:^3 %s^1!", szName( client ), aData[ GangName ] );
- get_players( Players, iNum );
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if ( iPlayer == client || g_iGang[ client ] != g_iGang[ iPlayer ] )
- continue;
- ColorChat( iPlayer, "Your gang was disbanded by^4 %s", szName( client ) );
- set_user_gang( iPlayer, -1 );
- }
- static szKey[ 2 ][ 128 ], szData[ 32 ];
- for ( new j; j < sqlv_size_ex( g_hVault ); j++ )
- {
- sqlv_read_ex( g_hVault, j, szKey[ 0 ], charsmax( szKey[] ), szKey[ 1 ], charsmax( szKey[] ), szData, charsmax( szData ) );
- if ( !( equal( szKey[ 1 ], aData[ GangName ] ) ) )
- continue;
- }
- iGang = g_iGang[ client ];
- set_user_gang( client, -1 );
- ArrayDeleteItem( g_aGangs, iGang );
- }
- }
- menu_destroy( Menu );
- CmdGang( client );
- return 1;
- }
- /* Transfer Menu */
- public CmdTransferMenu( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_LEADER )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gang Menu^nTransfer Leadership to", Info[ 3 ] );
- new Menu = menu_create( szItem, "SubTransferMenu" );
- new Players[ 32 ], iNum, iPlayer, szTempid[ 10 ];
- get_players( Players, iNum );
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if ( g_iGang[ iPlayer ] != g_iGang[ client ] || client == iPlayer )
- continue;
- num_to_str( iPlayer, szTempid, charsmax( szTempid ) );
- menu_additem( Menu, szName( iPlayer ), szTempid );
- }
- menu_display( client, Menu );
- return 1;
- }
- public SubTransferMenu( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_LEADER )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- new Trash, mData[ 6 ], aData[ GangInfo ];
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _,_, Trash );
- new iPlayer = str_to_num( mData );
- if ( !is_user_connected( iPlayer ) )
- {
- CmdTransferMenu( client );
- return ColorChat( client, "Player is no longer^3 Connected^1." );
- }
- set_user_gang( iPlayer, g_iGang[ client ], STATUS_LEADER );
- set_user_gang( client, g_iGang[ client ], STATUS_ADMIN );
- CmdGang( client );
- new Players[ 32 ], iNum, iTemp;
- get_players( Players, iNum );
- for ( new i; i < iNum; i++ )
- {
- iTemp = Players[ i ];
- if ( iTemp == iPlayer )
- {
- ColorChat( iTemp, "You are the new leader of the gang." );
- continue;
- }
- else if ( g_iGang[ iTemp ] != g_iGang[ client ] )
- continue;
- ColorChat( iTemp, "^x04%s^x01 is the new leader of the^x03 %s^x01 gang.", szName( iPlayer ), aData[ GangName ] );
- }
- return 1;
- }
- /* Add Admin */
- stock get_gang_admins( const index )
- {
- static aData[ GangInfo ], iNum, szKey[ 2 ][ 128 ], szData[ 32 ];
- iNum = 0;
- ArrayGetArray( g_aGangs, g_iGang[ index ], aData );
- for ( new i; i < sqlv_size_ex( g_hVault ); i++ )
- {
- sqlv_read_ex( g_hVault, i, szKey[ 0 ], charsmax( szKey[] ), szKey[ 1 ], charsmax( szKey[] ), szData, charsmax( szData ) );
- if ( !( equali( aData[ GangName ], szKey[ 1 ] ) ) )
- continue;
- if ( equali( szData, "2" ) )
- iNum++;
- }
- return iNum;
- }
- public CmdAddAdmin( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_LEADER )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- if ( get_gang_admins( client ) >= MAX_ADMINS )
- return ColorChat( client, "The gang has reached it's maximum^4 Admin Members^1." );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gang Menu^nPromote a Player", Info[ 3 ] );
- new Menu = menu_create( szItem, "SubAddAdmin" );
- new Players[ 32 ], iNum, iPlayer, szTempid[ 10 ];
- get_players( Players, iNum );
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if ( g_iGang[ client ] != g_iGang[ iPlayer ] || getStatus( iPlayer, g_iGang[ iPlayer ] ) > STATUS_MEMBER )
- continue;
- num_to_str( iPlayer, szTempid, charsmax( szTempid ) );
- menu_additem( Menu, szName( iPlayer ), szTempid );
- }
- menu_display( client, Menu );
- return 1;
- }
- public SubAddAdmin( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_LEADER )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- if ( get_gang_admins( client ) >= MAX_ADMINS )
- return ColorChat( client, "The gang has reached it's maximum^4 Admin Members^1." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- new Trash, mData[ 6 ];
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _,_, Trash )
- new iPlayer = str_to_num( mData );
- if ( !is_user_connected( iPlayer ) )
- {
- ColorChat( client, "Player is no longer^3 Connected^1." );
- CmdAddAdmin( client );
- return 1;
- }
- set_user_gang( iPlayer, g_iGang[ client ], STATUS_ADMIN );
- new Players[ 32 ], iNum, iTemp;
- get_players( Players, iNum );
- for ( new i; i < iNum; i++ )
- {
- iTemp = Players[ i ];
- if ( g_iGang[ iTemp ] != g_iGang[ client ] || iPlayer == iTemp )
- continue;
- ColorChat( iTemp, "^3%s^1 has been^4 promoted^1 to^3 Admin^1 of the gang.", szName( iPlayer ) );
- }
- ColorChat( iPlayer, "You have been^4 promoted^1 to^3 Admin^1 of the gang." );
- ColorChat( client, "You promoted^4 %s^1 to^3 Admin^1 of the gang.", szName( iPlayer ) );
- menu_destroy( Menu );
- return 1;
- }
- /* Remove Admin */
- public CmdRemoveAdmin( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_LEADER )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gang Menu^nDemote a Player", Info[ 3 ] );
- new Menu = menu_create( szItem, "SubRemoveAdmin" );
- new Players[ 32 ], iNum, iPlayer, szTempid[ 10 ];
- get_players( Players, iNum );
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if ( g_iGang[ client ] != g_iGang[ iPlayer ] || getStatus( iPlayer, g_iGang[ iPlayer ] ) != STATUS_ADMIN )
- continue;
- num_to_str( iPlayer, szTempid, charsmax( szTempid ) );
- menu_additem( Menu, szName( iPlayer ), szTempid );
- }
- menu_display( client, Menu );
- return 1;
- }
- public SubRemoveAdmin( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_LEADER )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- new Trash, mData[ 6 ];
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _,_, Trash );
- new iPlayer = str_to_num( mData );
- if ( !is_user_connected( iPlayer ) )
- {
- CmdRemoveAdmin( client );
- return ColorChat( client, "Player is no longer^3 Connected^1." );
- }
- set_user_gang( iPlayer, g_iGang[ client ], STATUS_MEMBER );
- new Players[ 32 ], iNum, iTemp;
- get_players( Players, iNum );
- for ( new i; i < iNum; i++ )
- {
- iTemp = Players[ i ];
- if ( g_iGang[ iTemp ] != g_iGang[ client ] || iPlayer == iTemp )
- continue;
- ColorChat( iTemp, "^3%s^1 has been^4 demoted^1 from being^3 Admin^1 of the gang.", szName( iPlayer ) );
- }
- ColorChat( iPlayer, "You've been^4 demoted^1 from being^3 Admin^1 of the gang." );
- ColorChat( client, "You^4 demoted^3 %s^1 from being^4 Admin^1 of the gang.", szName( iPlayer ) );
- CmdGang( client );
- return 1;
- }
- /* Admin Menu */
- public CmdAdminMenu( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_ADMIN )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gang Main Menu^nAdmin Menu.", Info[ 3 ] );
- new Menu = menu_create( szItem, "SubAdminMenu" );
- menu_additem( Menu, "Kick from the Gang" );
- menu_additem( Menu, "Invite to the Gang" );
- menu_additem( Menu, "Upgrade Skills" );
- menu_display( client, Menu );
- return 1;
- }
- public SubAdminMenu( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_ADMIN )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- switch ( Item )
- {
- case 0: return CmdKickMenu( client );
- case 1: return CmdShowInvite( client );
- case 2: return CmdSkillsMenu( client );
- }
- menu_destroy( Menu );
- return 1;
- }
- /* Owner Menu */
- public CmdOwnerMenu( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_LEADER )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Leaders Menu", Info[ 3 ] );
- new Menu = menu_create( szItem, "SubOwnerMneu" );
- menu_additem( Menu, "Kick from the Gang" );
- menu_additem( Menu, "Invite to the Gang" );
- menu_additem( Menu, "Upgrade Skills" );
- menu_additem( Menu, "Add an Admin" );
- menu_additem( Menu, "Remove an Admin" );
- menu_additem( Menu, "Transfer Leadership" );
- menu_additem( Menu, "Disband Gang" );
- //menu_additem( Menu, "Change Gang Name" );
- menu_display( client, Menu );
- return 1;
- }
- public SubOwnerMneu( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_ADMIN )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- switch ( Item )
- {
- case 0: return CmdKickMenu( client );
- case 1: return CmdShowInvite( client );
- case 2: return CmdSkillsMenu( client );
- case 3: return CmdAddAdmin( client );
- case 4: return CmdRemoveAdmin( client );
- case 5: return CmdTransferMenu( client );
- case 6: return CmdDisbandConfirm( client );
- }
- menu_destroy( Menu );
- return 1;
- }
- /* Skills Menu */
- public CmdSkillsMenu( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_ADMIN )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- static aData[ GangInfo ], iData;
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Skills Menu^n\dCurrent Gang:\y %s^n\dGang Cash:\y %i\w Cash.",
- Info[ 3 ], aData[ GangName ], aData[ GangCash ] );
- new Menu = menu_create( szItem, "SubSkillsMenu" );
- /* Health Regen */
- iData = aData[ GangRegen ];
- if ( iData == charsmax( gHealth ) )
- formatex( szItem, charsmax( szItem ), "Health Regeneration:\y %i\d Seconds \r(\wMax\r)", gHealth[ iData ][ skNum ] );
- else if ( iData == 0 )
- formatex( szItem, charsmax( szItem ), "Health Regeneration:\d Upgdrade for\y %i\w Cash", gHealth[ iData ][ skCost ] );
- else
- formatex( szItem, charsmax( szItem ), "Health Regeneration:\y %i\d Seconds \r(\w%i\r)\d Upgrade for\y %i\w Cash", gHealth[ iData ][ skNum ], iData, gHealth[ iData ][ skCost ] );
- menu_additem( Menu, szItem );
- /* Get Cash */
- iData = aData[ GangGetCash ];
- if ( iData == charsmax( gGetCash ) )
- formatex( szItem, charsmax( szItem ), "Get Cash:\y %i\d Cash \r(\wMax\r)", gGetCash[ iData ][ skNum ] );
- else if ( iData == 0 )
- formatex( szItem, charsmax( szItem ), "Get Cash:\d Upgdrade for\y %i\w Cash", gGetCash[ iData ][ skCost ] );
- else
- formatex( szItem, charsmax( szItem ), "Get Cash:\y %i\d Cash \r(\w%i\r)\d Upgrade for\y %i\w Cash", gGetCash[ iData ][ skNum ], iData, gGetCash[ iData ][ skCost ] );
- menu_additem( Menu, szItem );
- /* Cash Booster */
- iData = aData[ GangBoost ];
- if ( iData == charsmax( gCashBoost ) )
- formatex( szItem, charsmax( szItem ), "ExtraCash:\y %i\d Cash \r(\wMax\r)", gCashBoost[ iData ][ skNum ] );
- else if ( iData == 0 )
- formatex( szItem, charsmax( szItem ), "ExtraCash:\d Upgdrade for\y %i\w Cash", gCashBoost[ iData ][ skCost ] );
- else
- formatex( szItem, charsmax( szItem ), "ExtraCash:\y %i\d Cash \r(\w%i\r)\d Upgrade for\y %i\w Cash", gCashBoost[ iData ][ skNum ], iData, gCashBoost[ iData ][ skCost ] );
- menu_additem( Menu, szItem );
- /* Next Cash */
- iData = aData[ GangNext ];
- if ( iData == charsmax( gNextCash ) )
- formatex( szItem, charsmax( szItem ), "NextCash:\y %i\d Cash \r(\wMax\r)", gNextCash[ iData ][ skNum ] );
- else if ( iData == 0 )
- formatex( szItem, charsmax( szItem ), "NextCash:\d Upgdrade for\y %i\w Cash", gNextCash[ iData ][ skCost ] );
- else
- formatex( szItem, charsmax( szItem ), "NextCash:\y %i\d Cash \r(\w%i\r)\d Upgrade for\y %i\w Cash", gNextCash[ iData ][ skNum ], iData, gNextCash[ iData ][ skCost ] );
- menu_additem( Menu, szItem );
- menu_display( client, Menu );
- return 1;
- }
- public SubSkillsMenu( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_ADMIN )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- static aData[ GangInfo ]//, Cost, Skill, Max;
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- if ( aData[ szSkills[ Item ][ baseEnum ] ] == szSkills[ Item ][ baseCharMax ] )
- return ColorChat( client, "This skill is already^4 Maxed Out^1." );
- static Cost;
- switch ( Item )
- {
- case 0:
- {
- Cost = gHealth[ aData[ GangRegen ] ][ skCost ];
- if ( aData[ GangCash ] < Cost )
- return ColorChat( client, "The gang doesn't have enough cash." );
- }
- case 1:
- {
- Cost = gGetCash[ aData[ GangGetCash ] ][ skCost ];
- if ( aData[ GangCash ] < Cost )
- return ColorChat( client, "The gang doesn't have enough cash." );
- }
- case 2:
- {
- Cost = gCashBoost[ aData[ GangBoost ] ][ skCost ];
- if ( aData[ GangCash ] < Cost )
- return ColorChat( client, "The gang doesn't have enough cash." );
- }
- case 3:
- {
- Cost = gNextCash[ aData[ GangNext ] ][ skCost ];
- if ( aData[ GangCash ] < Cost )
- return ColorChat( client, "The gang doesn't have enough cash." );
- }
- }
- aData[ szSkills[ Item ][ baseEnum ] ]++;
- aData[ GangCash ] -= Cost;
- ArraySetArray( g_aGangs, g_iGang[ client ], aData )
- new Players[ 32 ], iNum, iTemp;
- get_players( Players, iNum, "ch" );
- for ( new i; i < iNum; i++ )
- {
- iTemp = Players[ i ];
- if ( g_iGang[ iTemp ] != g_iGang[ client ] || client == iTemp )
- continue;
- ColorChat( iTemp, "^3%s^4 upgraded^1 the skill^3 %s^1 to level^3 %i^1!", szName( client ), szSkills[ Item ][ baseName ], aData[ szSkills[ Item ][ baseEnum ] ] );
- }
- ColorChat( client, "You^3 upgraded^1 the skill^4 %s^1 to level^3 %i^1!", szSkills[ Item ][ baseName ], aData[ szSkills[ Item ][ baseEnum ] ] );
- CmdSkillsMenu( client );
- return 1;
- }
- /* Gangs Info */
- public CmdGangsInfo( client )
- {
- static aData[ GangInfo ];
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gangs Information", Info[ 3 ] );
- new Menu = menu_create( szItem, "SubGangsInfo" );
- for ( new i; i < ArraySize( g_aGangs ); i++ )
- {
- ArrayGetArray( g_aGangs, i, aData );
- formatex( szItem, charsmax( szItem ), "%s%s", aData[ GangName ], (i==g_iGang[ client ]) ? "\r *\d Your Gang \r*" : "" );
- menu_additem( Menu, szItem );
- }
- menu_setprop( Menu, MPROP_EXITNAME, "Back" );
- menu_display( client, Menu );
- return 1;
- }
- public SubGangsInfo( client, Menu, Item )
- {
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return CmdGang( client );
- }
- CmdSubInfo( client, Item );
- return 1;
- }
- public CmdSubInfo( client, Item )
- {
- static aData[ GangInfo ], mItem[ 6 ], iData;
- num_to_str( Item, mItem, charsmax( mItem ) );
- ArrayGetArray( g_aGangs, Item, aData );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Gang Information^n^n\r%s\w Info:", Info[ 3 ], aData[ GangName ] );
- new Menu = menu_create( szItem, "SubSubInfo" );
- /*---- Gang Info ----*/
- formatex( szItem, charsmax( szItem ), "Gang Leader:\d %s", GetGangOwner( Item ) );
- menu_additem( Menu, szItem, mItem );
- formatex( szItem, charsmax( szItem ), "Gang Color:\d %s", g_iGangsColors[ Item ][ ColorName ] );
- menu_additem( Menu, szItem, mItem );
- formatex( szItem, charsmax( szItem ), "Gang Members:\d %i/%i", aData[ NumMembers ], MAX_MEMBERS );
- menu_additem( Menu, szItem, mItem );
- formatex( szItem, charsmax( szItem ), "Gang Cash:\d %i Cash^n^n\wGang\y Skills\w Info:^n", aData[ GangCash ] );
- menu_additem( Menu, szItem, mItem );
- /*---- Gang Skill Info ----*/
- /* Health Regen */
- iData = aData[ GangRegen ];
- if ( aData[ GangRegen ] == charsmax( gHealth ) )
- formatex( szItem, charsmax( szItem ), "Health Regeneration:\y Max \r(\w%i\d seconds\r)", gHealth[ iData ][ skNum ] );
- else
- formatex( szItem, charsmax( szItem ), "Health Regeneration:\y %i \r(\w%i\d seconds\r)", iData, gHealth[ iData ][ skNum ] );
- menu_additem( Menu, szItem, mItem );
- /* Extra Cash */
- iData = aData[ GangBoost ];
- if ( iData == charsmax( gCashBoost ) )
- formatex( szItem, charsmax( szItem ), "ExtraCash:\y Max \r(\w%i\d cash\r)", iData, gCashBoost[ iData ][ skNum ] );
- else
- formatex( szItem, charsmax( szItem ), "ExtraCash:\y %i \r(\w%i\d cash\r)", iData, gCashBoost[ iData ][ skNum ] );
- menu_additem( Menu, szItem, mItem );
- /* Get Cash */
- iData = aData[ GangGetCash ];
- if ( iData == charsmax( gGetCash ) )
- formatex( szItem, charsmax( szItem ), "Get Cash:\y Max \r(\w%i\d cash\r)", iData, gGetCash[ iData ][ skNum ] );
- else
- formatex( szItem, charsmax( szItem ), "Get Cash:\y %i \r(\w%i\d cash\r)", iData, gGetCash[ iData ][ skNum ] );
- menu_additem( Menu, szItem, mItem );
- /* Next Cash */
- iData = aData[ GangNext ];
- if ( iData == charsmax( gNextCash ) )
- formatex( szItem, charsmax( szItem ), "NextCash:\y Max \r(\w%i\d cash\r)^n", gNextCash[ iData ][ skNum ] );
- else
- formatex( szItem, charsmax( szItem ), "NextCash:\y %i \r(\w%i\d cash\r)^n", iData, gNextCash[ iData ][ skNum ] );
- menu_additem( Menu, szItem, mItem );
- /*---- Server Owner Item ----*/
- if ( get_user_flags( client ) & ADMIN_ACCESS )
- {
- menu_additem( Menu, "\rRemove This Gang.^n", mItem );
- menu_additem( Menu, "Back" );
- menu_setprop( Menu, MPROP_PERPAGE, 0 );
- }
- else menu_setprop( Menu, MPROP_EXITNAME, "Back" );
- menu_display( client, Menu );
- return 1;
- }
- public SubSubInfo( client, Menu, Item )
- {
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return CmdGangsInfo( client );
- }
- static mData[ 6 ], Trash, Key;
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _, _, Trash );
- Key = str_to_num( mData );
- if ( get_user_flags( client ) & ADMIN_ACCESS )
- {
- if ( Item == 8 )
- return CmdConfirmDelete( client, Key );
- if ( Item == 9 )
- {
- menu_destroy( Menu );
- return CmdGangsInfo( client );
- }
- }
- CmdSubInfo( client, Key );
- return 1;
- }
- /* Owners Manage Disband Gangs */
- public CmdConfirmDelete( client, iGang )
- {
- if ( !( get_user_flags( client ) & ADMIN_ACCESS ) )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- static aData[ GangInfo ];
- ArrayGetArray( g_aGangs, iGang, aData );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Are you sure you want to\r delete\w the gang\y %s?", Info[ 3 ], aData[ GangName ] );
- new Menu = menu_create( szItem, "SubConfirmDelete" );
- static szGang[ 6 ];
- num_to_str( iGang, szGang, charsmax( szGang ) );
- menu_additem( Menu, "\rYes\w, Delete this gang.", szGang );
- menu_additem( Menu, "No, \yLeave this gang alone.", szGang );
- menu_display( client, Menu );
- return 1;
- }
- public SubConfirmDelete( client, Menu, Item )
- {
- if ( !( get_user_flags( client ) & ADMIN_ACCESS ) )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- if ( Item == MENU_EXIT || Item == 1 )
- {
- menu_destroy( Menu );
- return CmdGangsInfo( client );
- }
- static mData[ 6 ], Trash, iGang, aData[ GangInfo ], Players[ 32 ], iNum, iPlayer
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _,_, Trash );
- iGang = str_to_num( mData );
- ArrayGetArray( g_aGangs, iGang, aData );
- ColorChat( 0, "ADMIN:^3 %s^1 deleted^1 the gang^4 %s^1!", szName( client ), aData[ GangName ] );
- get_players( Players, iNum, "ch" );
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if ( g_iGang[ iPlayer ] != iGang )
- continue;
- set_user_gang( iPlayer, -1 );
- }
- ArrayDeleteItem( g_aGangs, iGang );
- menu_destroy( Menu );
- return CmdGangsInfo( client );
- }
- /* Kick Menu */
- public CmdMenu( client )
- {
- static aData[ GangInfo ];
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- new szKey1[ 254 ], szKey2[ 256 ], szData[ 512];
- for ( new i; i < sqlv_size_ex( g_hVault ); i++ )
- {
- sqlv_read_ex( g_hVault, i, szKey1, 255, szKey2, 255, szData, 511 );
- if ( !( equali( szKey2, aData[ GangName ] ) ) )
- continue;
- ColorChat( client, "^3%s:^4 %s", szKey2, szKey1 );
- }
- }
- public CmdKickMenu( client )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_ADMIN )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- formatex( szItem, charsmax( szItem ), "\r[\w%s\r]\w Kick Menu", Info[ 3 ] );
- new Menu = menu_create( szItem, "SubKickMenu" );
- static aData[ GangInfo ], szKey1[ 254 ], szKey2[ 256 ], szData[ 512 ], szAuthID[ 35 ], szNameID[ 32 ], KeyIndex[ 6 ], Status;
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- for ( new i; i < sqlv_size_ex( g_hVault ); i++ )
- {
- sqlv_read_ex( g_hVault, i, szKey1, charsmax( szKey1 ), szKey2, charsmax( szKey2 ), szData, charsmax( szData ) );
- if ( equali( szKey2, aData[ GangName ] ) )
- {
- Status = str_to_num( szData );
- if ( Status > getStatus( client, g_iGang[ client ] ) )
- continue;
- replace( szKey1, charsmax( szKey1 ), "@", " " );
- parse( szKey1, szAuthID, charsmax( szAuthID ), szNameID, charsmax( szNameID ) );
- if ( is_auth_online( szAuthID ) )
- formatex( szItem, charsmax( szItem ), "\yONLINE\w - %s (%s)", szNameID, szAuthID );
- else formatex( szItem, charsmax( szItem ), "\rOFFLINE\d - %s (%s)", szNameID, szAuthID );
- num_to_str( i, KeyIndex, charsmax( KeyIndex ) );
- menu_additem( Menu, szItem, KeyIndex );
- }
- }
- menu_display( client, Menu );
- return 1;
- }
- public SubKickMenu( client, Menu, Item )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( getStatus( client, g_iGang[ client ] ) < STATUS_ADMIN )
- return ColorChat( client, "You have no^x04 access^x01 to this command." );
- if ( Item == MENU_EXIT )
- {
- menu_destroy( Menu );
- return 1;
- }
- static mData[ 6 ], Trash, KeyIndex, aData[ GangInfo ], szKey1[ 254 ];
- static szKey2[ 256 ], szData[ 512 ], szAuthID[ 35 ], szNameID[ 32 ], gStatus, iStatus;
- iStatus = getStatus( client, g_iGang[ client ] );
- menu_item_getinfo( Menu, Item, Trash, mData, charsmax( mData ), _,_, Trash );
- KeyIndex = str_to_num( mData );
- sqlv_read_ex( g_hVault, KeyIndex, szKey1, charsmax( szKey1 ), szKey2, charsmax( szKey2 ), szData, charsmax( szData ) );
- gStatus = str_to_num( szData );
- if ( iStatus == STATUS_ADMIN && gStatus != STATUS_MEMBER || iStatus == STATUS_LEADER && gStatus > STATUS_ADMIN )
- return ColorChat( client, "You canno't kick %s^1!", (gStatus==STATUS_ADMIN) ? "an^4 Admin" : "a^4 Leader" );
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- TrieDeleteKey( aData[ GangMembers ], szKey1 );
- aData[ NumMembers ]--;
- ArraySetArray( g_aGangs, g_iGang[ client ], aData );
- sqlv_remove_ex( g_hVault, szKey1, szKey2 );
- replace( szKey1, charsmax( szKey1 ), "@", " " );
- parse( szKey1, szAuthID, charsmax( szAuthID ), szNameID, charsmax( szNameID ) );
- new Players[ 32 ], iNum, iPlayer;
- get_players( Players, iNum, "ch" );
- if ( is_auth_online( szAuthID ) )
- {
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if ( equali( szAuthID, szAuth( iPlayer ) ) )
- g_iGang[ iPlayer ] = -1;
- }
- }
- for( new i; i < iNum; i++ )
- {
- new client = read_data( 1 );
- new iPlayer = read_data( 2 );
- iPlayer = Players[ i ];
- if( /*iPlayer == client ||*/ g_iGang[ iPlayer ] != g_iGang[ client ] )
- continue;
- set_user_gang( g_iGang[ iPlayer ], -1, STATUS_NONE );
- }
- ColorChat( 0, "^x04%s^x01 kicked^x03 %s^x01 from gang.", szName( client ), szNameID );
- return CmdGang( client );
- }
- /* Events */
- public evRoundStart()
- {
- static aData[ GangInfo ];
- for ( new client = 1; client < get_maxplayers(); client++ )
- {
- if ( !is_user_connected( client ) || g_iGang[ client ] == -1 )
- continue;
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- if ( aData[ GangGetCash ] == 0 )
- continue;
- set_hudmessage( 0, 70, 255, -1.0, 0.0, 0, 0.1, 12.0, 0.1, 0.1, -1 );
- if( gGetCash[ aData[ GangGetCash ] ][ skNum ] >= sizeof( gGetCash ) && is_user_admin( client ) )
- show_hudmessage( client, "Type /getcash to get %i Cash!", gGetCash[ aData[ GangGetCash ] ][ skNum ] * 2 );
- else
- show_hudmessage( client, "Type /getcash to get %i Cash!", gGetCash[ aData[ GangGetCash ] ][ skNum ] );
- bGetCash[ client ] = false;
- }
- }
- public evDeathMsg()
- {
- static Attacker, Victim, aData[ GangInfo ], Bonus;
- Attacker = read_data( 1 );
- Victim = read_data( 2 );
- if ( !is_user_connected( Attacker ) )
- return 0;
- if ( cs_get_user_team( Attacker ) != CS_TEAM_T || cs_get_user_team( Victim ) != CS_TEAM_CT || Attacker == Victim || g_iGang[ Attacker ] == -1 )
- return 0;
- ArrayGetArray( g_aGangs, g_iGang[ Attacker ], aData );
- if ( aData[ GangBoost ] == 0 )
- return 0;
- Bonus = gCashBoost[ aData[ GangBoost ] ][ skNum ];
- if ( CountPlayers() < 5 )
- return 1;
- set_user_cash( Attacker, get_user_cash( Attacker ) + Bonus );
- ColorChat( Attacker, "You gained^4 %i^3 bonus cash^1!", Bonus );
- return 0;
- }
- /* Forwards */
- public FwdPreThink( client )
- {
- if ( !is_user_alive( client ) || !is_user_connected( client ) || g_iGang[ client ] == -1 )
- return 1;
- static aData[ GangInfo ];
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- if ( aData[ GangRegen ] == 0 )
- return 1;
- if ( is_lr_active() )
- return 1;
- if ( fRegen[ client ] + gHealth[ aData[ GangRegen ] ][ skNum ] < get_gametime() )
- {
- if ( get_user_health( client ) >= 100 )
- {
- fRegen[ client ] = get_gametime();
- return 1;
- }
- else if ( get_user_health( client ) + 20 > 100 )
- fm_set_user_health( client, 100 );
- else
- fm_set_user_health( client, get_user_health( client ) + 20 );
- fRegen[ client ] = get_gametime();
- }
- return 1;
- }
- /* Chat */
- public CmdSay( client )
- {
- static szMsg[ 512 ];
- read_args( szMsg, charsmax( szMsg ) );
- remove_quotes( szMsg );
- static aData[ GangInfo ], Amount;
- if ( g_iGang[ client ] > -1 )
- ArrayGetArray( g_aGangs, g_iGang[ client ], aData );
- if ( equali( szMsg, "/getcash" ) || equali( szMsg, "/gc" ) )
- {
- if ( g_iGang[ client ] == -1 )
- return ColorChat( client, "You need to be in a gang." );
- if ( aData[ GangGetCash ] == 0 )
- return ColorChat( client, "That skill is not yet upgraded in your gang." );
- if ( bGetCash[ client ] )
- return ColorChat( client, "You can only use^4 Get cash^1 on time^3 per round^1!" );
- if ( CountPlayers() < 5 )
- return ColorChat( client, "You can't use^3 get cash^1 if there are less than^4 5 players^1." );
- static iData;
- iData = aData[ GangGetCash ];
- bGetCash[ client ] = true;
- Amount = gGetCash[ iData ][ skNum ];
- Amount += Amount;
- set_user_cash( client, get_user_cash( client ) + Amount );
- return ColorChat( client, "You received^4 %i cash^1,^3 good luck^1!", Amount );
- }
- if ( g_iGang[ client ] == -1 )
- return 0;
- if ( szMsg[ 0 ] != '~' )
- return 0;
- replace( szMsg, charsmax( szMsg ), "~", "" );
- static Players[ 32 ], iNum, iPlayer, szStatus[ 32 ];
- get_players( Players, iNum );
- formatex( szStatus, charsmax( szStatus ), "%s",
- (getStatus( client, g_iGang[ client ] ) == STATUS_LEADER) ? "Leader" : (getStatus( client, g_iGang[ client ] ) == STATUS_ADMIN) ? "Admin" : "Member" );
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if ( g_iGang[ iPlayer ] != g_iGang[ client ] )
- continue;
- if(getStatus( client, g_iGang[ client ] ) == STATUS_LEADER)
- {
- set_hudmessage(255, 255, 255, -1.0, 0.73, 0, 6.0, 12.0)
- show_hudmessage(iPlayer, "Leader %s : %s",szName( client ), szMsg)
- ColorChat( iPlayer, "^1%sGang Name:^3 %s^4 |^1 Leader^4 |^3 %s^1 :^1 %s", is_user_alive( client ) ? " " : "DEAD", aData[ GangName ], szName( client ), szMsg );
- }
- else
- ColorChat( iPlayer, "^1%sGang Name:^3 %s^4 |^1 %s^4 |^3 %s^1 :^1 %s", is_user_alive( client ) ? " " : " DEAD ^3|^1 ", aData[ GangName ], szStatus, szName( client ), szMsg );
- }
- return 1;
- }
- stock CountPlayers()
- {
- static Players[ 32 ], iNum;
- get_players( Players, iNum, "ch" );
- return iNum;
- }
- /* Gang Glow */
- public _set_glow( plugin, params )
- {
- bGlow = true;
- GangGlow();
- set_task( 20.0, "GangGlow", TASKID_GLOW, _,_, "b" );
- }
- public _remove_glow( plugin, params )
- {
- remove_task( TASKID_GLOW );
- bGlow = false;
- for ( new client = 1; client < get_maxplayers(); client++ )
- {
- if ( !is_user_connected( client ) || !is_user_alive( client ) )
- continue;
- fm_set_user_rendering( client );
- }
- }
- public GangGlow()
- {
- if ( !bGlow )
- return 1;
- static red, green, blue;
- for ( new client = 1; client < get_maxplayers(); client++ )
- {
- if ( !is_user_connected( client ) || !is_user_alive( client ) || cs_get_user_team( client ) != CS_TEAM_T || g_iGang[ client ] == -1 )
- continue;
- red = g_iGangsColors[ g_iGang[ client ] ][ rColor ];
- green = g_iGangsColors[ g_iGang[ client ] ][ gColor ];
- blue = g_iGangsColors[ g_iGang[ client ] ][ bColor ];
- fm_set_user_rendering( client, kRenderFxGlowShell, red, green, blue, kRenderNormal, 16 );
- }
- return 1;
- }
- /* Stocks and Functions */
- public LoadGangs()
- {
- new szConfigsDir[ 60 ], szFileName[ 32 ];
- get_configsdir( szConfigsDir, charsmax( szConfigsDir ) );
- formatex( szFileName, charsmax( szFileName ), "/%s.ini", FILE_NAME );
- add( szConfigsDir, charsmax( szConfigsDir ), szFileName );
- new iFile = fopen( szConfigsDir, "rt" );
- new aData[ GangInfo ];
- new szBuffer[ 512 ], szData[ 256 ], szValue[ 512 ], i, iCurGang;
- while( !feof( iFile ) )
- {
- fgets( iFile, szBuffer, charsmax( szBuffer ) );
- trim( szBuffer );
- remove_quotes( szBuffer );
- if( !szBuffer[ 0 ] || szBuffer[ 0 ] == ';' )
- {
- continue;
- }
- if( szBuffer[ 0 ] == '[' && szBuffer[ strlen( szBuffer ) - 1 ] == ']' )
- {
- copy( aData[ GangName ], strlen( szBuffer ) - 2, szBuffer[ 1 ] );
- aData[ GangRegen ] = 0;
- aData[ GangBoost ] = 0;
- aData[ GangGetCash ] = 0;
- aData[ GangNext ] = 0;
- aData[ GangCash ] = 0;
- aData[ NumMembers ] = 0;
- aData[ GangMembers ] = _:TrieCreate();
- if( TrieKeyExists( g_tGangNames, aData[ GangName ] ) )
- {
- new szError[ 256 ];
- formatex( szError, charsmax( szError ), "[JB Gangs] Gang already exists: %s", aData[ GangName ] );
- set_fail_state( szError );
- }
- ArrayPushArray( g_aGangs, aData );
- TrieSetCell( g_tGangNames, aData[ GangName ], iCurGang );
- log_amx( "Gang Created: %s", aData[ GangName ] );
- iCurGang++;
- continue;
- }
- strtok( szBuffer, szData, charsmax( szData ), szValue, charsmax( szValue ), '=' );
- trim( szData );
- trim( szValue );
- if( TrieGetCell( g_tGangValues, szData, i ) )
- {
- ArrayGetArray( g_aGangs, iCurGang - 1, aData );
- switch( i )
- {
- case VALUE_REGEN:
- aData[ GangRegen ] = str_to_num( szValue );
- case VALUE_BOOST:
- aData[ GangBoost ] = str_to_num( szValue );
- case VALUE_GETCASH:
- aData[ GangGetCash ] = str_to_num( szValue );
- case VALUE_NEXTCASH:
- aData[ GangNext ] = str_to_num( szValue );
- case VALUE_CASH:
- aData[ GangCash ] = str_to_num( szValue );
- }
- ArraySetArray( g_aGangs, iCurGang - 1, aData );
- }
- }
- new Array:aSQL;
- sqlv_read_all_ex( g_hVault, aSQL );
- new aVaultData[ SQLVaultEntryEx ];
- new iGang;
- for( i = 0; i < ArraySize( aSQL ); i++ )
- {
- ArrayGetArray( aSQL, i, aVaultData );
- if( TrieGetCell( g_tGangNames, aVaultData[ SQLVEx_Key2 ], iGang ) )
- {
- ArrayGetArray( g_aGangs, iGang, aData );
- TrieSetCell( aData[ GangMembers ], aVaultData[ SQLVEx_Key1 ], str_to_num( aVaultData[ SQLVEx_Data ] ) );
- aData[ NumMembers ]++;
- ArraySetArray( g_aGangs, iGang, aData );
- }
- }
- fclose( iFile );
- }
- public SaveGangs()
- {
- new szConfigsDir[ 60 ], szFileName[ 32 ];
- get_configsdir( szConfigsDir, charsmax( szConfigsDir ) );
- formatex( szFileName, charsmax( szFileName ), "/%s.ini", FILE_NAME );
- add( szConfigsDir, charsmax( szConfigsDir ), szFileName );
- if( file_exists( szConfigsDir ) )
- delete_file( szConfigsDir );
- new iFile = fopen( szConfigsDir, "wt" );
- new aData[ GangInfo ];
- new szBuffer[ 256 ];
- for( new i = 0; i < ArraySize( g_aGangs ); i++ )
- {
- ArrayGetArray( g_aGangs, i, aData );
- formatex( szBuffer, charsmax( szBuffer ), "[%s]^n", aData[ GangName ] );
- fputs( iFile, szBuffer );
- formatex( szBuffer, charsmax( szBuffer ), "Regeneration=%i^n", aData[ GangRegen ] );
- fputs( iFile, szBuffer );
- formatex( szBuffer, charsmax( szBuffer ), "CashBoost=%i^n", aData[ GangBoost ] );
- fputs( iFile, szBuffer );
- formatex( szBuffer, charsmax( szBuffer ), "GetCash=%i^n", aData[ GangGetCash ] );
- fputs( iFile, szBuffer );
- formatex( szBuffer, charsmax( szBuffer ), "NextCash=%i^n", aData[ GangNext ] );
- fputs( iFile, szBuffer );
- formatex( szBuffer, charsmax( szBuffer ), "Cash=%i^n^n", aData[ GangCash ] );
- fputs( iFile, szBuffer );
- }
- fclose( iFile );
- }
- set_user_gang( id, iGang, iStatus = STATUS_MEMBER )
- {
- new szAuthID[ 35 ], szFormat[ 128 ];
- GetUserAuth( id, szAuthID, charsmax( szAuthID ) );
- new aData[ GangInfo ];
- if( g_iGang[ id ] > -1 )
- {
- ArrayGetArray( g_aGangs, g_iGang[ id ], aData );
- TrieDeleteKey( aData[ GangMembers ], szAuthID );
- aData[ NumMembers ]--;
- ArraySetArray( g_aGangs, g_iGang[ id ], aData );
- sqlv_remove_ex( g_hVault, szAuthID, aData[ GangName ] );
- }
- if( iGang > -1 )
- {
- formatex( szFormat, charsmax( szFormat ), "%s@%s", szAuthID, szName( id ) );
- ArrayGetArray( g_aGangs, iGang, aData );
- TrieSetCell( aData[ GangMembers ], szFormat, iStatus );
- aData[ NumMembers ]++;
- ArraySetArray( g_aGangs, iGang, aData );
- sqlv_set_num_ex( g_hVault, szFormat, aData[ GangName ], iStatus );
- }
- g_iGang[ id ] = iGang;
- return 1;
- }
- get_user_gang( id )
- {
- static aData[ GangInfo ], szAuthID[ 35 ];
- GetUserAuth( id, szAuthID, charsmax( szAuthID ) );
- new szKey1[ 254 ], szKey2[ 256 ], szData[ 512 ], szAuthID2[ 35 ], szNameID[ 32 ];
- for ( new i; i < sqlv_size_ex( g_hVault ); i++ )
- {
- sqlv_read_ex( g_hVault, i, szKey1, 255, szKey2, 255, szData, 511 );
- replace( szKey1, charsmax( szKey1 ), "@", " " );
- parse( szKey1, szAuthID2, charsmax( szAuthID2 ), szNameID, charsmax( szNameID ) );
- if ( equali( szAuthID, szAuthID2 ) )
- {
- for( new j; j < ArraySize( g_aGangs ); j++ )
- {
- ArrayGetArray( g_aGangs, j, aData );
- if ( equal( aData[ GangName ], szKey2 ) )
- return j;
- }
- }
- }
- return -1;
- }
- getStatus( id, iGang )
- {
- if ( !is_user_connected( id ) || iGang == -1 )
- return STATUS_NONE;
- static aData[ GangInfo ], szAuthID[ 35 ], iStatus;
- ArrayGetArray( g_aGangs, iGang, aData );
- GetUserAuth( id, szAuthID, charsmax( szAuthID ) );
- iStatus = 0;
- new szKey1[ 254 ], szKey2[ 256 ], szData[ 512 ], szAuthID2[ 35 ], szNameID[ 32 ];
- for ( new KeyIndex; KeyIndex < sqlv_size_ex( g_hVault ); KeyIndex++ )
- {
- sqlv_read_ex( g_hVault, KeyIndex, szKey1, 255, szKey2, 255, szData, 511 );
- replace( szKey1, charsmax( szKey1 ), "@", " " );
- parse( szKey1, szAuthID2, charsmax( szAuthID ), szNameID, charsmax( szNameID ) );
- if ( !( equal( szKey2, aData[ GangName ] ) ) )
- continue;
- if ( !( equali( szAuthID, szAuthID2 ) ) )
- continue;
- break;
- }
- iStatus = str_to_num( szData );
- TrieGetCell( aData[ GangMembers ], szAuthID, iStatus );
- return iStatus;
- }
- stock ColorChat( const client, const string[], any:... )
- {
- new szMsg[ 191 ], Players[ 32 ], PNum = 1;
- static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^3[^1 %s^3 ]^1 ", Info[ 4 ] );
- vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
- if ( client )
- Players[ 0 ] = client;
- else
- get_players( Players, PNum, "ch" );
- for ( new i; i < PNum; i++ )
- {
- if( is_user_connected( Players[ i ] ) )
- {
- message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
- write_byte( Players[ i ] );
- write_string( szMsg );
- message_end( );
- }
- }
- return 1;
- }
- stock szName( const index )
- {
- static g_szName[ 32 ]; get_user_name( index, g_szName, charsmax( g_szName ) );
- return g_szName;
- }
- stock szAuth( const index )
- {
- static g_szAuthID[ 35 ]; get_user_ip( index, g_szAuthID, charsmax( g_szAuthID ) ,1);
- return g_szAuthID;
- }
- stock szAddress( const index )
- {
- static g_szAddress[ 22 ]; get_user_ip( index, g_szAddress, charsmax( g_szAddress ), 1 );
- return g_szAddress;
- }
- /*stock GetTeamColor( CsTeams:iTeam )
- {
- switch ( iTeam )
- {
- case CS_TEAM_CT: return BLUE;
- case CS_TEAM_T: return RED;
- case CS_TEAM_SPECTATOR: return GREY;
- }
- return GREEN;
- }*/
- stock bool:is_str_type(const string[], StrType:flags, const exceptions[] = "")
- {
- new c, i, tmp[2];
- while(is_char(c = string[i++]))
- {
- if(flags & STRTYPE_NUM && isdigit(c)
- || flags & STRTYPE_ALPHA && isalpha(c)
- || flags & STRTYPE_SPACE && isspace(c))
- {
- continue;
- }
- tmp[0] = c;
- if(contain(exceptions, tmp) != -1)
- {
- continue;
- }
- return false;
- }
- return (i > 1);
- }
- stock GetUserAuth( const index, output[], len )
- {
- //if ( IsValidAuthid( szAuth( index ) ) )
- //get_user_authid( index, output, len );
- get_user_ip( index, output, len, 1 )
- }
- stock bool: is_auth_online( Auth[] )
- {
- static Players[ 32 ], iNum, iPlayer, szAuthID[ 35 ];
- get_players( Players, iNum, "ch" );
- for ( new i; i < iNum; i++ )
- {
- iPlayer = Players[ i ];
- if ( IsValidAuthid( Auth ) )
- formatex( szAuthID, charsmax( szAuthID ), szAuth( iPlayer ) );
- else formatex( szAuthID, charsmax( szAuthID ), szAddress( iPlayer ) );
- if ( equali( Auth, szAuthID ) )
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement