Официалният форум на iPlay.bg 

Този раздел е създаден специално за проблеми и въпроси за направата на плъгини или преработката на вече съществуващи кодове.
 #388200  от southdivision
 пет апр 22, 2016 12:07 am
Invalid cellvector handle provided (7:-1:0)
[AMXX] Displaying debug trace (plugin "jb_gangs.amxx")
[AMXX] Run time error 10: native error (native "ArrayGetArray")
[AMXX] [0] jb_gangs.sma::client_putinserver (line 191)
Код: Избери всички
#include <amxmodx>
#include <amxmisc>
#include <sqlvault_ex>
#include <cstrike>
#include <colorchat>
#include <hamsandwich>
#include <fun>
#include <pokemod>

new const g_szVersion[ ] = "1.0";

enum _:GangInfo
{
Trie:GangMembers,
	GangName[ 64 ],
	GangHP,
	GangStealing,
	GangGravity,
	GangDamage,
	GangStamina,
	GangWeaponDrop,
	GangKills,
	GangEXP,
	GangLevel,
	NumMembers
};

enum
{
	VALUE_HP,
	VALUE_STEALING,
	VALUE_GRAVITY,
	VALUE_DAMAGE,
	VALUE_STAMINA,
	VALUE_WEAPONDROP,
	VALUE_KILLS,
	VALUE_EXP,
	VALUE_LEVEL
}

enum
{
	STATUS_NONE,
	STATUS_MEMBER,
	STATUS_ADMIN,
	STATUS_LEADER
};

new const g_szGangValues[ ][ ] = 
{
	"HP",
	"Stealing",
	"Gravity",
	"Damage",
	"Stamina",
	"WeaponDrop",
	"Kills",
	"EXP",
	"Level"
};

new const g_szPrefix[ ] = "^04[Gildia]^01";

new Trie:g_tGangNames;
new Trie:g_tGangValues;

new SQLVault:g_hVault;
new SQLVault:g_hPointsVault;

new Array:g_aGangs;

new g_pCreateCost;

new g_pHealthCost;
new g_pStealingCost;
new g_pGravityCost;
new g_pDamageCost;
new g_pStaminaCost;
new g_pWeaponDropCost;

new g_pHealthMax;
new g_pStealingMax;
new g_pGravityMax;
new g_pDamageMax;
new g_pStaminaMax;
new g_pWeaponDropMax;

new g_pHealthPerLevel;
new g_pStealingPerLevel;
new g_pGravityPerLevel;
new g_pDamagePerLevel;
new g_pStaminaPerLevel;
new g_pWeaponDropPerLevel;

new g_pPointsPerKill;
new g_pHeadshotBonus;

new g_pMaxMembers;

new g_iGang[ 33 ];

new const exp_poziomu[] = {0,35000,85000,160000,290000,490000,620000,890000,1300000,1800000};

public plugin_init()
{
	register_plugin( "Jailbreak Gang System", g_szVersion, "Radim" );

	g_aGangs 				= ArrayCreate( GangInfo );

	g_tGangValues 			= TrieCreate();
	g_tGangNames 			= TrieCreate();

	g_hVault 				= sqlv_open_local( "jb_gangs", false );
	sqlv_init_ex( g_hVault );

	g_hPointsVault			= sqlv_open_local( "jb_points", true );

	g_pCreateCost			= register_cvar( "jb_gang_cost", 		"50" );
	g_pHealthCost			= register_cvar( "jb_health_cost", 		"20" );
	g_pStealingCost 		= register_cvar( "jb_stealing_cost", 	"20" );
	g_pGravityCost			= register_cvar( "jb_gravity_cost", 	"20" );
	g_pDamageCost			= register_cvar( "jb_damage_cost", 		"20" );
	g_pStaminaCost			= register_cvar( "jb_stamina_cost", 	"20" );
	g_pWeaponDropCost		= register_cvar( "jb_weapondrop_cost", 	"20" );

	g_pHealthMax			= register_cvar( "jb_health_max", 		"10" );
	g_pStealingMax			= register_cvar( "jb_stealing_max", 	"10" );
	g_pGravityMax			= register_cvar( "jb_gravity_max", 		"10" ); // Max * Gravity Per Level must be LESS than 800
	g_pDamageMax			= register_cvar( "jb_damage_max", 		"10" );
	g_pStaminaMax			= register_cvar( "jb_stamina_max", 		"10" );
	g_pWeaponDropMax		= register_cvar( "jb_weapondrop_max", 	"10" );

	g_pHealthPerLevel		= register_cvar( "jb_health_per", 		"10" 	);
	g_pStealingPerLevel		= register_cvar( "jb_stealing_per", 	"0.05" 	);
	g_pGravityPerLevel		= register_cvar( "jb_gravity_per", 		"50" 	);
	g_pDamagePerLevel		= register_cvar( "jb_damage_per", 		"3" 	);
	g_pStaminaPerLevel		= register_cvar( "jb_stamina_per", 		"3" 	);
	g_pWeaponDropPerLevel 		= register_cvar( "jb_weapondrop_per", 	"1" 	);

	g_pPointsPerKill		= register_cvar( "jb_points_per_kill",	"3" );
	g_pHeadshotBonus		= register_cvar( "jb_headshot_bonus",	"2" );

	g_pMaxMembers			= register_cvar( "jb_max_members",		"10" );

	register_cvar( "jb_gang_version", g_szVersion, FCVAR_SPONLY | FCVAR_SERVER );

	register_menu( "Gang Menu", 1023, "GangMenu_Handler" );
	register_menu( "Skills Menu", 1023, "SkillsMenu_Handler" );

	for( new i = 0; i < sizeof g_szGangValues; i++ )
	{
		TrieSetCell( g_tGangValues, g_szGangValues[ i ], i );
	}

	RegisterHam( Ham_Spawn, "player", "Ham_PlayerSpawn_Post", 1 );
	RegisterHam( Ham_TakeDamage, "player", "Ham_TakeDamage_Pre", 0 );
	RegisterHam( Ham_TakeDamage, "player", "Ham_TakeDamage_Post", 1 );
	RegisterHam( Ham_Item_PreFrame, "player", "Ham_PlayerResetSpeedPost", 1);

	register_event( "DeathMsg", "Event_DeathMsg", "a" );

	register_clcmd( "say /gang", "Cmd_Gang" );
	register_clcmd( "gang_name", "Cmd_CreateGang" );
	register_clcmd("say", "Wplac");

	LoadGangs();
}

public client_disconnect( id )
{
	new szAuthID[ 35 ];
	get_user_authid( id, szAuthID, charsmax( szAuthID ) );
	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, g_iGang[ id ], aData );

	sqlv_set_num( g_hPointsVault, szAuthID, aData[ GangEXP ] );
	ArraySetArray( g_aGangs, g_iGang[id], aData );
	g_iGang[ id ] = -1;
}

public client_connect( id )
{
	g_iGang[ id ] = get_user_gang( id );
}

public client_putinserver( id )
{
	new szAuthID[ 35 ];
	get_user_authid( id, szAuthID, charsmax( szAuthID ) );
	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, g_iGang[ id ], aData );

	aData[ GangEXP ] = sqlv_get_num( g_hPointsVault, szAuthID );
}

public plugin_end()
{
	SaveGangs();
	sqlv_close( g_hVault );
	ArrayDestroy( g_aGangs );
}

public Ham_PlayerSpawn_Post( id )
{
	if( !is_user_alive( id ) )
	return HAM_IGNORED;

	if( g_iGang[ id ] == -1 )
	{
		return HAM_IGNORED;
	}

	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, g_iGang[ id ], aData );

	new iHealth = 100 + aData[ GangHP ] * get_pcvar_num( g_pHealthPerLevel );
	set_user_health( id, iHealth );

	new iGravity = 800 - ( get_pcvar_num( g_pGravityPerLevel ) * aData[ GangGravity ] );
	set_user_gravity( id, float( iGravity ) / 800.0 );

	return HAM_IGNORED;
}

public Ham_TakeDamage_Pre( iVictim, iInflictor, iAttacker, Float:flDamage, iBits )
{
	if( !is_user_alive( iAttacker ) )
	return HAM_IGNORED;

	if( g_iGang[ iAttacker ] == -1 )
	return HAM_IGNORED;

	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, g_iGang[ iAttacker ], aData );

	SetHamParamFloat( 4, flDamage + ( get_pcvar_num( g_pDamagePerLevel ) * ( aData[ GangDamage ] ) ) );

	return HAM_IGNORED;
}

public Ham_TakeDamage_Post( iVictim, iInflictor, iAttacker, Float:flDamage, iBits )
{
	if( !is_user_alive( iAttacker ) || g_iGang[ iAttacker ] == -1 || get_user_weapon( iAttacker ) != CSW_KNIFE )
	{
		return HAM_IGNORED;
	}

	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, g_iGang[ iAttacker ], aData );

	new iChance = aData[ GangWeaponDrop ] * get_pcvar_num( g_pWeaponDropPerLevel );

	if( iChance == 0 )
	return HAM_IGNORED;
	
	new bool:bDrop = ( random_num( 1, 100 ) <= iChance );
	
	if( bDrop )
	client_cmd( iVictim, "drop" );
	
	return HAM_IGNORED;
}

public Ham_PlayerResetSpeedPost( id )
{
	if( g_iGang[ id ] == -1 || !is_user_alive( id ) )
	{
		return HAM_IGNORED;
	}
	
	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, g_iGang[ id ], aData );
	
	if( aData[ GangStamina ] > 0 && get_user_maxspeed( id ) > 1.0 )
	set_user_maxspeed( id, 250.0 + ( aData[ GangStamina ] * get_pcvar_num( g_pStaminaPerLevel ) ) );
	
	return HAM_IGNORED;
}

public Event_DeathMsg()
{
	new iKiller = read_data( 1 );
	new iVictim = read_data( 2 );
	
	if( !is_user_alive( iKiller ) || get_user_team( iKiller ) == get_user_team( iVictim ) )
	return PLUGIN_CONTINUE;
	
	new iTotal = get_pcvar_num( g_pPointsPerKill ) + ( bool:read_data( 3 ) ? get_pcvar_num( g_pHeadshotBonus ) : 0 );
	
	if( g_iGang[ iKiller ] > -1 )
	{
		new aData[ GangInfo ];
		ArrayGetArray( g_aGangs, g_iGang[ iKiller ], aData );
		aData[ GangKills ]++;
		ArraySetArray( g_aGangs, g_iGang[ iKiller ], aData );
		
		iTotal += iTotal * ( aData[ GangStealing ] * get_pcvar_num( g_pStealingPerLevel ) );
	}
	
	return PLUGIN_CONTINUE;
}

public Cmd_Gang( id )
{	
	if( !is_user_connected( id ) )
	return PLUGIN_HANDLED;
	
	static szMenu[ 512 ], iLen, aData[ GangInfo ], iKeys, iStatus;
	
	iKeys = MENU_KEY_0 | MENU_KEY_4;
	
	iStatus = getStatus( id, g_iGang[ id ] );
	
	if( g_iGang[ id ] > -1 )
	{
		ArrayGetArray( g_aGangs, g_iGang[ id ], aData );
		iLen 	= 	formatex( szMenu, charsmax( szMenu ),  "\yMenu Gangu^n\wAktualny Gang:\y %s^n", aData[ GangName ] );
		iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\yGildyjny EXP: \w%i / %i^n", aData[ GangEXP ], exp_poziomu[aData[ GangLevel ]]);
		iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\yLevel Gildii: \w%i^n^n", aData[ GangLevel ]);
		iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r1. \dStworz gang [%i Blantow]^n", get_pcvar_num( g_pCreateCost ) );
	}
	
	else
	{
		iLen 	= 	formatex( szMenu, charsmax( szMenu ),  "\yMenu Gangu^n\wAktualny gang:\r None^n" );
		iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\yGildyjny EXP: \w%i^n^n", aData[ GangEXP ] );
		iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r1. \wStworz gang [%i Blantow]^n", get_pcvar_num( g_pCreateCost ) );
		
		iKeys |= MENU_KEY_1;
	}
	
	
	if( iStatus > STATUS_MEMBER && g_iGang[ id ] > -1 && get_pcvar_num( g_pMaxMembers ) > aData[ NumMembers ] )
	{
		iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r2. \wZapros gracza do gangu^n" );
		iKeys |= MENU_KEY_2;
	}
	else
	iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r2. \dZapros gracza do gangu^n" );
	
	if( g_iGang[ id ] > -1 )
	{
		iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r3. \wUmiejetnosci^n" );
		iKeys |= MENU_KEY_3;
	}
	
	else
	iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r3. \dUmiejetnosci^n" );
	
	iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r4. \wTop-10^n" );
	
	if( g_iGang[ id ] > -1 )
	{
		iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r5. \wOpusc Gang^n" );
		iKeys |= MENU_KEY_5;
	}
	
	else
	iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r5. \dOpusc gang^n" );
	
	
	if( iStatus > STATUS_MEMBER )
	{
		iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r6. \wMenu Leadera Gangu^n" );
		iKeys |= MENU_KEY_6;
	}
	
	else
	iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r6. \dMenu Leadera Gangu^n" );
	
	if( g_iGang[ id ] > -1 )
	{
		iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r7. \wCzlonkowie online^n" );
		iKeys |= MENU_KEY_7;
	}
	
	else
	iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "\r7. \dCzlonkowie online^n" );
	
	iLen	+=	formatex( szMenu[ iLen ], charsmax( szMenu ) - iLen, "^n\r0. \wExit" );
	
	show_menu( id, iKeys, szMenu, -1, "Gang Menu" );
	
	return PLUGIN_CONTINUE;
}

public GangMenu_Handler( id, iKey )
{
	new pokerank = Poke_PlayerRank(id);
	switch( ( iKey + 1 ) % 10 )
	{
	case 0: return PLUGIN_HANDLED;
		
	case 1: 
		{
			
			if( pokerank < get_pcvar_num( g_pCreateCost ) )
			{
				ColorChat( id, NORMAL, "%s Nie masz wystarczajaco PokeRanku aby utworzyc gang!", g_szPrefix );
				return PLUGIN_HANDLED;
			}
			
			else
			client_cmd( id, "messagemode gang_name" );
		}
		
	case 2:
		{
			ShowInviteMenu( id );
		}
		
	case 3:
		{
			ShowSkillsMenu( id );
		}
		
	case 4:
		{
			Cmd_Top10( id );
		}
		
	case 5:
		{
			ShowLeaveConfirmMenu( id );
		}
		
	case 6:
		{
			ShowLeaderMenu( id );
		}
		
	case 7:
		{
			ShowMembersMenu( id );
		}
	}
	
	return PLUGIN_HANDLED;
}

public Cmd_CreateGang( id )
{
	new pokerank = Poke_PlayerRank(id);
	
	if( pokerank < get_pcvar_num( g_pCreateCost ) )
	{
		ColorChat( id, NORMAL, "%s Nie masz wystarczajaco PokeRanku aby utworzyc gang!", g_szPrefix );
		return PLUGIN_HANDLED;
	}
	
	else if( g_iGang[ id ] > -1 )
	{
		ColorChat( id, NORMAL, "%s Nie mozesz stworzyc gangu jesli jestes w innym!", g_szPrefix );
		return PLUGIN_HANDLED;
	}
	
	new szArgs[ 60 ];
	read_args( szArgs, charsmax( szArgs ) );
	
	remove_quotes( szArgs );
	
	if( TrieKeyExists( g_tGangNames, szArgs ) )
	{
		ColorChat( id, NORMAL, "%s Gang z ta nazwa juz istnieje.", g_szPrefix );
		Cmd_Gang( id );
		return PLUGIN_HANDLED;
	}
	
	new aData[ GangInfo ];
	
	aData[ GangName ] 		= szArgs;
	aData[ GangHP ] 		= 0;
	aData[ GangStealing ] 	= 0;
	aData[ GangGravity ] 	= 0;
	aData[ GangStamina ] 	= 0;
	aData[ GangWeaponDrop ]	= 0;
	aData[ GangDamage ] 	= 0;
	aData[ GangEXP ]	= 0;
	aData[ GangLevel ]	= 0;
	aData[ NumMembers ] 	= 0;
	aData[ GangMembers ] 	= _:TrieCreate();
	
	ArrayPushArray( g_aGangs, aData );
	
	set_user_gang( id, ArraySize( g_aGangs ) - 1, STATUS_LEADER );
	
	ColorChat( id, NORMAL, "%s Stworzyles gang o nazwie '^03%s^01'.", g_szPrefix, szArgs );
	
	return PLUGIN_HANDLED;
}

public ShowInviteMenu( id )
{	
	new iPlayers[ 32 ], iNum;
	get_players( iPlayers, iNum );
	
	new szInfo[ 6 ], hMenu;
	hMenu = menu_create( "Wybierz gracza do zaproszenia:", "InviteMenu_Handler" );
	new szName[ 32 ];
	
	for( new i = 0, iPlayer; i < iNum; i++ )
	{
		iPlayer = iPlayers[ i ];
		
		if( iPlayer == id || g_iGang[ iPlayer ] == g_iGang[ id ] )
		continue;
		
		get_user_name( iPlayer, szName, charsmax( szName ) );
		
		num_to_str( iPlayer, szInfo, charsmax( szInfo ) );
		
		menu_additem( hMenu, szName, szInfo );
	}
	
	menu_display( id, hMenu, 0 );
}

public InviteMenu_Handler( id, hMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		Cmd_Gang( id );
		return PLUGIN_HANDLED;
	}
	
	new szData[ 6 ], iAccess, hCallback, szName[ 32 ];
	menu_item_getinfo( hMenu, iItem, iAccess, szData, 5, szName, 31, hCallback );
	
	new iPlayer = str_to_num( szData );
	
	if( !is_user_connected( iPlayer ) )
	return PLUGIN_HANDLED;
	
	ShowInviteConfirmMenu( id, iPlayer );
	
	ColorChat( id, NORMAL, "%s Udalo Ci sie zaprosic %s do dolaczenia do Twojego gangu.", g_szPrefix, szName );
	
	Cmd_Gang( id );
	return PLUGIN_HANDLED;
}

public ShowInviteConfirmMenu( id, iPlayer )
{
	new szName[ 32 ];
	get_user_name( id, szName, charsmax( szName ) );
	
	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, g_iGang[ id ], aData );
	
	new szMenuTitle[ 128 ];
	formatex( szMenuTitle, charsmax( szMenuTitle ), "%s Zaprasza Cie do gangu %s", szName, aData[ GangName ] );
	new hMenu = menu_create( szMenuTitle, "InviteConfirmMenu_Handler" );
	
	new szInfo[ 6 ];
	num_to_str( g_iGang[ id ], szInfo, 5 );
	
	menu_additem( hMenu, "Akceptuj zaproszenie", szInfo );
	menu_additem( hMenu, "Odrzuc zaproszenie", "-1" );
	
	menu_display( iPlayer, hMenu, 0 );	
}

public InviteConfirmMenu_Handler( id, hMenu, iItem )
{
	if( iItem == MENU_EXIT )
	return PLUGIN_HANDLED;
	
	new szData[ 6 ], iAccess, hCallback;
	menu_item_getinfo( hMenu, iItem, iAccess, szData, 5, _, _, hCallback );
	
	new iGang = str_to_num( szData );
	
	if( iGang == -1 )
	return PLUGIN_HANDLED;
	
	if( getStatus( id, g_iGang[ id ] ) == STATUS_LEADER )
	{
		ColorChat( id, NORMAL, "%s Nie mozesz opuscic gangu kiedy jestes ledaerem.", g_szPrefix );
		return PLUGIN_HANDLED;
	}
	
	set_user_gang( id, iGang );
	
	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, iGang, aData );
	
	ColorChat( id, NORMAL, "%s Udalo Ci sie dolaczyc do gangu ^03%s^01.", g_szPrefix, aData[ GangName ] );
	
	return PLUGIN_HANDLED;
}


public ShowSkillsMenu( id )
{	
	static szMenu[ 512 ], iLen, iKeys, aData[ GangInfo ];
	
	if( !iKeys )
	{
		iKeys = MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0;
	}
	
	ArrayGetArray( g_aGangs, g_iGang[ id ], aData );
	
	iLen	=	formatex( szMenu, charsmax( szMenu ), "\yMenu umiejetnosci^n^n" );
	iLen	+=	formatex( szMenu[ iLen ], 511 - iLen, "\r1. \wSilownia [\rKoszt: \y%i Respektu\w] \y[Level:%i/%i]^n", get_pcvar_num( g_pHealthCost ), aData[ GangHP ], get_pcvar_num( g_pHealthMax ) );
	iLen	+=	formatex( szMenu[ iLen ], 511 - iLen, "\r2. \wZlodziejstwo [\rKoszt: \y%i Respektu\w] \y[Level:%i/%i]^n", get_pcvar_num( g_pStealingCost ), aData[ GangStealing ], get_pcvar_num( g_pStealingMax ) );
	iLen	+=	formatex( szMenu[ iLen ], 511 - iLen, "\r3. \wNarkomania [\rKoszt: \y%i Respektu\w] \y[Level:%i/%i]^n", get_pcvar_num( g_pGravityCost ), aData[ GangGravity ], get_pcvar_num( g_pGravityMax ) );
	iLen	+=	formatex( szMenu[ iLen ], 511 - iLen, "\r4. \wObrazenia [\rKoszt: \y%i Respektu\w] \y[Level:%i/%i]^n", get_pcvar_num( g_pDamageCost ), aData[ GangDamage ], get_pcvar_num( g_pDamageMax ) );
	iLen	+=	formatex( szMenu[ iLen ], 511 - iLen, "\r5. \wObezwladnienie [\rKoszt: \y%i Respektu\w] \y[Level:%i/%i]^n", get_pcvar_num( g_pWeaponDropCost ), aData[ GangWeaponDrop ], get_pcvar_num( g_pWeaponDropMax ) );
	iLen	+=	formatex( szMenu[ iLen ], 511 - iLen, "\r6. \wUcieczka [\rKoszt: \y%i Respektu\w] \y[Level:%i/%i]^n", get_pcvar_num( g_pStaminaCost ), aData[ GangStamina ], get_pcvar_num( g_pStaminaMax ) );
	
	iLen	+=	formatex( szMenu[ iLen ], 511 - iLen, "^n\r0. \wExit" );
	
	show_menu( id, iKeys, szMenu, -1, "Skills Menu" );
}

public SkillsMenu_Handler( id, iKey )
{
	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, g_iGang[ id ], aData );
	
	switch( ( iKey + 1 ) % 10 )
	{
	case 0: 
		{
			Cmd_Gang( id );
			return PLUGIN_HANDLED;
		}
		
	case 1:
		{
			if( aData[ GangHP ] == get_pcvar_num( g_pHealthMax ) )
			{
				ColorChat( id, NORMAL, "%s Twoj gang ma juz maksymalny poziom tej umiejetnosci.", g_szPrefix  );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			new iRemaining = aData[ GangEXP ] - get_pcvar_num( g_pHealthCost );
			
			if( iRemaining < 0 )
			{
				ColorChat( id, NORMAL, "%s Nie masz wystarczajaco respektu na to.", g_szPrefix );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			aData[ GangHP ]++;
			
			aData[ GangEXP ] = iRemaining;
		}
		
	case 2:
		{
			if( aData[ GangStealing ] == get_pcvar_num( g_pStealingMax ) )
			{
				ColorChat( id, NORMAL, "%s Twoj gang ma juz maksymalny poziom tej umiejetnosci.", g_szPrefix  );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			new iRemaining = aData[ GangEXP ] - get_pcvar_num( g_pStealingCost );
			
			if( iRemaining < 0 )
			{
				ColorChat( id, NORMAL, "%s Nie masz wystarczajaco respektu na to.", g_szPrefix );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			aData[ GangStealing ]++;
			
			aData[ GangEXP ] = iRemaining;
		}
		
	case 3:
		{
			if( aData[ GangGravity ] == get_pcvar_num( g_pGravityMax ) )
			{
				ColorChat( id, NORMAL, "%s Twoj gang ma juz maksymalny poziom tej umiejetnosci.", g_szPrefix  );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			new iRemaining = aData[ GangEXP ] - get_pcvar_num( g_pGravityCost );
			
			if( iRemaining < 0 )
			{
				ColorChat( id, NORMAL, "%s Nie masz wystarczajaco respektu na to.", g_szPrefix );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			aData[ GangGravity ]++;
			
			aData[ GangEXP ] = iRemaining;
		}
		
	case 4:
		{
			if( aData[ GangDamage ] == get_pcvar_num( g_pDamageMax ) )
			{
				ColorChat( id, NORMAL, "%s Twoj gang ma juz maksymalny poziom tej umiejetnosci.", g_szPrefix  );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			new iRemaining = aData[ GangEXP ] - get_pcvar_num( g_pDamageCost );
			
			if( iRemaining < 0 )
			{
				ColorChat( id, NORMAL, "%s Nie masz wystarczajaco respektu na to.", g_szPrefix );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			aData[ GangDamage ]++;
			
			aData[ GangEXP ] = iRemaining;
		}
		
	case 5:
		{
			if( aData[ GangWeaponDrop ] == get_pcvar_num( g_pWeaponDropMax ) )
			{
				ColorChat( id, NORMAL, "%s Twoj gang ma juz maksymalny poziom tej umiejetnosci.", g_szPrefix  );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			new iRemaining = aData[ GangEXP ] - get_pcvar_num( g_pWeaponDropCost );
			
			if( iRemaining < 0 )
			{
				ColorChat( id, NORMAL, "%s Nie masz wystarczajaco respektu na to.", g_szPrefix );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			aData[ GangWeaponDrop ]++;
			
			aData[ GangEXP ] = iRemaining;
		}
		
	case 6:
		{
			if( aData[ GangStamina ] == get_pcvar_num( g_pStaminaMax ) )
			{
				ColorChat( id, NORMAL, "%s Twoj gang ma juz maksymalny poziom tej umiejetnosci.", g_szPrefix  );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			new iRemaining = aData[ GangEXP ] - get_pcvar_num( g_pStaminaCost );
			
			if( iRemaining < 0 )
			{
				ColorChat( id, NORMAL, "%s Nie masz wystarczajaco respektu na to.", g_szPrefix );
				ShowSkillsMenu( id );
				return PLUGIN_HANDLED;
			}
			
			aData[ GangStamina ]++;
			
			aData[ GangEXP ] = iRemaining;
		}
	}
	
	ArraySetArray( g_aGangs, g_iGang[ id ], aData );
	
	new iPlayers[ 32 ], iNum, iPlayer;
	new szName[ 32 ];
	get_players( iPlayers, iNum );
	
	for( new i = 0; i < iNum; i++ )
	{
		iPlayer = iPlayers[ i ];
		
		if( iPlayer == id || g_iGang[ iPlayer ] != g_iGang[ id ] )
		continue;
		
		ColorChat( iPlayer, NORMAL, "%s ^03%s ^01 ulepszyl jedna z umiejetnosci Naszego gangu.", g_szPrefix, szName );
	}
	
	ColorChat( id, NORMAL, "%s Udalo Ci sie ulepszyc gang!.", g_szPrefix );
	
	ShowSkillsMenu( id );
	
	return PLUGIN_HANDLED;
}


public Cmd_Top10( id )
{
	new iSize = ArraySize( g_aGangs );
	
	new iOrder[ 100 ][ 2 ];
	
	new aData[ GangInfo ];
	
	for( new i = 0; i < iSize; i++ )
	{
		ArrayGetArray( g_aGangs, i, aData );
		
		iOrder[ i ][ 0 ] = i;
		iOrder[ i ][ 1 ] = aData[ GangKills ];
	}
	
	SortCustom2D( iOrder, iSize, "Top10_Sort" );
	
	new szMessage[ 2048 ];
	formatex( szMessage, charsmax( szMessage ), "<body bgcolor=#000000><font color=#FFB000><pre>" );
	format( szMessage, charsmax( szMessage ), "%s%2s %-22.22s %7s %4s %10s %9s %9s %11s %8s^n", szMessage, "#", "Nazwa", "Zabojstwa", "HP", "Kradziez", 
	"Narkomania", "Ucieczka", "Obezwladnienie", "Obrazenia" );
	
	for( new i = 0; i < min( 10, iSize ); i++ )
	{
		ArrayGetArray( g_aGangs, iOrder[ i ][ 0 ], aData );
		
		format( szMessage, charsmax( szMessage ), "%s%-2d %22.22s %7d %4d %10d %9d %9d %11d %8d^n", szMessage, i + 1, aData[ GangName ], 
		aData[ GangKills ], aData[ GangHP ], aData[ GangStealing ], aData[ GangGravity ], aData[ GangStamina], aData[ GangWeaponDrop ], aData[ GangDamage ] );
	}
	
	show_motd( id, szMessage, "Gang Top 10" );
}

public Top10_Sort( const iElement1[ ], const iElement2[ ], const iArray[ ], szData[], iSize ) 
{
	if( iElement1[ 1 ] > iElement2[ 1 ] )
	return -1;
	
	else if( iElement1[ 1 ] < iElement2[ 1 ] )
	return 1;
	
	return 0;
}

public ShowLeaveConfirmMenu( id )
{
	new hMenu = menu_create( "Jestes pewien ze chcesz opuscic gang?", "LeaveConfirmMenu_Handler" );
	menu_additem( hMenu, "Tak", "0" );
	menu_additem( hMenu, "Nie", "1" );
	
	menu_display( id, hMenu, 0 );
}

public LeaveConfirmMenu_Handler( id, hMenu, iItem )
{
	if( iItem == MENU_EXIT )
	return PLUGIN_HANDLED;
	
	new szData[ 6 ], iAccess, hCallback;
	menu_item_getinfo( hMenu, iItem, iAccess, szData, 5, _, _, hCallback );
	
	switch( str_to_num( szData ) )
	{
	case 0: 
		{
			if( getStatus( id, g_iGang[ id ] ) == STATUS_LEADER )
			{
				ColorChat( id, NORMAL, "%s Oddaj przywodctwo zanim odejdziesz.", g_szPrefix );
				Cmd_Gang( id );
				
				return PLUGIN_HANDLED;
			}
			
			ColorChat( id, NORMAL, "%s Opusciles swoj gang.", g_szPrefix );
			set_user_gang( id, -1 );
			Cmd_Gang( id );
		}
		
	case 1: Cmd_Gang( id );
	}
	
	return PLUGIN_HANDLED;
}

public ShowLeaderMenu( id )
{
	new hMenu = menu_create( "Gang Leader Menu", "LeaderMenu_Handler" );
	
	new iStatus = getStatus( id, g_iGang[ id ] );
	
	if( iStatus == STATUS_LEADER )
	{
		menu_additem( hMenu, "Usun gang", "0" );
		menu_additem( hMenu, "Przenies przywodctwo", "1" );
		menu_additem( hMenu, "Dodaj viceleadera", "4" );
		menu_additem( hMenu, "Odbierz viceleadera", "5" );
	}
	
	menu_additem( hMenu, "Usun z gangu", "2" );
	menu_additem( hMenu, "Zmien nazwe gangu", "3" );
	
	
	menu_display( id, hMenu, 0 );
}

public LeaderMenu_Handler( id, hMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		Cmd_Gang( id );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, hCallback, szData[ 6 ];
	menu_item_getinfo( hMenu, iItem, iAccess, szData, 5, _, _, hCallback );
	
	switch( str_to_num( szData ) )
	{
	case 0:
		{
			ShowDisbandConfirmMenu( id );
		}
		
	case 1:
		{
			ShowTransferMenu( id );
		}
		
	case 2:
		{
			ShowKickMenu( id );
		}
		
	case 3:
		{
			client_cmd( id, "messagemode New_Name" );
		}
		
	case 4:
		{
			ShowAddAdminMenu( id );
		}
		
	case 5:
		{
			ShowRemoveAdminMenu( id );
		}
	}
	
	return PLUGIN_HANDLED;
}

public ShowDisbandConfirmMenu( id )
{
	new hMenu = menu_create( "Jestes pewien ze chcesz usunac gang?", "DisbandConfirmMenu_Handler" );
	menu_additem( hMenu, "Tak, usun ten chlam", "0" );
	menu_additem( hMenu, "Nie, bede bronil swoich przyjaciol", "1" );
	
	menu_display( id, hMenu, 0 );
}

public DisbandConfirmMenu_Handler( id, hMenu, iItem )
{
	if( iItem == MENU_EXIT )
	return PLUGIN_HANDLED;
	
	new szData[ 6 ], iAccess, hCallback;
	menu_item_getinfo( hMenu, iItem, iAccess, szData, 5, _, _, hCallback );
	
	switch( str_to_num( szData ) )
	{
	case 0: 
		{
			
			ColorChat( id, NORMAL, "%s Rozwiazales swoj gang.", g_szPrefix );
			
			new iPlayers[ 32 ], iNum;
			
			get_players( iPlayers, iNum );
			
			new iPlayer;
			
			for( new i = 0; i < iNum; i++ )
			{
				iPlayer = iPlayers[ i ];
				
				if( iPlayer == id )
				continue;
				
				if( g_iGang[ id ] != g_iGang[ iPlayer ] )
				continue;
				
				ColorChat( iPlayer, NORMAL, "%s Twoj gang zostal rozwiazany przez lidera.", g_szPrefix );
				set_user_gang( iPlayer, -1 );
			}
			new iGang = g_iGang[ id ];
			
			set_user_gang( id, -1 );
			
			ArrayDeleteItem( g_aGangs, iGang );
			
			Cmd_Gang( id );
		}
		
	case 1: Cmd_Gang( id );
	}
	
	return PLUGIN_HANDLED;
}

public ShowTransferMenu( id )
{
	new iPlayers[ 32 ], iNum;
	get_players( iPlayers, iNum );
	
	new hMenu = menu_create( "Przekaz przywodctwo:", "TransferMenu_Handler" );
	new szName[ 32 ], szData[ 6 ];
	
	for( new i = 0, iPlayer; i < iNum; i++ )
	{
		iPlayer = iPlayers[ i ];
		
		if( g_iGang[ iPlayer ] != g_iGang[ id ] || id == iPlayer )
		continue;
		
		get_user_name( iPlayer, szName, charsmax( szName ) );
		num_to_str( iPlayer, szData, charsmax( szData ) );
		
		menu_additem( hMenu, szName, szData );
	}
	
	menu_display( id, hMenu, 0 );
}

public TransferMenu_Handler( id, hMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		ShowLeaderMenu( id );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, hCallback, szData[ 6 ], szName[ 32 ];
	
	menu_item_getinfo( hMenu, iItem, iAccess, szData, 5, szName, charsmax( szName ), hCallback );
	
	new iPlayer = str_to_num( szData );
	
	if( !is_user_connected( iPlayer ) )
	{
		ColorChat( id, NORMAL, "%s Ten gracz nie jest polaczony z serwerem.", g_szPrefix );
		ShowTransferMenu( id );
		return PLUGIN_HANDLED;
	}
	
	set_user_gang( iPlayer, g_iGang[ id ], STATUS_LEADER );
	set_user_gang( id, g_iGang[ id ], STATUS_ADMIN );
	
	Cmd_Gang( id );
	
	new iPlayers[ 32 ], iNum, iTemp;
	get_players( iPlayers, iNum );
	
	for( new i = 0; i < iNum; i++ )
	{
		iTemp = iPlayers[ i ];
		
		if( iTemp == iPlayer )
		{
			ColorChat( iTemp, NORMAL, "%s Jestes nowym przywodca tego gangu.", g_szPrefix );
			continue;
		}
		
		else if( g_iGang[ iTemp ] != g_iGang[ id ] )
		continue;
		
		ColorChat( iTemp, NORMAL, "%s ^03%s^01 jest nowym liderem Twojego gangu", g_szPrefix, szName );
	}
	
	return PLUGIN_HANDLED;
}


public ShowKickMenu( id )
{
	new iPlayers[ 32 ], iNum;
	get_players( iPlayers, iNum );
	
	new hMenu = menu_create( "Wyrzuc z gangu", "KickMenu_Handler" );
	new szName[ 32 ], szData[ 6 ];
	
	
	for( new i = 0, iPlayer; i < iNum; i++ )
	{
		iPlayer = iPlayers[ i ];
		
		if( g_iGang[ iPlayer ] != g_iGang[ id ] || id == iPlayer )
		continue;
		
		get_user_name( iPlayer, szName, charsmax( szName ) );
		num_to_str( iPlayer, szData, charsmax( szData ) );
		
		menu_additem( hMenu, szName, szData );
	}
	
	menu_display( id, hMenu, 0 );
}

public KickMenu_Handler( id, hMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		ShowLeaderMenu( id );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, hCallback, szData[ 6 ], szName[ 32 ];
	
	menu_item_getinfo( hMenu, iItem, iAccess, szData, 5, szName, charsmax( szName ), hCallback );
	
	new iPlayer = str_to_num( szData );
	
	if( !is_user_connected( iPlayer ) )
	{
		ColorChat( id, NORMAL, "%s Ten gracz nie jest juz polaczony z serwerem.", g_szPrefix );
		ShowTransferMenu( id );
		return PLUGIN_HANDLED;
	}
	
	set_user_gang( iPlayer, -1 );
	
	Cmd_Gang( id );
	
	new iPlayers[ 32 ], iNum, iTemp;
	get_players( iPlayers, iNum );
	
	for( new i = 0; i < iNum; i++ )
	{
		iTemp = iPlayers[ i ];
		
		if( iTemp == iPlayer || g_iGang[ iTemp ] != g_iGang[ id ] )
		continue;
		
		ColorChat( iTemp, NORMAL, "%s ^03%s^01 zostal wyrzucony z gangu.", g_szPrefix, szName );
	}
	
	ColorChat( iPlayer, NORMAL, "%s Zostales usuniety z gangu.", g_szPrefix, szName );
	
	return PLUGIN_HANDLED;
}

public ChangeName_Handler( id )
{
	if( g_iGang[ id ] == -1 || getStatus( id, g_iGang[ id ] ) == STATUS_MEMBER )
	{
		return;
	}
	
	new iGang = g_iGang[ id ];
	
	new szArgs[ 64 ];
	read_args( szArgs, charsmax( szArgs ) );
	
	new iPlayers[ 32 ], iNum;
	get_players( iPlayers, iNum );
	
	new bool:bInGang[ 33 ];
	new iStatus[ 33 ];
	
	for( new i = 0, iPlayer; i < iNum; i++ )
	{
		iPlayer = iPlayers[ i ];
		
		if( g_iGang[ id ] != g_iGang[ iPlayer ] )
		continue;
		
		bInGang[ iPlayer ] = true;
		iStatus[ iPlayer ] = getStatus( id, iGang );
		
		set_user_gang( iPlayer, -1 );
	}
	
	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, iGang, aData );
	
	aData[ GangName ] = szArgs;
	
	ArraySetArray( g_aGangs, iGang, aData );
	
	for( new i = 0, iPlayer; i < iNum; i++ )
	{
		iPlayer = iPlayers[ i ];
		
		if( !bInGang[ iPlayer ] )
		continue;
		
		set_user_gang( iPlayer, iGang, iStatus[ id ] );
	}
}

public ShowAddAdminMenu( id )
{
	new iPlayers[ 32 ], iNum;
	new szName[ 32 ], szData[ 6 ];
	new hMenu = menu_create( "Wybierz gracza do awansu:", "AddAdminMenu_Handler" );
	
	get_players( iPlayers, iNum );
	
	for( new i = 0, iPlayer; i < iNum; i++ )
	{
		iPlayer = iPlayers[ i ];
		
		if( g_iGang[ id ] != g_iGang[ iPlayer ] || getStatus( iPlayer, g_iGang[ iPlayer ] ) > STATUS_MEMBER )
		continue;
		
		get_user_name( iPlayer, szName, charsmax( szName ) );
		
		num_to_str( iPlayer, szData, charsmax( szData ) );
		
		menu_additem( hMenu, szName, szData );
	}
	
	menu_display( id, hMenu, 0 );
}

public AddAdminMenu_Handler( id, hMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( hMenu );
		ShowLeaderMenu( id );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, hCallback, szData[ 6 ], szName[ 32 ];
	
	menu_item_getinfo( hMenu, iItem, iAccess, szData, charsmax( szData ), szName, charsmax( szName ), hCallback );
	
	new iChosen = str_to_num( szData );
	
	if( !is_user_connected( iChosen ) )
	{
		menu_destroy( hMenu );
		ShowLeaderMenu( id );
		return PLUGIN_HANDLED;
	}
	
	set_user_gang( iChosen, g_iGang[ id ], STATUS_ADMIN );
	
	new iPlayers[ 32 ], iNum;
	get_players( iPlayers, iNum );
	
	for( new i = 0, iPlayer; i < iNum; i++ )
	{
		iPlayer = iPlayers[ i ];
		
		if( g_iGang[ iPlayer ] != g_iGang[ id ] || iPlayer == iChosen )
		continue;
		
		ColorChat( iPlayer, NORMAL, "%s ^03%s ^01dostal awans na Oficera gangu.", g_szPrefix, szName );
	}
	
	ColorChat( iChosen, NORMAL, "%s ^01Dostales awans na Oficera gangu!", g_szPrefix );
	
	menu_destroy( hMenu );
	return PLUGIN_HANDLED;
}

public ShowRemoveAdminMenu( id )
{
	new iPlayers[ 32 ], iNum;
	new szName[ 32 ], szData[ 6 ];
	new hMenu = menu_create( "Wybierz gracza do degradacji:", "RemoveAdminMenu_Handler" );
	
	get_players( iPlayers, iNum );
	
	for( new i = 0, iPlayer; i < iNum; i++ )
	{
		iPlayer = iPlayers[ i ];
		
		if( g_iGang[ id ] != g_iGang[ iPlayer ] || getStatus( iPlayer, g_iGang[ iPlayer ] ) != STATUS_ADMIN )
		continue;
		
		get_user_name( iPlayer, szName, charsmax( szName ) );
		
		num_to_str( iPlayer, szData, charsmax( szData ) );
		
		menu_additem( hMenu, szName, szData );
	}
	
	menu_display( id, hMenu, 0 );
}

public RemoveAdminMenu_Handler( id, hMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( hMenu );
		ShowLeaderMenu( id );
		return PLUGIN_HANDLED;
	}
	
	new iAccess, hCallback, szData[ 6 ], szName[ 32 ];
	
	menu_item_getinfo( hMenu, iItem, iAccess, szData, charsmax( szData ), szName, charsmax( szName ), hCallback );
	
	new iChosen = str_to_num( szData );
	
	if( !is_user_connected( iChosen ) )
	{
		menu_destroy( hMenu );
		ShowLeaderMenu( id );
		return PLUGIN_HANDLED;
	}
	
	set_user_gang( iChosen, g_iGang[ id ], STATUS_MEMBER );
	
	new iPlayers[ 32 ], iNum;
	get_players( iPlayers, iNum );
	
	for( new i = 0, iPlayer; i < iNum; i++ )
	{
		iPlayer = iPlayers[ i ];
		
		if( g_iGang[ iPlayer ] != g_iGang[ id ] || iPlayer == iChosen )
		continue;
		
		ColorChat( iPlayer, NORMAL, "%s ^03%s ^01zostal zdegradowany z rangi Oficera gangu.", g_szPrefix, szName );
	}
	
	ColorChat( iChosen, NORMAL, "%s ^01Zostales zdegradowany z rangi Oficera ganu.", g_szPrefix );
	
	menu_destroy( hMenu );
	return PLUGIN_HANDLED;
}

public ShowMembersMenu( id )
{
	new szName[ 64 ], iPlayers[ 32 ], iNum;
	get_players( iPlayers, iNum );
	
	new hMenu = menu_create( "Gracze Online Twojej Gildii", "MemberMenu_Handler" );
	
	for( new i = 0, iPlayer; i < iNum; i++ )
	{
		iPlayer = iPlayers[ i ];
		
		if( g_iGang[ id ] != g_iGang[ iPlayer ] )
		continue;
		
		get_user_name( iPlayer, szName, charsmax( szName ) );
		
		switch( getStatus( iPlayer, g_iGang[ id ] ) )
		{
		case STATUS_MEMBER:
			{
				add( szName, charsmax( szName ), " \r[Czlonek]" );
			}
			
		case STATUS_ADMIN:
			{
				add( szName, charsmax( szName ), " \r[Oficer]" );
			}
			
		case STATUS_LEADER:
			{
				add( szName, charsmax( szName ), " \r[Lider]" );
			}
		}
		
		menu_additem( hMenu, szName );
	}
	
	menu_display( id, hMenu, 0 );
}

public MemberMenu_Handler( id, hMenu, iItem )
{
	if( iItem == MENU_EXIT )
	{
		menu_destroy( hMenu );
		Cmd_Gang( id );
		return PLUGIN_HANDLED;
	}
	
	menu_destroy( hMenu );
	
	ShowMembersMenu( id )
	return PLUGIN_HANDLED;
}

public Wplac(id){
	
	if(g_iGang[ id ] == -1)
	{
		ColorChat(id, NORMAL, "%s Nie mozesz wplacac EXP'a jesli nie jestes w Gildii", g_szPrefix);
		return PLUGIN_CONTINUE;
	}
	new args[256];
	read_args(args, charsmax(args));
	remove_quotes(args);
	
	new szCmd[15], szPoints[12];
	new player_exp = Poke_PlayerXP(id, -1)
	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, g_iGang[ id ], aData );
	
	new parsed = parse(args, szCmd, charsmax(szCmd), szPoints, charsmax(szPoints));
	if(parsed && equali(szCmd, "wplacexp")){
		if(parsed < 2){
			client_print(id, print_chat, "Uzycie: wplacexp <EXP>");
			return PLUGIN_HANDLED;
		}
		
		new iPoints = str_to_num(szPoints);
		
		if( player_exp < iPoints ){
			client_print(id, print_chat,"Nie masz wystarczajacej ilosc EXP'a");
			return PLUGIN_HANDLED;
		} 
		
		if( iPoints < 1 ) {
			client_print(id, print_chat,"Wplata musi byc wieksza od 0");
			return PLUGIN_HANDLED;
		}
		
		Poke_Give_XP(id, -1, -iPoints)
		aData[ GangEXP ] += iPoints;
		ArraySetArray( g_aGangs, g_iGang[ id ], aData );
		
		new iPlayers[ 32 ], iNum;
		get_players( iPlayers, iNum );
		
		for( new i = 0, iPlayer; i < iNum; i++ )
		{
			iPlayer = iPlayers[ i ];
			
			if( g_iGang[ id ] == g_iGang[ iPlayer ] && id != iPlayer)
			{
				new szNick[32];
				get_user_name(id, szNick, charsmax(szNick));
				
				client_print(id, print_chat,"Wplaciles %d EXP'a",iPoints);
				client_print(iPlayer, print_chat,"%s wplacil do Gildii %d EXP'a", szNick, iPoints);
			}
		}
		return PLUGIN_HANDLED;
	}
	return PLUGIN_CONTINUE;	
}
public SprawdzPoziom(id)
{	
	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, g_iGang[ id ], aData );
	if(aData[ GangLevel ] < 10)
	{
		while(aData[ GangEXP ] >= exp_poziomu[aData[ GangLevel ]])
		{
			aData[ GangLevel ]++;
			ArraySetArray( g_aGangs, g_iGang[ id ], aData );
			new iNum, iPlayers[32];
			for( new i = 0, iPlayer; i < iNum; i++ )
			{
				iPlayer = iPlayers[ i ];
				
				if( g_iGang[ id ] == g_iGang[ iPlayer ] )
				{
					set_hudmessage(60, 200, 25, -1.0, 0.25, 0, 1.0, 2.0, 0.1, 0.2, 2);
					ShowSyncHudMsg(iPlayer, CreateHudSyncObj(), "Twoja Gildia awansowala do nastepnego poziomu!");
				}
			}
		}
	}
	SaveGangs();
}

// Credits to Tirant from zombie mod and xOR from xRedirect
public LoadGangs()
{
	new szConfigsDir[ 60 ];
	get_configsdir( szConfigsDir, charsmax( szConfigsDir ) );
	add( szConfigsDir, charsmax( szConfigsDir ), "/jb_gangs.ini" );
	
	new iFile = fopen( szConfigsDir, "rt" );
	
	new aData[ GangInfo ];
	
	new szBuffer[ 512 ], szData[ 6 ], szValue[ 6 ], 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[ GangHP ] = 0;
			aData[ GangStealing ] = 0;
			aData[ GangGravity ] = 0;
			aData[ GangStamina ] = 0;
			aData[ GangWeaponDrop ] = 0;
			aData[ GangDamage ] = 0;
			aData[ GangKills ] = 0;
			aData[ GangEXP ] = 0;
			aData[ GangLevel ] = 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, 31, szValue, 511, '=' );
		trim( szData );
		trim( szValue );
		
		if( TrieGetCell( g_tGangValues, szData, i ) )
		{
			ArrayGetArray( g_aGangs, iCurGang - 1, aData );
			
			switch( i )
			{					
			case VALUE_HP:
				aData[ GangHP ] = str_to_num( szValue );
				
			case VALUE_STEALING:
				aData[ GangStealing ] = str_to_num( szValue );
				
			case VALUE_GRAVITY:
				aData[ GangGravity ] = str_to_num( szValue );
				
			case VALUE_STAMINA:
				aData[ GangStamina ] = str_to_num( szValue );
				
			case VALUE_WEAPONDROP:
				aData[ GangWeaponDrop ] = str_to_num( szValue );
				
			case VALUE_DAMAGE:
				aData[ GangDamage ] = str_to_num( szValue );
				
			case VALUE_KILLS:
				aData[ GangKills ] = str_to_num( szValue );
				
			case VALUE_EXP:
				aData[ GangEXP ] = str_to_num( szValue );
				
			case VALUE_LEVEL:
				aData[ GangLevel ] = 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[ 64 ];
	get_configsdir( szConfigsDir, charsmax( szConfigsDir ) );
	
	add( szConfigsDir, charsmax( szConfigsDir ), "/jb_gangs.ini" );
	
	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 ), "HP=%i^n", aData[ GangHP ] );
		fputs( iFile, szBuffer );
		
		formatex( szBuffer, charsmax( szBuffer ), "Stealing=%i^n", aData[ GangStealing ] );
		fputs( iFile, szBuffer );
		
		formatex( szBuffer, charsmax( szBuffer ), "Gravity=%i^n", aData[ GangGravity ] );
		fputs( iFile, szBuffer );
		
		formatex( szBuffer, charsmax( szBuffer ), "Stamina=%i^n", aData[ GangStamina ] );
		fputs( iFile, szBuffer );
		
		formatex( szBuffer, charsmax( szBuffer ), "WeaponDrop=%i^n", aData[ GangWeaponDrop ] );
		fputs( iFile, szBuffer );
		
		formatex( szBuffer, charsmax( szBuffer ), "Damage=%i^n", aData[ GangDamage ] );
		fputs( iFile, szBuffer );
		
		formatex( szBuffer, charsmax( szBuffer ), "Kills=%i^n^n", aData[ GangKills ] );
		fputs( iFile, szBuffer );
		
		formatex( szBuffer, charsmax( szBuffer ), "EXP=%i^n^n", aData[ GangEXP ] );
		fputs( iFile, szBuffer );
		
		formatex( szBuffer, charsmax( szBuffer ), "Level=%i^n^n", aData[ GangLevel ] );
		fputs( iFile, szBuffer );
	}
	
	fclose( iFile );
}



set_user_gang( id, iGang, iStatus=STATUS_MEMBER )
{
	new szAuthID[ 35 ];
	get_user_authid( 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 )
	{
		ArrayGetArray( g_aGangs, iGang, aData );
		TrieSetCell( aData[ GangMembers ], szAuthID, iStatus );
		aData[ NumMembers ]++;
		ArraySetArray( g_aGangs, iGang, aData );
		
		sqlv_set_num_ex( g_hVault, szAuthID, aData[ GangName ], iStatus );		
	}

	g_iGang[ id ] = iGang;

	return 1;
}

get_user_gang( id )
{
	new szAuthID[ 35 ];
	get_user_authid( id, szAuthID, charsmax( szAuthID ) );

	new aData[ GangInfo ];

	for( new i = 0; i < ArraySize( g_aGangs ); i++ )
	{
		ArrayGetArray( g_aGangs, i, aData );

		if( TrieKeyExists( aData[ GangMembers ], szAuthID ) )
		return i;
	}

	return -1;
}

getStatus( id, iGang )
{
	if( !is_user_connected( id ) || iGang == -1 )
	return STATUS_NONE;

	new aData[ GangInfo ];
	ArrayGetArray( g_aGangs, iGang, aData );

	new szAuthID[ 35 ];
	get_user_authid( id, szAuthID, charsmax( szAuthID ) );

	new iStatus;
	TrieGetCell( aData[ GangMembers ], szAuthID, iStatus );

	return iStatus;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
*/

Последна промяна от OciXCrom™ на пет апр 22, 2016 1:51 pm, променено общо 1 път. Причина: Преместена тема!
 #389244  от zolfeca
 вт май 03, 2016 12:34 pm
На мен не ми показва тази грешка, а това
(390) : error 017: undefined symbol "Poke_PlayerRank"
(444) : error 017: undefined symbol "Poke_PlayerRank"
Никъде не виждам такава дефиниция, дори из pokemod,pokemon/inl