Raised This Month: $2 Target: $400
 0% 

Plugin Crooshair


Post New Thread Reply   
 
Thread Tools Display Modes
AlinT
Junior Member
Join Date: Jun 2020
Location: Romania
Old 06-16-2020 , 09:12   Re: Plugin Crooshair
Reply With Quote #21

if you can please look in this plugin to see what blocks me from not being able to access the menu, I still have 1 plugin that also blocks it ... thank you very much

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <sqlx>
#include <fakemeta>
#include <fun>
#include <cstrike>
#include <hamsandwich>
#include <xs>

/* ColorChat Support */
#define NORMAL DontChange
#define GREEN DontChange
#define TEAM_COLOR DontChange
#define RED Red
#define BLUE Blue
#define GREY Grey
#define ColorChat client_print_color
/* ColorChat Support */

enum _:Colors {
    
DontChange,
    
Red,
    
Blue,
    
Grey
}

stock const g_szTeamName[Colors][] = 
{
    
"UNASSIGNED",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

stock client_print_color(idiColor=DontChange, const szMsg[], any:...)
{
    
// check if id is different from 0
    
if( id && !is_user_connected(id) )
    {
        return 
0;
    }

    if( 
iColor Grey )
    {
        
iColor DontChange;
    }

    new 
szMessage[192];
    if( 
iColor == DontChange )
    {
        
szMessage[0] = 0x04;
    }
    else
    {
        
szMessage[0] = 0x03;
    }

    new 
iParams numargs();
    
// Specific player code
    
if(id)
    {
        if( 
iParams == )
        {
            
copy(szMessage[1], charsmax(szMessage)-1szMsg);
        }
        else
        {
            
vformat(szMessage[1], charsmax(szMessage)-1szMsg4);
        }

        if( 
iColor )
        {
            new 
szTeam[11]; // store current team so we can restore it
            
get_user_team(idszTeamcharsmax(szTeam));

            
// set id TeamInfo in consequence
            // so SayText msg gonna show the right color
            
Send_TeamInfo(ididg_szTeamName[iColor]);

            
// Send the message
            
Send_SayText(ididszMessage);

            
// restore TeamInfo
            
Send_TeamInfo(ididszTeam);
        }
        else
        {
            
Send_SayText(ididszMessage);
        }
    } 

    
// Send message to all players
    
else
    {
        
// Figure out if at least 1 player is connected
        // so we don't send useless message if not
        // and we gonna use that player as team reference (aka SayText message sender) for color change
        
new iPlayers[32], iNum;
        
get_players(iPlayersiNum"ch");
        if( !
iNum )
        {
            return 
0;
        }

        new 
iFool iPlayers[0];

        new 
iMlNumberij;
        new Array:
aStoreML ArrayCreate();
        if( 
iParams >= // ML can be used
        
{
            for(
j=4j<iParamsj++)
            {
                
// retrieve original param value and check if it's LANG_PLAYER value
                
if( getarg(j) == LANG_PLAYER )
                {
                    
i=0;
                    
// as LANG_PLAYER == -1, check if next parm string is a registered language translation
                    
while( ( szMessage] = getarg1i++ ) ) ) {}
                    if( 
GetLangTransKey(szMessage) != TransKey_Bad )
                    {
                        
// Store that arg as LANG_PLAYER so we can alter it later
                        
ArrayPushCell(aStoreMLj++);

                        
// Update ML array saire so we'll know 1st if ML is used,
                        // 2nd how many args we have to alterate
                        
iMlNumber++;
                    }
                }
            }
        }

        
// If arraysize == 0, ML is not used
        // we can only send 1 MSG_BROADCAST message
        
if( !iMlNumber )
        {
            if( 
iParams == )
            {
                
copy(szMessage[1], charsmax(szMessage)-1szMsg);
            }
            else
            {
                
vformat(szMessage[1], charsmax(szMessage)-1szMsg4);
            }

            if( 
iColor )
            {
                new 
szTeam[11];
                
get_user_team(iFoolszTeamcharsmax(szTeam));
                
Send_TeamInfo(0iFoolg_szTeamName[iColor]);
                
Send_SayText(0iFoolszMessage);
                
Send_TeamInfo(0iFoolszTeam);
            }
            else
            {
                
Send_SayText(0iFoolszMessage);
            }
        }

        
// ML is used, we need to loop through all players,
        // format text and send a MSG_ONE_UNRELIABLE SayText message
        
else
        {
            new 
szTeam[11], szFakeTeam[10];
            
            if( 
iColor )
            {
                
get_user_team(iFoolszTeamcharsmax(szTeam));
                
copy(szFakeTeamcharsmax(szFakeTeam), g_szTeamName[iColor]);
            }

            for( 
0iNumi++ )
            {
                
id iPlayers[i];

                for(
j=0j<iMlNumberj++)
                {
                    
// Set all LANG_PLAYER args to player index ( = id )
                    // so we can format the text for that specific player
                    
setarg(ArrayGetCell(aStoreMLj), _id);
                }

                
// format string for specific player
                
vformat(szMessage[1], charsmax(szMessage)-1szMsg4);

                if( 
iColor )
                {
                    
Send_TeamInfo(idiFoolszFakeTeam);
                    
Send_SayText(idiFoolszMessage);
                    
Send_TeamInfo(idiFoolszTeam);
                }
                else
                {
                    
Send_SayText(idiFoolszMessage);
                }
            }
            
ArrayDestroy(aStoreML);
        }
    }
    return 
1;
}

stock Send_TeamInfo(iReceiveriPlayerIdszTeam[])
{
    static 
iTeamInfo 0;
    if( !
iTeamInfo )
    {
        
iTeamInfo get_user_msgid("TeamInfo");
    }
    
message_begin(iReceiver MSG_ONE_UNRELIABLE MSG_BROADCASTiTeamInfo, .player=iReceiver);
    
write_byte(iPlayerId);
    
write_string(szTeam);
    
message_end();
}

stock Send_SayText(iReceiveriPlayerIdszMessage[])
{
    static 
iSayText 0;
    if( !
iSayText )
    {
        
iSayText get_user_msgid("SayText");
    }
    
message_begin(iReceiver MSG_ONE_UNRELIABLE MSG_BROADCASTiSayText, .player=iReceiver);
    
write_byte(iPlayerId);
    
write_string(szMessage);
    
message_end();
}

stock register_dictionary_colored(const filename[])
{
    if( !
register_dictionary(filename) )
    {
        return 
0;
    }

    new 
szFileName[256];
    
get_localinfo("amxx_datadir"szFileNamecharsmax(szFileName));
    
format(szFileNamecharsmax(szFileName), "%s/lang/%s"szFileNamefilename);
    new 
fp fopen(szFileName"rt");
    if( !
fp )
    {
        
log_amx("Failed to open %s"szFileName);
        return 
0;
    }

    new 
szBuffer[512], szLang[3], szKey[64], szTranslation[256], TransKey:iKey;

    while( !
feof(fp) )
    {
        
fgets(fpszBuffercharsmax(szBuffer));
        
trim(szBuffer);

        if( 
szBuffer[0] == '[' )
        {
            
strtok(szBuffer[1], szLangcharsmax(szLang), szBuffer1']');
        }
        else if( 
szBuffer[0] )
        {
            
strbreak(szBufferszKeycharsmax(szKey), szTranslationcharsmax(szTranslation));
            
iKey GetLangTransKey(szKey);
            if( 
iKey != TransKey_Bad )
            {
                while( 
replace(szTranslationcharsmax(szTranslation), "!g""^4") ){}
                while( 
replace(szTranslationcharsmax(szTranslation), "!t""^3") ){}
                while( 
replace(szTranslationcharsmax(szTranslation), "!n""^1") ){}
                
AddTranslation(szLangiKeyszTranslation[2]);
            }
        }
    }
    
    
fclose(fp);
    return 
1;
}

new const 
PLUGIN[] = "Global Offensive";
new const 
VERSION[] = "2.15";
new const 
AUTHOR[] = "PepsiCo";
new const 
Prefix[] = "[CSGOPepsiCo]";

new 
SQL_Host[32], SQL_Database[32], SQL_User[32], SQL_Password[32];
new 
Handle:SQL_TUPLE;
new 
ServerLoaded;

new const 
SkinFolder[] = "deroidcsgo/";
new const 
DSkinFolder[] = "deroidcsgo/default/";

#define MAXP 32 + 1
#define MAXWP 120 + 1

#define MAXCASES 6
#define MAXKNIFESKINS 30 + 1
#define MAXTRADEINSAMETIME 5

#define RARE 4
#define COVERT 3
#define RESTRICTED 2
#define COMMON 1

#pragma semicolon 1

new Weapons[MAXP][MAXWP], SkinDataTrade[MAXWP][32], inUse[MAXP][4], Dollars[MAXP], Cases[MAXP][MAXCASES+1], Keys[MAXP], Name[MAXP][32],
TradeFounding[MAXP], inTrade[MAXP], TradeID[MAXP], TradePiece[MAXP], TradeItem[MAXP], TradeDollars[MAXP],
TradePartner[MAXP], Accept[MAXP], MarketDollar[MAXP], MarketItem[MAXP], InMarket[MAXP], bool:Logined[MAXP],
User[MAXP][32], Password[MAXP][32], Found[MAXP], UserLoad[MAXP], RegisterMod[MAXP], inProgress[MAXP],
UserID[MAXP], Activity[MAXP], Choosen[MAXP], CurrentRank[MAXP], Kills[MAXP];

new 
dSync;

new 
CvarHostCvarDatabaseCvarUserCvarPasswordCvarFoundCaseCvarFoundKeyCvarMinDollarDrop,
CvarMaxDollarDropCvarMinDollarMarketCvarMaxDollarMarketCvarSkinCheckCvarMenuButtonCvarWeaponMenuCvarGiveSmokeGrenade;
new 
MinDollarMarketMaxDollarMarketMinDollarDropMaxDollarDropFoundKeyChanceFoundCasesChanceGiveSmokeGrenade;
new 
PendingTradePTradeId[MAXP];

new const 
AnimationIDs[][] =
{
    { 
00},
    { 
60},
    { 
00},
    { 
00},
    { 
00},
    { 
00},
    { 
00},
    { 
00},
    { 
00},
    { 
00},
    { 
60},
    { 
00},
    { 
00},
    { 
00},
    { 
60},
    { 
60},
    { 
1617},
    { 
130},
    { 
60},
    { 
60},
    { 
00},
    { 
00},
    { 
1514},
    { 
00},
    { 
00},
    { 
00},
    { 
60},
    { 
00},
    { 
60},
    { 
80},
    { 
00},
    { 
00},
    { 
00}
};

new const 
DropData[][] = 
{
    { 
00000000000000000000000 },
    { 
00111213343536575850000 },
    { 
03141518373633545550000 },
    { 
18171611323032515050004 },
    { 
10212223444546676860008 },
    { 
13242528474643646560010 },
    { 
18272621424042616060020 }
};

new const 
DefaultModels[][][] = {
    { 
"""" },
    { 
"""" },
    { 
"""" },
    { 
"""" },
    { 
"HE.mdl""weapon_hegrenade" },
    { 
"""" },
    { 
"C4.mdl""weapon_c4" },
    { 
"""" },
    { 
"""" },
    { 
"""" },
    { 
"""" },
    { 
"""" },
    { 
"""" },
    { 
"""" },
    { 
"Galil.mdl""weapon_galil" },
    { 
"Famas.mdl""weapon_famas" },
    { 
"USP-S.mdl""weapon_usp" },
    { 
"Glock.mdl""weapon_glock18" },
    { 
"AWP.mdl""weapon_awp" },
    { 
"MP7.mdl""weapon_mp5navy" },
    { 
"""" },
    { 
"""" },
    { 
"M4A4.mdl""weapon_m4a1" },
    { 
"""" },
    { 
"""" },
    { 
"FLASH.mdl""weapon_flashbang" },
    { 
"Deagle.mdl""weapon_deagle" },
    { 
"""" },
    { 
"AK47.mdl""weapon_ak47" },
    { 
"Knife.mdl""weapon_knife" },
    { 
"""" },
    { 
"""" },
    { 
"""" }
};

new const 
RareData[][] = 
{
    
"",
    
"\d",
    
"\w",
    
"\r",
    
"\y"
};

new const 
SkinData[][][] = 
{
    { 
"Name""VMODEL""PMODEL"0},
    { 
"AK-47 | Outlaw""ak47/Outlaw"""CSW_AK47COMMON },
    { 
"AK-47 | Aquamarine Revenge""ak47/Aquamarine"""CSW_AK47COMMON },
    { 
"AK-47 | Jaguar""ak47/Jaguar"""CSW_AK47RESTRICTED },
    { 
"AK-47 | Vulcan""ak47/Vulcan"""CSW_AK47RESTRICTED },
    { 
"AK-47 | Wasteland Rebel""ak47/Wasteland"""CSW_AK47COVERT },
    { 
"AK-47 | Fireserpent""ak47/Fireserpent"""CSW_AK47COVERT },
    { 
"""AK47/"""CSW_AK47},
    { 
"""AK47/"""CSW_AK47},
    { 
"""AK47/"""CSW_AK47},
    { 
"""AK47/"""CSW_AK47},
    { 
"AWP | Worm God""awp/WormGod"""CSW_AWPCOMMON },
    { 
"AWP | Man'o'war""awp/Manowar"""CSW_AWPCOMMON },
    { 
"AWP | Redline""awp/Redline"""CSW_AWPRESTRICTED },
    { 
"AWP | Hyper Beast""awp/HBeast"""CSW_AWPRESTRICTED },
    { 
"AWP | Asiimov""awp/Asiimov"""CSW_AWPCOVERT },
    { 
"AWP | Dragon Lore""awp/DragonLore"""CSW_AWPCOVERT },
    { 
"""AWP/"""CSW_AWP},
    { 
"""AWP/"""CSW_AWP},
    { 
"""AWP/"""CSW_AWP},
    { 
"""AWP/"""CSW_AWP},
    { 
"M4A4 | Griffin""m4a1/Griffin"""CSW_M4A1COMMON },
    { 
"M4A4 | Bullet Rain""m4a1/BulletRain"""CSW_M4A1COMMON },
    { 
"M4A4 | Dragon King""m4a1/DragonKing"""CSW_M4A1RESTRICTED },
    { 
"M4A4 | Asiimov""m4a1/Asiimov"""CSW_M4A1RESTRICTED },
    { 
"M4A4 | Poseidon""m4a1/Poseidon"""CSW_M4A1COVERT },
    { 
"M4A4 | Howl""m4a1/Howl"""CSW_M4A1COVERT },
    { 
"""m4a4/"""CSW_M4A1},
    { 
"""m4a4/"""CSW_M4A1},
    { 
"""m4a4/"""CSW_M4A1},
    { 
"""m4a4/"""CSW_M4A1},
    { 
"FAMAS | Blue Way""famas/BlueWay"""CSW_FAMASCOMMON },
    { 
"FAMAS | Nuclear""famas/Nuclear"""CSW_FAMASCOMMON },
    { 
"FAMAS | Vanquish""famas/Vanquish"""CSW_FAMASRESTRICTED },
    { 
"FAMAS | Biohazard""famas/Biohazard"""CSW_FAMASRESTRICTED },
    { 
"FAMAS | Pulse""famas/Pulse"""CSW_FAMASCOVERT },
    { 
"FAMAS | Spitfire""famas/Spitfire"""CSW_FAMASCOVERT },
    { 
"""famas/"""CSW_FAMAS},
    { 
"""famas/"""CSW_FAMAS},
    { 
"""famas/"""CSW_FAMAS},
    { 
"""famas/"""CSW_FAMAS},
    { 
"GALIL-AR | Crimson Web""galil/CrimsonWeb"""CSW_GALILCOMMON },
    { 
"GALIL-AR | Blue Way""galil/BlueWay"""CSW_GALILCOMMON },
    { 
"GALIL-AR | Eco""galil/Eco"""CSW_GALILRESTRICTED },
    { 
"GALIL-AR | Odyssy""galil/Odyssy"""CSW_GALILRESTRICTED },
    { 
"GALIL-AR | Cerberus""galil/Cerberus"""CSW_GALILCOVERT },
    { 
"GALIL-AR | Chatterbox""galil/Chatterbox"""CSW_GALILCOVERT },
    { 
"""galil/"""CSW_GALIL},
    { 
"""galil/"""CSW_GALIL},
    { 
"""galil/"""CSW_GALIL},
    { 
"""galil/"""CSW_GALIL},
    { 
"MP7 | Blood""mp5/Blood"""CSW_MP5NAVYCOMMON },
    { 
"MP7 | Now Purple!""mp5/NowPurple"""CSW_MP5NAVYCOMMON },
    { 
"MP7 | Rising Sun""mp5/RisingSun"""CSW_MP5NAVYRESTRICTED },
    { 
"MP7 | Seaweed""mp5/Seaweed"""CSW_MP5NAVYRESTRICTED },
    { 
"MP7 | Carbonite""mp5/Carbonite"""CSW_MP5NAVYCOVERT },
    { 
"MP7 | Urbanhazard""mp5/UrbanHazard"""CSW_MP5NAVYCOVERT },
    { 
"""mp5/"""CSW_MP5NAVY},
    { 
"""mp5/"""CSW_MP5NAVY},
    { 
"""mp5/"""CSW_MP5NAVY},
    { 
"""mp5/"""CSW_MP5NAVY},
    { 
"USP-S | Stainless""usp/Stainless"""CSW_USPCOMMON },
    { 
"USP-S | Vertex""usp/Vertex"""CSW_USPCOMMON },
    { 
"USP-S | Caiman""usp/Caiman"""CSW_USPRESTRICTED },
    { 
"USP-S | Road Rash""usp/Rash"""CSW_USPRESTRICTED },
    { 
"USP-S | Orion""usp/Orion"""CSW_USPCOVERT },
    { 
"USP-S | Kill Confirmed""usp/KConfirmed"""CSW_USPCOVERT },
    { 
"""usp/"""CSW_USP},
    { 
"""usp/"""CSW_USP},
    { 
"""usp/"""CSW_USP},
    { 
"""usp/"""CSW_USP},
    { 
"DEAGLE | Engraved""deagle/Engraved"""CSW_DEAGLECOMMON },
    { 
"DEAGLE | Golden Rose""deagle/GoldenRose"""CSW_DEAGLECOMMON },
    { 
"DEAGLE | Biohazard""deagle/Biohazard"""CSW_DEAGLERESTRICTED },
    { 
"DEAGLE | Jungle""deagle/Jungle"""CSW_DEAGLERESTRICTED },
    { 
"DEAGLE | Hypnotic""deagle/Hypnotic"""CSW_DEAGLECOVERT },
    { 
"DEAGLE | Blaze""deagle/Blaze"""CSW_DEAGLECOVERT },
    { 
"""deagle/"""CSW_DEAGLE},
    { 
"""deagle/"""CSW_DEAGLE},
    { 
"""deagle/"""CSW_DEAGLE},
    { 
"""deagle/"""CSW_DEAGLE},
    { 
"GLOCK-18 | Candy Apple""glock/Candy"""CSW_GLOCK18COMMON },
    { 
"GLOCK-18 | Green Way""glock/GreenWay"""CSW_GLOCK18COMMON },
    { 
"GLOCK-18 | Catacombs""glock/Catacombs"""CSW_GLOCK18RESTRICTED },
    { 
"GLOCK-18 | Grinder""glock/Grinder"""CSW_GLOCK18RESTRICTED },
    { 
"GLOCK-18 | Water Elemental""glock/WaterElemental"""CSW_GLOCK18COVERT },
    { 
"GLOCK-18 | Fade""glock/Fade"""CSW_GLOCK18COVERT },
    { 
"""glock/"""CSW_GLOCK18},
    { 
"""glock/"""CSW_GLOCK18},
    { 
"""glock/"""CSW_GLOCK18},
    { 
"""glock/"""CSW_GLOCK18},
    { 
"Karambit | Doppler Ocean""knife/DopplerOcean_K"""CSW_KNIFERARE },
    { 
"Karambit | Doppler Pink""knife/DopplerPink_K"""CSW_KNIFERARE },
    { 
"Karambit | Crimson Web""knife/Crimson_K"""CSW_KNIFERARE },
    { 
"Butterfly Knife | Sea""knife/Sea_BF"""CSW_KNIFERARE },
    { 
"Butterfly Knife | Hawaiian""knife/Hawaiian_BF"""CSW_KNIFERARE },
    { 
"Butterfly Knife | Crimson Web""knife/Crimson_BF"""CSW_KNIFERARE },
    { 
"Bayonet M9 | Fade""knife/Fade_B"""CSW_KNIFERARE },
    { 
"Bayonet M9 | Doppler Sapphire""knife/Sapphire_B"""CSW_KNIFERARE },
    { 
"Bayonet | Space""knife/Space_B"""CSW_KNIFERARE },
    { 
"Gut Knife | Asiimov""knife/Asiimov_GUT"""CSW_KNIFERARE },
    { 
"Gut Knife | Doppler""knife/Doppler_GUT"""CSW_KNIFERARE },
    { 
"Gut Knife | Razer""knife/Razer_GUT"""CSW_KNIFERARE },
    { 
"Flip Knife | ROG""knife/ROG_FL"""CSW_KNIFERARE },
    { 
"Flip Knife | Fade""knife/Fade_FL"""CSW_KNIFERARE },
    { 
"Flip Knife | Marble Fade""knife/MarbleFade_FL"""CSW_KNIFERARE },
    { 
"Shadow Daggers""knife/Def_SD"""CSW_KNIFERARE },
    { 
"Shadow Daggers | Magma""knife/Magma_SD"""CSW_KNIFERARE },
    { 
"Shadow Daggers | Rainbow""knife/Rainbow_SD"""CSW_KNIFERARE },
    { 
"Falchion Knife | Orange""knife/Orange_F"""CSW_KNIFERARE },
    { 
"Falchion Knife | Diamond""knife/Diamond_F"""CSW_KNIFERARE },
    { 
"Falchion Knife""knife/Def_F"""CSW_KNIFERARE },
    { 
"Huntsman Knife | Fade""knife/Fade_HM"""CSW_KNIFERARE },
    { 
"Huntsman Knife | Crimson Web""knife/Crimson_HM"""CSW_KNIFERARE },
    { 
"Huntsman Knife | Slaughter""knife/Slaughter_HM"""CSW_KNIFERARE },
    { 
"""knife/"""CSW_KNIFE},
    { 
"""knife/"""CSW_KNIFE},
    { 
"""knife/"""CSW_KNIFE},
    { 
"""knife/"""CSW_KNIFE},
    { 
"""knife/"""CSW_KNIFE},
    { 
"""knife/"""CSW_KNIFE}
};

new const 
KeyName[] = "Key";

new const 
Case_Data[][][] = 
{
    { 
"Case Name""Found Num 0.1-100.0%" }, //Last must be 1
    
"Chroma Case"1000 }, //First must be 1000
    
"Chroma 2 Case"1025 },
    { 
"Chroma 3 Case"0380 },
    { 
"Gamma Case"0105 },
    { 
"Gamma 2 Case"0017 },
    { 
"Falcion Case"0009 }
};

new const 
FirstWeaponNames[][][] =
{
    { 
""""},
    { 
"AK47""weapon_ak47"CSW_AK47 },
    { 
"M4A4""weapon_m4a1"CSW_M4A1 },
    { 
"AWP""weapon_awp"CSW_AWP },
    { 
"FAMAS""weapon_famas"CSW_FAMAS },
    { 
"MP5""weapon_mp5navy"CSW_MP5NAVY },
    { 
"GALIL""weapon_galil"CSW_GALIL }
};

new const 
SecondaryWeaponNames[][][] =
{
    { 
""""},
    { 
"DEAGLE""weapon_deagle"CSW_DEAGLE },
    { 
"USP""weapon_usp"CSW_USP },
    { 
"GLOCK-18""weapon_glock18"CSW_GLOCK18 }
};

new const 
Ranks[][] =
{
    
"",
    
"Silver I",
    
"Silver II",
    
"Silver III",
    
"Silver IV",
    
"Silver Elite",
    
"Silver Elite Master",
    
"Gold Nova I",
    
"Gold Nova II",
    
"Gold Nova III",
    
"Gold Nova Master",
    
"Master Guardian I",
    
"Master Guardian II",
    
"Master Guardian Elite",
    
"Distinguished Master Guardian",
    
"Legendary Eagle",
    
"Legendary Eagle Master",
    
"Supreme Master First Class",
    
"The Global Elite",
    
""
};

new const 
RankKills[] =
{
    
0,
    
0,
    
25,
    
100,
    
250,
    
750,
    
1000,
    
1500,
    
2250,
    
3000,
    
3900,
    
4900,
    
5900,
    
7000,
    
8500,
    
10000,
    
15000,
    
22000,
    
30000,
    
40000,
    
0
};

public 
plugin_precache()
{
    new 
Mdl[96];
    
    for(new 
1sizeof(SkinData); i++)
    {
        if(
strlen(SkinData[i][0]) > 1)
        {
            
formatex(Mdlcharsmax(Mdl), "models/%s%s.mdl"SkinFolderSkinData[i][1]);
            
precache_model(Mdl);
        }
        
        if(
strlen(SkinData[i][2]) > 1)
        {
            
formatex(Mdlcharsmax(Mdl), "models/%s%s.mdl"SkinFolderSkinData[i][2]);
            
precache_model(Mdl);
        }
    }
    
    for(new 
1sizeof(DefaultModels); i++)
    {
        if(
strlen(DefaultModels[i][0]) > 1)
        {
            
formatex(Mdlcharsmax(Mdl), "models/%s%s"DSkinFolderDefaultModels[i][0]);
            
precache_model(Mdl);
        }
    }
}

public 
plugin_end()
{
    
SQL_FreeHandle(SQL_TUPLE);
}

public 
plugin_init()
{
    for(new 
iMAXWPi++)
    {
        
copy(SkinDataTrade[i], 31SkinData[i][0]);
    }
    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_cvar(PLUGINVERSIONFCVAR_SERVER);
    
register_dictionary("csgov2.txt");
    
    
CvarHost register_cvar("csgo_host""sql2.freesqldatabase.com");
    
CvarDatabase register_cvar("csgo_db""");
    
CvarUser register_cvar("csgo_user""");
    
CvarPassword register_cvar("csgo_pw""");
    
    
get_pcvar_string(CvarHostSQL_Hostcharsmax(SQL_Host));
    
get_pcvar_string(CvarDatabaseSQL_Databasecharsmax(SQL_Database));
    
get_pcvar_string(CvarUserSQL_Usercharsmax(SQL_User));
    
get_pcvar_string(CvarPasswordSQL_Passwordcharsmax(SQL_Password));

    
CvarFoundCase register_cvar("csgo_casefound""20");
    
CvarFoundKey register_cvar("csgo_keyfound""15");
    
CvarMinDollarDrop register_cvar("csgo_minddrop""1");
    
CvarMaxDollarDrop register_cvar("csgo_maxddrop""3");
    
CvarMinDollarMarket register_cvar("csgo_minmarketd""10");
    
CvarMaxDollarMarket register_cvar("csgo_maxmarketd""1000000");
    
CvarSkinCheck register_cvar("csgo_scheck""1");
    
CvarMenuButton register_cvar("csgo_mbutton""1");
    
CvarWeaponMenu register_cvar("csgo_wpmenu""0");
    
CvarGiveSmokeGrenade register_cvar("csgo_givesg""1");
    
    
FoundCasesChance get_pcvar_num(CvarFoundCase);
    
FoundKeyChance get_pcvar_num(CvarFoundKey);
    
MinDollarDrop get_pcvar_num(CvarMinDollarDrop);
    
MaxDollarDrop get_pcvar_num(CvarMaxDollarDrop);
    
MinDollarMarket get_pcvar_num(CvarMinDollarMarket);
    
MaxDollarMarket get_pcvar_num(CvarMaxDollarMarket);
    
FoundCasesChance get_pcvar_num(CvarFoundCase);
    
GiveSmokeGrenade get_pcvar_num(CvarGiveSmokeGrenade);
    
    
register_concmd("TRADEPIECE""cmdPiece");
    
register_concmd("TRADEDOLLARS""cmdDollarT");
    
register_concmd("MARKETDOLLAR""cmdDollarM");
    
register_concmd("MY_USERNAME""cmdUser");
    
register_concmd("MY_PASSWORD""cmdPassword");
    
    
register_clcmd("say /menu""MainMenu");
    
    if(
get_pcvar_num(CvarSkinCheck) == 1)
        
register_impulse(100"SkinCheck");
        
    if(
get_pcvar_num(CvarMenuButton) == 1)
        
register_impulse(201"MainMenu");
        
    
register_event("DeathMsg""Death""a");
    
    
dSync CreateHudSyncObj();
    
    for(new 
1sizeof(DefaultModels); i++)
    {
        if(
strlen(DefaultModels[i][1]) > 0)
        {
            
RegisterHam(Ham_Item_DeployDefaultModels[i][1], "WeaponSkin"1);
        }
    }
    
    
RegisterHam(Ham_Spawn"player""PlayerSpawn"1);
    
    if(
get_pcvar_num(CvarWeaponMenu) == 1)
    {
        
register_message(get_user_msgid("StatusIcon"), "msgStatusIcon");
        
register_clcmd("say /guns""Guns");
        
register_clcmd("say guns""Guns");
    }
    
    
register_clcmd("say""HandleSay");
    
    
set_task(55.0"Message"20170309__"b");
    
    
SQL_FirstLoad() ;
}

public 
msgStatusIcon(msgidmsgdestid

    static 
szIcon[8]; 
    
get_msg_arg_string(2szIcon7); 
    
    if(
equal(szIcon"buyzone") && get_msg_arg_int(1)) 
    { 
        
set_pdata_int(id235get_pdata_int(id235) & ~(1<<0)); 
        return 
PLUGIN_HANDLED
    }
    
    return 
PLUGIN_CONTINUE
}

public 
Message() 
{
    for(new 
iMAXPi++)
        if(
is_user_connected(i))
            
print_color(i"!g%s!y %L"Prefixi"SVMESSAGE");
}

public 
HandleSay(id)
{
    new 
Message[192], None[2][32], Chat[192], Alive[16];
    
    
read_args(Message191);
    
remove_quotes(Message);

    
formatex(None[0], 31"");
    
formatex(None[1], 31" ");
    
    if(
Message[0] == '@' || Message[0] == '!' || equal (Message""))
        return 
PLUGIN_HANDLED;
    
    if(!
is_user_alive(id))
        
Alive "*DEATH* ";
    else
        
Alive "";
        
    if(!
equali(MessageNone[0]) && !equali(MessageNone[1]))
    {
        if(
Logined[id])
        {
            
formatex(Chat191"^1%s^4[%s] ^3%s^1 : %s"AliveRanks[CurrentRank[id]], Name[id], Message);
        }
        else
        {
            
formatex(Chat191"^1%s^4[Unranked] ^3%s^1 : %s"AliveName[id], Message);
        }
        
        switch(
cs_get_user_team(id))
        {
            case 
CS_TEAM_TColorChat(0REDChat);
            case 
CS_TEAM_CTColorChat(0BLUEChat);
            case 
CS_TEAM_SPECTATORColorChat(0GREYChat);
        }
        
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_HANDLED;
}

public 
Death()
{
    new 
id read_data(1);
    new 
read_data(2);
    
    if(
id == || id == || == || !Logined[id])
    {
        return;
    }
    
    new 
DollarDrop random_num(MinDollarDropMaxDollarDrop);
    
    
Dollars[id] += DollarDrop;
    
    
set_hudmessage(02550, -1.000.8506.02.0);
    
ShowSyncHudMsg(iddSync"+%d$"x);
    
    new 
Drop random_num(1100);
    
    if(
FoundCasesChance >= Drop)
    {
        
DropCase(id);
    }
    else if(
FoundCasesChance+FoundKeyChance >= Drop)
    {
        for(new 
iMAXPi++)
            if(
is_user_connected(i))
                
print_color(i"!g%s!y %L"Prefixi"FOUND"Name[id], KeyName);
        
Keys[id]++;
    }
    
    
Kills[id]++;
    
    if(
RankKills[CurrentRank[id]+1] <= Kills[id] && RankKills[CurrentRank[id]+1] != 0)
    {
        
CurrentRank[id]++;
        
print_color(id"!g%s!y %L"Prefixid"RANKNEWLV"Ranks[CurrentRank[id]]);
    }
        
    
SQL_UpdateUser(id);
}

public 
DropCase(id)
{
    new 
RandomNum;
    
RandomNum random(1001);
    
    for(new 
1sizeof(Case_Data); i++)
    {
        if(
Case_Data[i][1][0] <= RandomNum)
        {
            for(new 
xMAXPx++)
                if(
is_user_connected(x))
                    
print_color(x"!g%s!y %L"Prefixx"FOUND"Name[id], Case_Data[i][0]);
                    
            
Cases[id][i]++;
            break;
        }
    }
    
    
SQL_UpdateUser(id);
}

public 
SkinDrop(idCaseNum)
{
    new 
RandomNum random_num(11000);
    
    if(
DropData[CaseNum][10] >= RandomNum && DropData[CaseNum][0] == 1)
    {
        new 
RandomKnife random_num(9190+MAXKNIFESKINS-1);
        
Weapons[id][RandomKnife]++;
        
        for(new 
iMAXPi++)
            if(
is_user_connected(i))
                
print_color(i"!g%s!y %L"Prefixi"UNBOXING"Name[id], SkinData[RandomKnife][0]);
    }
    else
    {
        new 
RandomNums[2], DroppedSkin;
        
RandomNum random_num(110);
        
        if(
RandomNum == 1)
        {
            
RandomNums[0] = 7RandomNums[1] = 9;
        }
        else if(
RandomNum <= 4)
        {
            
RandomNums[0] = 4RandomNums[1] = 6;
        }
        else if(
RandomNum <= 10)
        {
            
RandomNums[0] = 1RandomNums[1] = 3;
        }
        
        
DroppedSkin DropData[CaseNum][random_num(RandomNums[0], RandomNums[1])];
        
        
Weapons[id][DroppedSkin]++;
        
        for(new 
iMAXPi++)
            if(
is_user_connected(i))
                
print_color(i"!g%s!y %L"Prefixi"UNBOXING"Name[id], SkinData[DroppedSkin][0]);
    }
    
    
SQL_UpdateUser(id);
}

public 
WeaponSkin(f)
{
    new 
id get_pdata_cbase(f414);
    new 
wid cs_get_weapon_id(f);
    
    if(
id 32 || id || !is_user_alive(id))
    {
        return 
HAM_SUPERCEDE;
    }
    
    new 
AnimationIDs[wid][2], Mdl[86];
    
    if(
inUse[id][k] > && SkinData[inUse[id][k]][3][0] == wid && Weapons[id][inUse[id][k]] > 0)
    {
        
formatex(Mdlcharsmax(Mdl), "models/%s%s.mdl"SkinFolderSkinData[inUse[id][k]][1]);
        
set_pev(idpev_viewmodel2Mdl);
        
        if(
strlen(SkinData[inUse[id][k]][2]) > 0)
        {
            
formatex(Mdlcharsmax(Mdl), "models/%s%s.mdl"SkinFolderSkinData[inUse[id][k]][2]);
            
set_pev(idpev_weaponmodel2Mdl);
        }
    }
    else
    {
        
formatex(Mdlcharsmax(Mdl), "models/%s%s"DSkinFolderDefaultModels[wid][0]);
        
set_pev(idpev_viewmodel2Mdl);
    }
    
    return 
HAM_IGNORED;
}

public 
MainMenu(id)
{
    if(!
Logined[id])
    {
        
RegMenu(id);
        return;
    }
    
    new 
String[128];
    
formatex(Stringcharsmax(String), "%L"id"MAINMENU"Dollars[id]);
    new 
Menu menu_create(String"MainMenuh");
    
    
formatex(Stringcharsmax(String), "%L"id"INVENTORY");
    
menu_additem(MenuString"1");
    
    
formatex(Stringcharsmax(String), "%L"id"CASEOPEN");
    
menu_additem(MenuString"2");
    
    
formatex(Stringcharsmax(String), "%L"id"TRADE");
    
menu_additem(MenuString"3");
    
    
formatex(Stringcharsmax(String), "%L^n"id"MARKET");
    
menu_additem(MenuString"4");
    
    if(
RankKills[CurrentRank[id]+1] != 0)
    {
        
formatex(Stringcharsmax(String), "%L%L"id"TRASH"id"RANKMENU",
        
Ranks[CurrentRank[id]], Kills[id], RankKills[CurrentRank[id]+1], Ranks[CurrentRank[id]+1]);
    }
    else
    {
        
formatex(Stringcharsmax(String), "%L%L"id"TRASH"id"RANKMENUMAX",
        
Ranks[CurrentRank[id]], Kills[id]);
    }
    
menu_additem(MenuString"5");
    
    
menu_display(idMenu);
}

public 
MainMenuh(idMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(Menu);
        return;
    }
    
    new 
Data[14], Line[32];
    new 
AccessCallback;
    
menu_item_getinfo(MenuItemAccessDatacharsmax(Data), Linecharsmax(Line), Callback);
    
    new 
str_to_num(Data);
    
    switch(
x)
    {
        case 
: {
            
Inventory(id);
        }
        
        case 
: {
            
CaseMenu(id);
            
            if(
MarketItem[id] > || TradeItem[id] > || inTrade[id] > 0)
            {
                
print_color(id"!g%s!y %L"Prefixid"TMMESSAGE");
                
DeleteTradeandMarket(id);
            }
        }
        
        case 
: {
            if(
PendingTrade MAXTRADEINSAMETIME && PTradeId[id] == 0)
            {
                
print_color(id"!g%s!y %L"Prefixid"BLOCKTRADE");
                return;
            }
            
            
TradeMenu(id);
            
            if(
MarketItem[id] > 0)
            {
                
print_color(id"!g%s!y %L"Prefixid"TMMESSAGE");
                
DeleteTradeandMarket(id);
            }
        }
        
        case 
: {
            
MMarketMenu(id);
            
            if(
TradeItem[id] > || inTrade[id] > 0)
            {
                
print_color(id"!g%s!y %L"Prefixid"TMMESSAGE");
                
DeleteTradeandMarket(id);
            }
        }
        
        case 
: {
            
TrashMenu(id);
            
            if(
MarketItem[id] > || TradeItem[id] > || inTrade[id] > 0)
            {
                
print_color(id"!g%s!y %L"Prefixid"TMMESSAGE");
                
DeleteTradeandMarket(id);
            }
        }
    }
}

public 
CaseMenu(id)
{
    new 
String[128];
    
formatex(Stringcharsmax(String), "%L"id"CASEOPENM"Keys[id]);
    new 
Menu menu_create(String"CaseMenuh");
    
    for(new 
1sizeof(Case_Data); i++)
    {
        new 
NumToString[6];
        
num_to_str(iNumToString5);
        
formatex(Stringcharsmax(String), "%s \r(%d)"Case_Data[i][0], Cases[id][i]);
        
menu_additem(MenuStringNumToString);
    }
    
    
menu_display(idMenu);
}

public 
CaseMenuh(idMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(Menu);
        return;
    }
    
    new 
Data[14], Line[32];
    new 
AccessCallback;
    
menu_item_getinfo(MenuItemAccessDatacharsmax(Data), Linecharsmax(Line), Callback);
    
    new 
str_to_num(Data);
    
    if(
Cases[id][x] > && Keys[id] > 0)
    {
        
Keys[id]--;
        
Cases[id][x]--;
        
SkinDrop(idx);
    }
    else if(
Keys[id] == 0)
    {
        
print_color(id"!g%s!y %L"Prefixid"NOTENOUGHK");
    }
    else
    {
        
print_color(id"!g%s!y %L"Prefixid"NOTENOUGHC");
    }
    
    
CaseMenu(id);
}

public 
TrashMenu(id)
{
    new 
String[128];
    
formatex(Stringcharsmax(String), "%L"id"TRASH");
    new 
Menu menu_create(String"TrashMenuh");
    
    for(new 
1sizeof(SkinData); i++)
    {
        if(
Weapons[id][i] > && strlen(SkinData[i][0]) > 1)
        {
            new 
NumToString[6];
            
num_to_str(iNumToString5);
            
            if(
SkinData[i][3][0] != CSW_KNIFE)
                
formatex(Stringcharsmax(String), "%s%s \y(%d)"RareData[SkinData[i][4][0]], SkinData[i][0], Weapons[id][i]);
            else
                
formatex(Stringcharsmax(String), "%s%s \w(%d)"RareData[SkinData[i][4][0]], SkinData[i][0], Weapons[id][i]);
            
menu_additem(MenuStringNumToString);
        }
    }
    
    
menu_display(idMenu);
}

public 
TrashMenuh(idMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(Menu);
        return;
    }
    
    new 
Data[14], Line[32];
    new 
AccessCallback;
    
menu_item_getinfo(MenuItemAccessDatacharsmax(Data), Linecharsmax(Line), Callback);
    new 
str_to_num(Data);
    
    
Weapons[id][x]--;
    
TrashMenu(id);
    
SQL_UpdateUser(id);
}

public 
Inventory(id)
{
    new 
String[128];
    
formatex(Stringcharsmax(String), "%L"id"INVENTORY");
    new 
Menu menu_create(String"Inventoryh");
    
    for(new 
1sizeof(SkinData); i++)
    {
        if(
Weapons[id][i] > && strlen(SkinData[i][0]) > 1)
        {
            new 
NumToString[6];
            
num_to_str(iNumToString5);
            
            if(
SkinData[i][3][0] != CSW_KNIFE)
                
formatex(Stringcharsmax(String), "%s%s \y(%d)"RareData[SkinData[i][4][0]], SkinDataTrade[i], Weapons[id][i]);
            else
                
formatex(Stringcharsmax(String), "%s%s \w(%d)"RareData[SkinData[i][4][0]], SkinDataTrade[i], Weapons[id][i]);
            
menu_additem(MenuStringNumToString);
        }
    }
    
    
menu_display(idMenu);
}

public 
Inventoryh(idMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(Menu);
        return;
    }
    
    new 
Data[14], Line[32];
    new 
AccessCallback;
    
menu_item_getinfo(MenuItemAccessDatacharsmax(Data), Linecharsmax(Line), Callback);
    new 
str_to_num(Data);
    
    if(
SkinData[x][3][0] == 16 || SkinData[x][3][0] == 17 || SkinData[x][3][0] == 26)
    {
        
inUse[id][2] = x;
    }
    else if(
SkinData[x][3][0] == 29)
    {
        
inUse[id][3] = x;
    }
    else
    {
        
inUse[id][1] = x;
    }
}

public 
SkinCheck(id)
{
    if(!
is_user_alive(id))
        return 
PLUGIN_HANDLED;
    
    new 
SilWPName[32];
    
formatex(WPNamecharsmax(WPName), DefaultModels[get_user_weapon(id)][1]);
    new 
WPN find_ent_by_owner(-1DefaultModels[get_user_weapon(id)][1], id);
    
    if(
get_user_weapon(id) == CSW_M4A1 || get_user_weapon(id) == CSW_USP)
        
Sil cs_get_weapon_silen(WPN);
        
    if(
get_user_weapon(id) == CSW_AWP)
        
cs_set_user_zoom(id00);
    
    
PlayAnimation(idAnimationIDs[get_user_weapon(id)][Sil]);

    return 
PLUGIN_HANDLED;
}

public 
TradeMenu(id)
{
    if(
TradePiece[id] == 0)
    {
        
TradePiece[id] = 1;
    }
    
    new 
String[128], kidMenu;
    
    if(
TradePartner[id] > 0)
        
kid TradePartner[id];
    else
        
kid TradeID[id];

    if(
TradeFounding[id] == 1)
    {
        
formatex(Stringcharsmax(String), "%L"id"WANTTRADE"Name[kid]);
    }
    else if(
inTrade[id] == && inTrade[kid] == 1)
    {
        
formatex(Stringcharsmax(String), "%L"id"TRADEITEMS"Name[kid]);
    }
    else 
    {
        
formatex(Stringcharsmax(String), "%L"id"TRADEDOLLAR"Dollars[id]);
    }
    
    
Menu menu_create(String"TradeMenuh");
    
    if(
TradeFounding[id] == 1)
    {
        
formatex(Stringcharsmax(String), "%L"id"TRADEACCEPT");
        
menu_additem(MenuString"-3");
        
        
formatex(Stringcharsmax(String), "%L"id"TRADEREJECT");
        
menu_additem(MenuString"-2");
    }
    else if(
inTrade[id] == && inTrade[kid] == 1)
    {
        if(
TradeItem[kid] == 0)
        {
            
formatex(Stringcharsmax(String), "%L"id"TRADENOTHING");
        }
        else if(
TradeItem[kid] > && TradeItem[kid] <= 90+MAXKNIFESKINS)
        {
            
formatex(Stringcharsmax(String), "%L"id"TRADEITEM"SkinDataTrade[TradeItem[kid]], TradePiece[kid]);
        }
        else if(
TradeItem[kid] > 90+MAXKNIFESKINS && TradeItem[kid] <= 90+MAXKNIFESKINS+MAXCASES)
        {
            
formatex(Stringcharsmax(String), "%L"id"TRADEITEM"Case_Data[TradeItem[kid]-(90+MAXKNIFESKINS)][0], TradePiece[kid]);
        }
        else
        {
            
formatex(Stringcharsmax(String), "%L"id"TRADEITEM"KeyNameTradePiece[kid]);
        }
            
        
menu_additem(MenuString"0");
        
        
formatex(Stringcharsmax(String), "%L"id"TRADEYOURITEMS"TradeDollars[kid]);
        
menu_additem(MenuString"0");
        
        if(
TradeItem[id] == 0)
        {
            
formatex(Stringcharsmax(String), "%L"id"TRADENOTHING");
        }
        else if(
TradeItem[id] > && TradeItem[id] <= 90+MAXKNIFESKINS)
        {
            
formatex(Stringcharsmax(String), "%L"id"TRADEITEM"SkinDataTrade[TradeItem[id]], TradePiece[id]);
        }
        else if(
TradeItem[id] > 90+MAXKNIFESKINS && TradeItem[id] <= 90+MAXKNIFESKINS+MAXCASES)
        {
            
formatex(Stringcharsmax(String), "%L"id"TRADEITEM"Case_Data[TradeItem[id]-(90+MAXKNIFESKINS)][0], TradePiece[id]);
        }
        else
        {
            
formatex(Stringcharsmax(String), "%L"id"TRADEITEM"KeyNameTradePiece[id]);
        }
        
menu_additem(MenuString"-4");
        
        
formatex(Stringcharsmax(String), "%L"id"TRADEDOLLAR2"TradeDollars[id]);
        
menu_additem(MenuString"-5");
        
        
formatex(Stringcharsmax(String), "%L"id"TRADEACCEPT");
        
menu_additem(MenuString"-6");
        
        
formatex(Stringcharsmax(String), "%L"id"TRADEREJECT");
        
menu_additem(MenuString"-7");
    }
    else if(
TradeID[id] == 0)
    {
        for(new 
iMAXPi++)
        {
            new 
NumToStr[6];
            if(
is_user_connected(i))
            {
                if(
== id || is_user_bot(i))
                    continue;
                    
                if(
TradeFounding[i] == && inTrade[i] == 0)
                {
                    
num_to_str(iNumToStr5);
                    
formatex(Stringcharsmax(String), "%s"Name[i]);
                    
menu_additem(MenuStringNumToStr);
                }
            }
        }
    }
    else if(
TradeID[id] > 0)
    {
        
print_color(id"!g%s!y %L"Prefixid"DONTACCEPTEDTRADE");
        return;
    }

    
menu_display(idMenu);
}
public 
TradeMenuh(idMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(Menu);
        return;
    }
    
    new 
Data[14], Line[32];
    new 
AccessCallback;
    
menu_item_getinfo(MenuItemAccessDatacharsmax(Data), Linecharsmax(Line), Callback);
    
    new 
str_to_num(Data);
    
    if(
<= 0)
    {
        switch(
x)
        {
            case 
TradeMenu(id);
            
            case -
: {
                if(
PendingTrade MAXTRADEINSAMETIME)
                {
                    
print_color(id"!g%s!y %L"Prefixid"BLOCKTRADE");
                    return;
                }
                
                
TradeFounding[id] = 0;
                
inTrade[id] = 1;
                new 
kid;
                if(
TradePartner[id] > 0)
                    
kid TradePartner[id];
                else
                    
kid TradeID[id];
                
inTrade[kid] = 1;
                
TradePiece[id] = 0;
                
TradePiece[kid] = 0;
                
PTradeId[id] = 1;
                
PTradeId[kid] = 1;
                
TradeMenu(id);
                
TradeMenu(kid);
                
PendingTrade++;
            }
            
            case -
: {
                new 
kid;
                if(
TradePartner[id] > 0)
                    
kid TradePartner[id];
                else
                    
kid TradeID[id];
                
inTrade[id] = 0;
                
TradePartner[id] = 0;
                
TradeFounding[id] = 0;
                
inTrade[kid] = 0;
                
TradeID[kid] = 0;
                
TradeID[id] = 0;
            }
            
            case -
: {
                
TChooseItem(id);
            }
            
            case -
: {
                
client_cmd(id"messagemode TRADEDOLLARS");
            }
            
            case -
: {
                new 
kid;
                
                if(
TradePartner[id] > 0)
                    
kid TradePartner[id];
                else
                    
kid TradeID[id];
                    
                
Accept[id] = 1;
                
                if(
Accept[id] == && Accept[kid] == 1)
                {
                    
Trade(idkid);
                }
                else
                {
                    
MainMenu(id);
                }
            }
            
            case -
: {
                new 
kid;
                if(
TradePartner[id] > 0)
                    
kid TradePartner[id];
                else
                    
kid TradeID[id];
                
                
inTrade[id] = 0;
                
TradePartner[id] = 0;
                
TradeFounding[id] = 0;
                
TradeID[id] = 0;
                
inTrade[kid] = 0;
                
TradePartner[kid] = 0;
                
TradeFounding[kid] = 0;
                
TradeID[kid] = 0;
                
PTradeId[id] = 0;
                
PTradeId[kid] = 0;
                
PendingTrade--;
            }
        }
    }
    else
    {
        if(
PendingTrade MAXTRADEINSAMETIME && PTradeId[id] == 0)
        {
            
print_color(id"!g%s!y %L"Prefixid"BLOCKTRADE");
            return;
        }
            
        
TradeID[id] = x;
        
print_color(x"!g%s!y %L"Prefixx"WANTTRADE2"Name[id]);
        
TradeFounding[x] = 1;
        
TradeFounding[id] = 0;
        
inTrade[id] = 1;
        
TradePartner[x] = id;
        
remove_task(TradeID[id]+9929);
        
set_task(30.0"DeleteTrade"TradeID[id]+9929);
    }
}

public 
DeleteTrade(id
{
    
id id 9929;
    if(
Logined[id])
    {
        if(
inTrade[id] == 0)
        {
            
inTrade[id] = 0;
            
TradePartner[id] = 0;
            
TradeFounding[id] = 0;
        }
    }
}

public 
Trade(xy) {
    if(
Logined[x] && Logined[y] ||
    
inTrade[x] == && inTrade[y] == 1  ||
    
Accept[x] == && Accept[y] == 1)
    {
        
PendingTrade--;
        
        if(
TradeItem[x] > && TradeItem[x] <= 90+MAXKNIFESKINS)
        {
            
Weapons[y][TradeItem[x]] += TradePiece[x];
            
Weapons[x][TradeItem[x]] -= TradePiece[x];
        }
        else if(
TradeItem[x] > 90+MAXKNIFESKINS && TradeItem[x] <= 90+MAXKNIFESKINS+MAXCASES)
        {
            
Cases[y][TradeItem[x]-(90+MAXKNIFESKINS)] += TradePiece[x];
            
Cases[x][TradeItem[x]-(90+MAXKNIFESKINS)] -= TradePiece[x];
        }
        else if(
TradeItem[x] > 0)
        {
            
Keys[y] += TradePiece[x];
            
Keys[x] -= TradePiece[x];
        }
        
        if(
TradeItem[y] > && TradeItem[y] <= 90+MAXKNIFESKINS)
        {
            
Weapons[y][TradeItem[y]] -= TradePiece[y];
            
Weapons[x][TradeItem[y]] += TradePiece[y];
        }
        else if(
TradeItem[y] > 90+MAXKNIFESKINS && TradeItem[y] <= 90+MAXKNIFESKINS+MAXCASES)
        {
            
Cases[y][TradeItem[y]-(90+MAXKNIFESKINS)] -= TradePiece[y];
            
Cases[x][TradeItem[y]-(90+MAXKNIFESKINS)] += TradePiece[y];
        }
        else if(
TradeItem[y] > 0)
        {
            
Keys[y] -= TradePiece[y];
            
Keys[x] += TradePiece[y];
        }
        
        
Dollars[x] += TradeDollars[y];
        
Dollars[y] += TradeDollars[x];
        
Dollars[x] -= TradeDollars[x];
        
Dollars[y] -= TradeDollars[y];
        
        
print_color(x"!g%s!y %L"Prefixx"SUCCESSTRADE");
        
print_color(y"!g%s!y %L"Prefixy"SUCCESSTRADE");
        
        
DeleteTradeandMarket(x);
        
DeleteTradeandMarket(y);
        
        
show_menu(x0"^n"1);
        
show_menu(y0"^n"1);
        
        
set_task(0.5"SQL_UpdateUser"x);
        
set_task(0.5"SQL_UpdateUser"y);
        
        
PTradeId[x] = 0;
        
PTradeId[y] = 0;
    }    
}

public 
TChooseItem(id)
{
    new 
String[128];
    
formatex(Stringcharsmax(String), "%L"id"CHOOSEITEM");
    new 
Menu menu_create(String"TChooseItemh");
    
    for(new 
1sizeof(SkinData); i++)
    {
        if(
Weapons[id][i] > && strlen(SkinDataTrade[i]) > 1)
        {
            new 
NumToString[6];
            
num_to_str(iNumToString5);
            
            if(
SkinData[i][3][0] != CSW_KNIFE)
                
formatex(Stringcharsmax(String), "%s%s \y(%d)"RareData[SkinData[i][4][0]], SkinDataTrade[i], Weapons[id][i]);
            else
                
formatex(Stringcharsmax(String), "%s%s \w(%d)"RareData[SkinData[i][4][0]], SkinDataTrade[i], Weapons[id][i]);
            
menu_additem(MenuStringNumToString);
        }
    }
    
    for(new 
1sizeof(Case_Data); i++)
    {
        if(
Cases[id][i] > 0)
        {
            new 
NumToString[6];
            
num_to_str(i+sizeof(SkinData), NumToString5);
            
formatex(Stringcharsmax(String), "%s \r(%d)"Case_Data[i][0], Cases[id][i]);
            
menu_additem(MenuStringNumToString);
        }
    }
    
    if(
Keys[id] > 0)
    {
        new 
NumToString[6];
        
num_to_str(1+sizeof(SkinData)+sizeof(Case_Data), NumToString5);
        
formatex(Stringcharsmax(String), "%s \r(%d)"KeyNameKeys[id]);
        
menu_additem(MenuStringNumToString);
    }
    
    
menu_display(idMenu);
}

public 
TChooseItemh(idMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(Menu);
        return;
    }
    
    new 
Data[14], Line[32];
    new 
AccessCallback;
    
menu_item_getinfo(MenuItemAccessDatacharsmax(Data), Linecharsmax(Line), Callback);
    new 
str_to_num(Data);
    
    
TradeItem[id] = x;
    
client_cmd(id"messagemode TRADEPIECE");
}

public 
MChooseItem(id)
{
    new 
String[128];
    
formatex(Stringcharsmax(String), "%L"id"CHOOSEITEM");
    new 
Menu menu_create(String"MChooseItemh");
    
    for(new 
1sizeof(SkinData); i++)
    {
        if(
Weapons[id][i] > && strlen(SkinDataTrade[i]) > 1)
        {
            new 
NumToString[6];
            
num_to_str(iNumToString5);
            
            if(
SkinData[i][3][0] != CSW_KNIFE)
                
formatex(Stringcharsmax(String), "%s%s \y(%d)"RareData[SkinData[i][4][0]], SkinDataTrade[i], Weapons[id][i]);
            else
                
formatex(Stringcharsmax(String), "%s%s \w(%d)"RareData[SkinData[i][4][0]], SkinDataTrade[i], Weapons[id][i]);
            
menu_additem(MenuStringNumToString);
        }
    }
    
    for(new 
1sizeof(Case_Data); i++)
    {
        if(
Cases[id][i] > 0)
        {
            new 
NumToString[6];
            
num_to_str(i+sizeof(SkinData), NumToString5);
            
formatex(Stringcharsmax(String), "%s \r(%d)"Case_Data[i][0], Cases[id][i]);
            
menu_additem(MenuStringNumToString);
        }
    }
    
    if(
Keys[id] > 0)
    {
        new 
NumToString[6];
        
num_to_str(1+sizeof(SkinData)+sizeof(Case_Data), NumToString5);
        
formatex(Stringcharsmax(String), "%s \r(%d)"KeyNameKeys[id]);
        
menu_additem(MenuStringNumToString);
    }
    
    
menu_display(idMenu);
}

public 
MChooseItemh(idMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(Menu);
        return;
    }
    
    new 
Data[14], Line[32];
    new 
AccessCallback;
    
menu_item_getinfo(MenuItemAccessDatacharsmax(Data), Linecharsmax(Line), Callback);
    new 
str_to_num(Data);
    
    
MarketItem[id] = x;
    
MarketMenu(id);
}

public 
cmdDollarM(id)
{
    if(
inTrade[id] == || !Logined[id])
        return;
    
    new 
PriceData[32];
    
read_args(Datacharsmax(Data));
    
remove_quotes(Data);
    
    
Price str_to_num(Data);
    
    if(
Price <= MinDollarMarket)
    {
        
print_color(id"!g%s!y %L"Prefixid"LOWPRICE"MinDollarMarket);
        
client_cmd(id"messagemode MARKETDOLLAR");
        
MarketMenu(id);
    }
    else if(
MaxDollarMarket >= Price)
    {
        
MarketDollar[id] = Price;
        
MarketMenu(id);
    }
    else
    {
        
print_color(id"!g%s!y %L"Prefixid"HIGHPRICE"MaxDollarMarket);
        
client_cmd(id"messagemode MARKETDOLLAR");
        
MarketMenu(id);
    }
}

public 
cmdDollarT(id)
{
    if(
inTrade[id] == || !Logined[id])
        return;
    
    new 
PieceData[32], kid;
    
read_args(Datacharsmax(Data));
    
remove_quotes(Data);
    
    
Piece str_to_num(Data);
    
    if(
TradePartner[id] > 0)
        
kid TradePartner[id];
    else
        
kid TradeID[id];
    
    if(
Piece <= 0)
    {
        
client_cmd(id"messagemode TRADEDOLLARS");
    }
    else if(
Dollars[id] >= Piece)
    {
        
TradeDollars[id] = Piece;
        
TradeMenu(id);
        
TradeMenu(kid);
        
Accept[id] = 0;
        
Accept[kid] = 0;
    }
    else
    {
        
TradeDollars[id] = Dollars[id];
        
TradeMenu(id);
        
TradeMenu(kid);
        
Accept[id] = 0;
        
Accept[kid] = 0;
    }
}
public 
cmdPiece(id)
{
    new 
kid;
    
    if(
TradePartner[id] > 0)
        
kid TradePartner[id];
    else
        
kid TradeID[id];
        
    if(
inTrade[id] == || inTrade[kid] == || !Logined[id])
        return;
    
    new 
PieceData[32];
    
read_args(Datacharsmax(Data));
    
remove_quotes(Data);
    
    
Piece str_to_num(Data);
    
    if(
TradeItem[id] > && TradeItem[id] <= 90+MAXKNIFESKINS)
    {
        if(
Weapons[id][TradeItem[id]] >= Piece && Piece >= 1)
        {
            
TradePiece[id] = Piece;
            
TradeMenu(id);
            
TradeMenu(kid);
            
Accept[id] = 0;
            
Accept[kid] = 0;
        }
    }
    else if(
TradeItem[id] > 90+MAXKNIFESKINS && TradeItem[id] <= 90+MAXKNIFESKINS+MAXCASES)
    {
        if(
Cases[id][TradeItem[id]-(90+MAXKNIFESKINS)] >= Piece && Piece >= 1)
        {
            
TradePiece[id] = Piece;
            
TradeMenu(id);
            
TradeMenu(kid);
            
Accept[id] = 0;
            
Accept[kid] = 0;
        }
    }
    else if(
TradeItem[id] > 0)
    {
        if(
Keys[id] >= Piece && Piece >= 1)
        {
            
TradePiece[id] = Piece;
            
TradeMenu(id);
            
TradeMenu(kid);
            
Accept[id] = 0;
            
Accept[kid] = 0;
        }
    }
    else
    {
        
TradePiece[id] = 0;
        
TradeMenu(id);
        
TradeMenu(kid);
        
Accept[id] = 0;
        
Accept[kid] = 0;
        return;
    }
}

public 
RegMenu(id)
{
    if(
ServerLoaded == 0)
    {
        
print_color(id"!g%s!y %L"Prefixid"SERVERLOADING");
        return;
    }
    
    new 
String[128];
    
formatex(Stringcharsmax(String), "%L"id"REGISTERMENU");
    new 
menu menu_create(String"RegMenuh" );
        
    if(
strlen(User[id]) > 0)
    {
        
formatex(Stringcharsmax(String), "%L"id"USERNAME"User[id]);
        
menu_additem(menuString"1");
        
        
formatex(Stringcharsmax(String), "%L^n"id"PASSWORD"Password[id]);
        
menu_additem(menuString"2");
    }
    else
    {
        
formatex(Stringcharsmax(String), "%L"id"USERNAME2"User[id]);
        
menu_additem(menuString"1");
    }
    
    if(
strlen(User[id]) > && strlen(Password[id]) > && UserLoad[id] == && inProgress[id] == 0)
    {
        if(
Found[id])
        {
            
formatex(Stringcharsmax(String), "%L"id"LOGIN");
            
menu_additem(menuString"3");
        }
        else
        {
            
formatex(Stringcharsmax(String), "%L"id"REGISTER");
            
menu_additem(menuString"4");
        }
    }
    
    
menu_display(idmenu);
}

public 
RegMenuh(idMenuItem)
{
    if(
Item == MENU_EXIT)
    {
        
menu_destroy(Menu);
        return;
    }
    
    new 
Data[14], Line[32];
    new 
AccessCallback;
    
menu_item_getinfo(MenuItemAccessDatacharsmax(Data), Linecharsmax(Line), Callback);
    
    new 
str_to_num(Data);
    
    switch(
x)
    {
        case 
: {
            
client_cmd(id"messagemode MY_USERNAME");
            
RegMenu(id);
        }
        
        case 
: {
            
client_cmd(id"messagemode MY_PASSWORD");
            
RegMenu(id);
        }
        
        case 
: {
            if(
inProgress[id] == 0)
            {
                
inProgress[id] = 1;
                
print_color(id"!g%s!y %L"Prefixid"LOGINPENDING");
                
RegisterMod[id] = 1;
                
SQL_Check(id);
                
RegMenu(id);
            }
            else
            {
                
RegMenu(id);
            }
        }
        
        case 
: {
            if(
inProgress[id] == 0)
            {
                
inProgress[id] = 1;
                
print_color(id"!g%s!y %L"Prefixid"REGISTERPENDING");
                
RegisterMod[id] = 2;
                
SQL_Check(id);
                
RegMenu(id);
            }
            else
            {
                
RegMenu(id);
            }
        }
    }
}

public 
SQL_RegCheck(id)
{
    new 
szQuery[128], Lena[32];
    
    
formatex(a31"%s"User[id]);

    
replace_all(a31"\", "\\");
    replace_all(a, 31, "'", "\'");
    
    Len += formatex(szQuery[Len], 128, "SELECT * FROM globaloffensive ");
    Len += formatex(szQuery[Len], 128-Len,"WHERE USER = '
%s'", a);
    
    new szData[2];
    szData[0] = id;
    szData[1] = get_user_userid(id);
    
    SQL_ThreadQuery(SQL_TUPLE, "SQL_RegCheckResult", szQuery, szData, 2);
    
    UserLoad[id] = 1;
}

public SQL_RegCheckResult(FailState, Handle:Query, Error[], Errcode, szData[], DataSize)
{
    if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)
    {
        log_amx("%s", Error);
        return;
    }
    
    new id = szData[0];
    
    if(szData[1] != get_user_userid(id))
        return;
    
    if(SQL_NumRows(Query) > 0)
    {
        Found[id] = true;
    }
    else
    {
        Found[id] = false;
    }
    
    UserLoad[id] = 0;
    RegMenu(id);
}

public SQL_Check(id)
{
    new szQuery[128], Len, a[32];
    
    formatex(a, 31, "%s", User[id]);

    replace_all(a, 31, "\", "\\");
    replace_all(a, 31, "'", "
\'");
    
    Len += formatex(szQuery[Len], 128, "SELECT * FROM globaloffensive ");
    Len += formatex(szQuery[Len], 128-Len,"WHERE USER = '
%s'", a);
    
    new szData[2];
    szData[0] = id;
    szData[1] = get_user_userid(id);
    
    SQL_ThreadQuery(SQL_TUPLE, "SQL_CheckResult", szQuery, szData, 2);
}

public SQL_CheckResult(FailState, Handle:Query, Error[], Errcode, szData[], DataSize)
{
    if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)
    {
        log_amx("%s", Error);
        return;
    }
    
    new id = szData[0];
    
    if(szData[1] != get_user_userid(id))
        return;
    
    if(RegisterMod[id] == 2)
    {    
        if(SQL_NumRows(Query) > 0)
        {
            print_color(id, "!g%s!y %L", Prefix, id, "USERNAMEUSING");
            inProgress[id] = 0;
            RegMenu(id);
        }
        else
        {
            SQL_NewAccount(id);
        }
    }
    else if(RegisterMod[id] == 1)
    {
        if(SQL_NumRows(Query) == 0)
        {
            print_color(id, "!g%s!y %L", Prefix, id, "BADPW");
            inProgress[id] = 0;
            RegMenu(id);
        }
        else
        {
            SQL_UserLoad(id);
        }
    }
}

public SQL_NewAccount(id)
{
    new szQuery[512], Len, a[32], b[32], c[32];
    
    formatex(a, 31, "%s", User[id]);
    formatex(b, 31, "%s", Password[id]);
    formatex(c, 31, "%s", Name[id]);

    replace_all(a, 31, "\", "\\");
    replace_all(a, 31, "'", "
\'"); 
    replace_all(b, 31, "\", "\\");
    replace_all(b, 31, "'", "
\'"); 
    replace_all(c, 31, "\", "\\");
    replace_all(c, 31, "'", "
\'");
     
    Len += formatex(szQuery[Len], 511, "INSERT INTO globaloffensive ");
    Len += formatex(szQuery[Len], 511-Len,"(USER,PW,NAME) VALUES('
%s','%s','%s')", a, b, c);
    
    new szData[2];
    szData[0] = id;
    szData[1] = get_user_userid(id);

    SQL_ThreadQuery(SQL_TUPLE,"SQL_NewAccountResult", szQuery, szData, 2);
}

public SQL_NewAccountResult(FailState, Handle:Query, Error[], Errcode, szData[], DataSize)
{
    if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)
    {
        log_amx("%s", Error);
        return;
    }
        
    new id = szData[0];
    
    if(szData[1] != get_user_userid(id))
        return;
    
    inProgress[id] = 0;
    RegisterMod[id] = 2;
    print_color(id, "!g%s!y %L", Prefix, id, "REGISTERED");
    print_color(id, "!g%s!y %L", Prefix, id, "REGDATAS", User[id], Password[id]);
    SQL_RegCheck(id);
    
    return;
}

public SQL_UserLoad(id)
{
    new szQuery[256], Len, a[32];
    
    formatex(a, 31, "%s", User[id]);

    replace_all(a, 31, "\", "\\");
    replace_all(a, 31, "'", "
\'");
    
    Len += formatex(szQuery[Len], 256, "SELECT * FROM globaloffensive ");
    Len += formatex(szQuery[Len], 256-Len,"WHERE USER = '
%s'", a);
    
    new szData[2];
    szData[0] = id;
    szData[1] = get_user_userid(id);

    SQL_ThreadQuery(SQL_TUPLE,"SQL_UserLoadResult", szQuery, szData, 2);
}

public SQL_UserLoadResult(FailState, Handle:Query, Error[], Errcode, szData[], DataSize)
{
    if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)
    {
        log_amx("%s", Error);
        return;
    }
    else
    {
        new id = szData[0];
        
        if(szData[1] != get_user_userid(id))
            return;
        
        new SqlPassword[32], i;
        SQL_ReadResult(Query, 2, SqlPassword, 31);
        
        if(equal(Password[id], SqlPassword))
        {    
            SQL_ReadResult(Query, 2, Password[id], 31);
            Activity[id] = SQL_ReadResult(Query, 132);
            
            if(Activity[id] > 0)
            {
                print_color(id, "!g%s!y %L", Prefix, id, "USERUSING");
                inProgress[id] = 0;
                RegMenu(id);
                return;
            }
            
            UserID[id] = SQL_ReadResult(Query, 0);
            
            Dollars[id] = SQL_ReadResult(Query, 4);
            Keys[id] = SQL_ReadResult(Query, 11);
            
            for(i = 1; i < sizeof(Case_Data); i++)
            {
                Cases[id][i] = SQL_ReadResult(Query, 4+i);
            }
            
            for(i = 1; i < sizeof(SkinData); i++)
            {
                Weapons[id][i] = SQL_ReadResult(Query, 11+i);
            }
            
            Activity[id] = 1;
            
            Kills[id] = SQL_ReadResult(Query, 133);
            CurrentRank[id] = SQL_ReadResult(Query, 134);
            
            if(CurrentRank[id] == 0)
            {
                CurrentRank[id] = 1;
            }
            
            SQL_UpdateActivity(id);
            
            print_color(id, "!g%s!y %L", Prefix, id, "LOGINED");
            
            inProgress[id] = 0;
            Logined[id] = true;
            MainMenu(id);
        }
        else
        {
            print_color(id, "!g%s!y %L", Prefix, id, "BADPW");
            inProgress[id] = 0;
            RegMenu(id);
        }
    }
}

public cmdUser(id)
{
    if(Logined[id])
    {
        return PLUGIN_HANDLED;
    }
    
    if(UserLoad[id] == 1)
    {
        RegMenu(id);
        return PLUGIN_HANDLED;
    }
    
    new cmdData[32], cmdLength;
    cmdData[0] = EOS;
    read_args(cmdData, 31);
    remove_quotes(cmdData);
    
    cmdLength = strlen(cmdData);
    
    if(cmdLength < 4)
    {
        print_color(id, "!g%s!y %L", Prefix, id, "SHORT");
        return PLUGIN_HANDLED;
    }
    
    if(cmdLength > 19)
    {
        print_color(id, "!g%s!y %L", Prefix, id, "LONG");
        return PLUGIN_HANDLED;
    }
    
    copy(User[id], 31, cmdData);
    SQL_RegCheck(id);
    return PLUGIN_HANDLED;
}

public cmdPassword(id)
{
    if(Logined[id] || strlen(User[id]) == 0)
    {
        return PLUGIN_HANDLED;
    }
    
    new cmdData[32], cmdLength;
    cmdData[0] = EOS;
    read_args(cmdData, 31);
    remove_quotes(cmdData);
    
    cmdLength = strlen(cmdData);
    
    if(cmdLength < 4)
    {
        print_color(id, "!g%s!y %L", Prefix, id, "SHORT");
        return PLUGIN_HANDLED;
    }
    
    if(cmdLength > 19)
    {
        print_color(id, "!g%s!y %L", Prefix, id, "LONG");
        return PLUGIN_HANDLED;
    }
    
    copy(Password[id], 31, cmdData);
    RegMenu(id);
    return PLUGIN_HANDLED;
}

public SQL_Results(FailState, Handle:Query, Error[], Errcode, szData[], DataSize)
{
    if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)
    {
        log_amx("%s", Error);
        return;
    }
}

public SQL_FirstLoad() 
{
    SQL_TUPLE = SQL_MakeDbTuple(SQL_Host, SQL_User, SQL_Password, SQL_Database);
    SQL_Reload();
}

public SQL_Reload()
{
    new szQuery[256], Len;
    
    Len += formatex(szQuery[Len], 256, "UPDATE globaloffensive SET ");
    Len += formatex(szQuery[Len], 255-Len,"ACT = '
0' ");
    Len += formatex(szQuery[Len], 255-Len,"WHERE ACT = '
1'");
    
    SQL_ThreadQuery(SQL_TUPLE,"SQL_Results", szQuery);
    ServerLoaded = 1;
}

public SQL_UpdateActivity(id)
{
    new sQuery[512], szQuery[256], a[32];
    formatex(a, 31, "%s", Name[id]);

    replace_all(a, 31, "\", "\\");
    replace_all(a, 31, "'", "
\'");
    
    formatex(szQuery, charsmax(szQuery), "UPDATE globaloffensive SET ");
    add(sQuery, charsmax(sQuery), szQuery);
    
    formatex(szQuery, charsmax(szQuery),"NAME = '
%s', ", a);
    add(sQuery, charsmax(sQuery), szQuery);
    
    formatex(szQuery, charsmax(szQuery),"ACT = '
%d' ", Activity[id]);
    add(sQuery, charsmax(sQuery), szQuery);
    
    formatex(szQuery, charsmax(szQuery),"WHERE Id = '
%d'", UserID[id]);
    add(sQuery, charsmax(sQuery), szQuery);
    
    SQL_ThreadQuery(SQL_TUPLE, "SQL_Results", sQuery);
}

public SQL_UpdateUser(id)
{    
    if(!Logined[id])
        return;
    
    new sQuery[2000], szQuery[256];
    new a[32], i;
    formatex(a, 31, "%s", Name[id]);

    replace_all(a, 31, "\", "\\");
    replace_all(a, 31, "'", "
\'");
    
    formatex(szQuery, charsmax(szQuery), "UPDATE globaloffensive SET ");
    add(sQuery, charsmax(sQuery), szQuery);
    
    formatex(szQuery, charsmax(szQuery),"NAME = '
%s', ", a);
    add(sQuery, charsmax(sQuery), szQuery);
    
    formatex(szQuery, charsmax(szQuery),"DOLLAR = '
%d', ", Dollars[id]);
    add(sQuery, charsmax(sQuery), szQuery);
    
    formatex(szQuery, charsmax(szQuery),"K = '
%d', ", Keys[id]);
    add(sQuery, charsmax(sQuery), szQuery);
    
    formatex(szQuery, charsmax(szQuery),"KILLS = '
%d', ", Kills[id]);
    add(sQuery, charsmax(sQuery), szQuery);
    
    formatex(szQuery, charsmax(szQuery),"RANK = '
%d', ", CurrentRank[id]);
    add(sQuery, charsmax(sQuery), szQuery);
    
    for(i = 1; i < sizeof(Case_Data); i++)
    {
        formatex(szQuery, charsmax(szQuery), "C%d = '
%d', ", i, Cases[id][i]);
        add(sQuery, charsmax(sQuery), szQuery);
    }
    
    for(i = 1; i < sizeof(SkinData); i++)
    {
        formatex(szQuery, charsmax(szQuery), "W%d = '
%d', ", i, Weapons[id][i]);
        add(sQuery, charsmax(sQuery), szQuery);
    }
    
    formatex(szQuery, charsmax(szQuery),"ACT = '
%d' ", Activity[id]);
    add(sQuery, charsmax(sQuery), szQuery);
    
    formatex(szQuery, charsmax(szQuery),"WHERE Id = '
%d'", UserID[id]);
    add(sQuery, charsmax(sQuery), szQuery);
    
    SQL_ThreadQuery(SQL_TUPLE, "SQL_Results", sQuery);
}

public client_putinserver(id)
{
    for(new i = 1; i < 3; i++)
        inUse[id][i] = 0;
        
    UserLoad[id] = 0;
    inProgress[id] = 0;
    Logined[id] = false;
    copy(Password[id], 31, "");
    copy(User[id], 31, "");
    get_user_name(id, Name[id], 31);
    
    Activity[id] = 0;
    DeleteTradeandMarket(id);
}

public client_disconnect(id)
{
    DeleteTradeandMarket(id);

    if(Logined[id])
    {
        Logined[id] = false;
        Activity[id] = 0;
        SQL_UpdateActivity(id);
        log_amx("asdsdadsadsa");
    }
}

public DeleteTradeandMarket(id)
{
    new kid;
    
    if(TradePartner[id] > 0)
        kid = TradePartner[id];
    else if(TradeID[id] > 0)
        kid = TradeID[id];
    
    inTrade[id] = 0;
    TradeDollars[id] = 0;
    TradeFounding[id] = 0;
    TradePartner[id] = 0;
    TradeItem[id] = 0;
    TradeID[id] = 0;
    
    if(kid > 0)
    {
        inTrade[id] = 0;
        TradeDollars[id] = 0;
        TradeFounding[id] = 0;
        TradePartner[id] = 0;
        TradeItem[id] = 0;
        TradeID[id] = 0;
        PTradeId[id] = 0;
        PTradeId[kid] = 0;
    }
}

public MMarketMenu(id)
{
    new String[128];
    formatex(String, charsmax(String), "%L", id, "MMARKET", Dollars[id]);
    new Menu = menu_create(String, "MMarketMenuh");
    
    formatex(String, charsmax(String), "%L", id, "SELLI");
    menu_additem(Menu, String, "1");
    
    formatex(String, charsmax(String), "%L", id, "BUYI");
    menu_additem(Menu, String, "2");
    
    menu_display(id, Menu);
}

public MMarketMenuh(id, Menu, Item)
{
    if(Item == MENU_EXIT)
    {
        menu_destroy(Menu);
        return;
    }
    
    new Data[14], Line[32];
    new Access, Callback;
    menu_item_getinfo(Menu, Item, Access, Data, charsmax(Data), Line, charsmax(Line), Callback);
    
    new x = str_to_num(Data);
    
    switch(x)
    {
        case 1 : {
            MarketMenu(id);
        }
        
        case 2 : {
            BuyMenu(id);
        }
    }
}

public MarketMenu(id)
{        
    new String[128], ItemName[32];
    
    if(MarketItem[id] > 0 && MarketItem[id] <= 90+MAXKNIFESKINS)
    {
        formatex(ItemName, charsmax(ItemName), "%s", SkinData[MarketItem[id]][0]);
    }
    else if(MarketItem[id] > 90+MAXKNIFESKINS && MarketItem[id] <= 90+MAXKNIFESKINS+MAXCASES)
    {
        formatex(ItemName, charsmax(ItemName), "%s", Case_Data[MarketItem[id]-(90+MAXKNIFESKINS)][0]);
    }
    else if(MarketItem[id] > 0)
    {
        formatex(ItemName, charsmax(ItemName), "%s", KeyName);
    }
    
    formatex(String, charsmax(String), "%L", id, "MARKET");
    new menu = menu_create(String, "MarketMenuh" );
    
    if(InMarket[id] == 0)
    {
        if(MarketItem[id] == 0)
        {
            formatex(String, charsmax(String), "%L^n", id, "CHOOSEITEM");
        }
        else
        {
            formatex(String, charsmax(String), "%L", id, "ITEM", ItemName);
        }
        menu_additem(menu, String, "1");
        
        formatex(String, charsmax(String), "%L", id, "CHOOSESELLITEM", MarketDollar[id]);
        menu_additem(menu, String, "2");
        
        formatex(String, charsmax(String), "%L", id, "TOMARKET");
        menu_additem(menu, String, "3");
    }
    else
    {
        formatex(String, charsmax(String), "%L", id, "INMARKET", ItemName, MarketDollar[id]);
        menu_additem(menu, String, "0");
    }
    
    menu_display(id, menu);
}

public MarketMenuh(id, Menu, Item)
{
    if(Item == MENU_EXIT)
    {
        menu_destroy(Menu);
        return;
    }
    
    new Data[14], Line[32];
    new Access, Callback;
    menu_item_getinfo(Menu, Item, Access, Data, charsmax(Data), Line, charsmax(Line), Callback);
    
    new x = str_to_num(Data);
    
    switch(x)
    {
        case 0:
        {
            InMarket[id] = 0;
            MarketItem[id] = 0;
            MarketDollar[id] = 0;
            MChooseItem(id);
        }
        
        case 1:
        {
            MChooseItem(id);
        }
        
        case 2:
        {
            client_cmd(id, "messagemode MARKETDOLLAR");
            MarketMenu(id);
        }
        
        case 3:
        {
            if(MarketItem[id] > 0)
            {
                new ItemName[32];
    
                if(MarketItem[id] > 0 && MarketItem[id] <= 90+MAXKNIFESKINS)
                {
                    formatex(ItemName, charsmax(ItemName), "%s", SkinData[MarketItem[id]][0]);
                }
                else if(MarketItem[id] > 90+MAXKNIFESKINS && MarketItem[id] <= 90+MAXKNIFESKINS+MAXCASES)
                {
                    formatex(ItemName, charsmax(ItemName), "%s", Case_Data[MarketItem[id]-(90+MAXKNIFESKINS)][0]);
                }
                else if(MarketItem[id] > 0)
                {
                    formatex(ItemName, charsmax(ItemName), "%s", KeyName);
                }
                
                for(new i; i < MAXP; i++)
                    if(is_user_connected(i))
                        print_color(i, "!g%s!y %L", Prefix, i, "SOLVEDTOMARKET", Name[id], ItemName, MarketDollar[id]);
                        
                InMarket[id] = 1;
                MarketMenu(id);
            }
            else
            {
                MarketMenu(id);
            }
        }
    }
}

public BuyMenu(id)
{        
    new String[128], ItemName[32];
    
    formatex(String, charsmax(String), "%L", id, "MARKETMENUBUY", Dollars[id]);
    new Menu = menu_create(String, "BuyMenuh" );
    
    for(new i; i < MAXP; i++)
    {
        if(!is_user_connected(i) || !Logined[i] || InMarket[i] == 0)
            continue;
        
        if(MarketItem[i] > 0 && MarketItem[i] <= 90+MAXKNIFESKINS)
        {
            formatex(ItemName, charsmax(ItemName), "%s", SkinDataTrade[MarketItem[i]]);
        }
        else if(MarketItem[i] > 90+MAXKNIFESKINS && MarketItem[i] <= 90+MAXKNIFESKINS+MAXCASES)
        {
            formatex(ItemName, charsmax(ItemName), "%s", Case_Data[MarketItem[i]-(90+MAXKNIFESKINS)][0]);
        }
        else if(MarketItem[i] > 0)
        {
            formatex(ItemName, charsmax(ItemName), "%s", KeyName);
        }
        
        new Nts[3];
        num_to_str(i, Nts, 2);
        formatex(String, charsmax(String), "%L", id, "SELLITEM", ItemName, MarketDollar[i], Name[i]);
        menu_additem(Menu, String, Nts);
    }
    
    menu_display(id, Menu);
}

public BuyMenuh(id, Menu, Item)
{
    if(Item == MENU_EXIT)
    {
        menu_destroy(Menu);
        return;
    }
    
    new Data[14], Line[32];
    new Access, Callback;
    menu_item_getinfo(Menu, Item, Access, Data, charsmax(Data), Line, charsmax(Line), Callback);
    
    new x = str_to_num(Data);
    
    if(InMarket[x] > 0 && MarketItem[x] > 0 && MarketDollar[x] > 0)
    {
        if(Dollars[id] < MarketDollar[x])
        {
            print_color(id, "!g%s!y %L", Prefix, id, "NOTENOUGHDOLLAR");
            return;
        }
        
        if(MarketItem[x] > 0 && MarketItem[x] <= 90+MAXKNIFESKINS)
        {
            Weapons[id][MarketItem[x]]++;
            Weapons[x][MarketItem[x]]--;
        }
        else if(MarketItem[x] > 90+MAXKNIFESKINS && MarketItem[x] <= 90+MAXKNIFESKINS+MAXCASES)
        {
            Cases[id][MarketItem[x]-(90+MAXKNIFESKINS)]++;
            Cases[x][MarketItem[x]-(90+MAXKNIFESKINS)]--;
        }
        else if(MarketItem[x] > 0)
        {
            Keys[id]++;
            Keys[x]--;
        }
        
        Dollars[id] -= MarketDollar[x];
        Dollars[x] += MarketDollar[x];
        InMarket[x] = 0;
        
        new ItemName[32];
    
        if(MarketItem[id] > 0 && MarketItem[id] <= 90+MAXKNIFESKINS)
        {
            formatex(ItemName, charsmax(ItemName), "%s", SkinData[MarketItem[id]][0]);
        }
        else if(MarketItem[id] > 90+MAXKNIFESKINS && MarketItem[id] <= 90+MAXKNIFESKINS+MAXCASES)
        {
            formatex(ItemName, charsmax(ItemName), "%s", Case_Data[MarketItem[id]-(90+MAXKNIFESKINS)][0]);
        }
        else if(MarketItem[id] > 0)
        {
            formatex(ItemName, charsmax(ItemName), "%s", KeyName);
        }
        
        
        for(new i; i < MAXP; i++)
            if(is_user_connected(i))
                print_color(i, "!g%s!y %L", Prefix, i, "BUYINGITEM", Name[id], ItemName, MarketDollar[x], Name[x]);
                
        MarketDollar[x] = 0;
        MarketItem[x] = 0;
        SQL_UpdateUser(id);
        SQL_UpdateUser(x);
    }
}

public Guns(id) 
{
    if(Choosen[id] > 1)
    {
        print_color(id, "!g%s!y %L", Prefix, id, "WPMESSAGE");
    }
    else if(Choosen[id] < 1)
    {
        Choosen[id] = 0;
        TakeWeapons(id);
    }
}

public PlayerSpawn(id) 
{
    if(!is_user_alive(id))
        return;
    
    if(get_pcvar_num(CvarWeaponMenu) == 1)
    {
        Choosen[id] = 0;
        TakeWeapons(id);
        
        give_item(id, "item_kevlar");
        give_item(id, "item_assaultsuit");
    }
}

public TakeWeapons(id)
{
    if(is_user_alive(id))
    {
        Choosen[id] = 0;
        new HasC4;
        
        if(user_has_weapon(id, CSW_C4))
        {
            HasC4 = 1;
        }
        
        strip_user_weapons(id);
        give_item(id, "weapon_knife");
        WeaponMenu(id);
        
        if(HasC4 == 1)
        {
            give_item(id, "weapon_c4");
        }
        
        if(cs_get_user_team(id) == CS_TEAM_CT)
        {
            give_item(id, "item_thighpack");
        }
    }
    return PLUGIN_CONTINUE;
}

public WeaponMenu(id)
{
    if(Choosen[id] > 1)
        return;
        
    new String[128], Menu;
    
    if(Choosen[id] == 0)
    {
        formatex(String, 127, "%s %L", Prefix, LANG_SERVER, "WPMENU2");
        Menu = menu_create(String, "WeaponMenuh");
        
        for(new i = 1; i < sizeof(FirstWeaponNames); i++)
        {
            new NumToString[6];
            num_to_str(i, NumToString, 5);
            formatex(String, charsmax(String), "%s", FirstWeaponNames[i][0]);
            menu_additem(Menu, String, NumToString);
        }
    }
    
    if(Choosen[id] == 1)
    {
        formatex(String, 127, "%s %L", Prefix, LANG_SERVER, "WPMENU2");
        Menu = menu_create(String, "WeaponMenuh");
        
        for(new i = 1; i < sizeof(SecondaryWeaponNames); i++)
        {
            new NumToString[6];
            num_to_str(i, NumToString, 5);
            formatex(String, charsmax(String), "%s", SecondaryWeaponNames[i][0]);
            menu_additem(Menu, String, NumToString);
        }
    }
    
    menu_display(id, Menu);
}

public WeaponMenuh(id, Menu, Item)
{
    if(Item == MENU_EXIT)
    {
        menu_destroy(Menu);
        return;
    }
    
    new Data[14], Line[32];
    new Access, Callback;
    menu_item_getinfo(Menu, Item, Access, Data, charsmax(Data), Line, charsmax(Line), Callback);
    
    new x = str_to_num(Data);
    
    if(Choosen[id] == 0)
    {
        give_item(id, FirstWeaponNames[x][1]);
        cs_set_user_bpammo(id, FirstWeaponNames[x][2][0], 90);
    }
    if(Choosen[id] == 1)
    {
        give_item(id, SecondaryWeaponNames[x][1]);
        cs_set_user_bpammo(id, SecondaryWeaponNames[x][2][0], 90);
    }
        
    Choosen[id]++;
    
    if(Choosen[id] >= 2)
    {
        Grenades(id);
    }
        
    WeaponMenu(id);
}

stock PlayAnimation(const Player, const Sequence)
{
    set_pev(Player, pev_weaponanim, Sequence);
    
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player);
    write_byte(Sequence);
    write_byte(pev(Player, pev_body));
    message_end();
}

stock print_color(const id, const input[], any:...)
{
    new count = 1, players[32];
    static msg[191];
    vformat(msg, 190, input, 3);

    replace_all(msg, 190, "!g", "^4");
    replace_all(msg, 190, "!y", "^1");
    replace_all(msg, 190, "!t", "^3");   

    if(id) players[0] = id; else get_players(players, count, "ch");
    {
        for (new i = 0; i < count; i++)
        {
            if (is_user_connected(players[i]))
            {
                message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
                write_byte(players[i]);
                write_string(msg);
                message_end();
            }
        }
    }

    return PLUGIN_HANDLED;
}

stock Grenades(id)
{
    give_item(id, "weapon_hegrenade");
    give_item(id, "weapon_flashbang");
    
    if(GiveSmokeGrenade == 1)
    {
        give_item(id, "weapon_smokegrenade");
    }
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
*/ 

Last edited by AlinT; 06-16-2020 at 09:56.
AlinT is offline
Send a message via AIM to AlinT
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:54.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode