Advertisement
Guest User

Francisco Weapon Skins "Private"

a guest
Aug 5th, 2016
4,145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 47.00 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <cstrike>
  4. #include <sdkhooks>
  5. #include <multicolors>
  6.  
  7. #define IDAYS 26
  8.  
  9. #undef REQUIRE_PLUGIN
  10. #include <lastrequest>
  11.  
  12. new Handle:db;
  13.  
  14. new clientlang[MAXPLAYERS+1];
  15.  
  16. //bool checked[MAXPLAYERS + 1];
  17.  
  18. #define MAX_PAINTS 800
  19. #define MAX_LANGUAGES 40
  20.  
  21. enum Listados
  22. {
  23.     String:Nombre[64],
  24.     index,
  25.     Float:wear,
  26.     stattrak,
  27.     quality,
  28.     pattern,
  29.     String:flag[8]
  30. }
  31.  
  32. new Handle:menuw[MAX_LANGUAGES] = INVALID_HANDLE;
  33. new g_paints[MAX_LANGUAGES][MAX_PAINTS][Listados];
  34. new g_paintCount[MAX_LANGUAGES];
  35. new String:path_paints[PLATFORM_MAX_PATH];
  36.  
  37. new bool:g_hosties = false;
  38.  
  39. new bool:g_c4;
  40. new Handle:cvar_c4;
  41.  
  42. new Handle:arbol[MAXPLAYERS+1] = INVALID_HANDLE;
  43. new Handle:menu1[MAXPLAYERS+1] = INVALID_HANDLE;
  44.  
  45. new Handle:saytimer;
  46. new Handle:cvar_saytimer;
  47. new g_saytimer;
  48.  
  49. new Handle:rtimer;
  50. new Handle:cvar_rtimer;
  51. new g_rtimer;
  52.  
  53. new Handle:cvar_rmenu;
  54. new bool:g_rmenu;
  55.  
  56. new Handle:cvar_onlyadmin;
  57. new bool:onlyadmin;
  58.  
  59. new Handle:cvar_zombiesv;
  60. new bool:zombiesv;
  61.  
  62. new String:s_arma[MAXPLAYERS+1][64];
  63. new s_sele[MAXPLAYERS+1];
  64.  
  65. new ismysql;
  66.  
  67. new Handle:array_paints[MAX_LANGUAGES];
  68. new Handle:array_armas;
  69.  
  70. #define DATA "4.0.3 private version"
  71.  
  72. //new String:base[64] = "weaponpaints";
  73.  
  74. new bool:uselocal = false;
  75.  
  76. new bool:comprobado41[MAXPLAYERS+1];
  77.  
  78. bool chooset[MAXPLAYERS + 1];
  79.  
  80.  
  81. public Plugin:myinfo =
  82. {
  83.     name = "SM CS:GO Weapon Paints",
  84.     author = "Franc1sco franug",
  85.     description = "",
  86.     version = DATA,
  87.     url = "http://steamcommunity.com/id/franug"
  88. };
  89.  
  90. new String:g_sCmdLogPath[256];
  91.  
  92. public OnPluginStart()
  93. {
  94.     for(new i=0;;i++)
  95.     {
  96.         BuildPath(Path_SM, g_sCmdLogPath, sizeof(g_sCmdLogPath), "logs/weaponpaints_%d.log", i);
  97.         if ( !FileExists(g_sCmdLogPath) )
  98.             break;
  99.     }
  100.    
  101.     LoadTranslations ("franug_weaponpaints.phrases");
  102.    
  103.     CreateConVar("sm_wpaints_version", DATA, "", FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_CHEAT|FCVAR_DONTRECORD);
  104.    
  105.     HookEvent("round_start", roundStart);
  106.     //HookEvent("player_team", EventPlayerTeam);
  107.     //HookEvent("player_spawn", Event_Player_Spawn, EventHookMode_Pre);
  108.     AddCommandListener(OnJoinTeam, "joingame");
  109.     AddCommandListener(OnJoinTeam, "jointeam");
  110.    
  111.     RegConsoleCmd("buyammo1", GetSkins);
  112.     RegConsoleCmd("sm_ws", GetSkins);
  113.     RegConsoleCmd("sm_wskins", GetSkins);
  114.     RegConsoleCmd("sm_paints", GetSkins);
  115.    
  116.     RegAdminCmd("sm_reloadwskins", ReloadSkins, ADMFLAG_ROOT);
  117.    
  118.     cvar_c4 = CreateConVar("sm_weaponpaints_c4", "1", "Enable or disable that people can apply paints to the C4. 1 = enabled, 0 = disabled");
  119.     cvar_saytimer = CreateConVar("sm_weaponpaints_saytimer", "10", "Time in seconds for block that show the plugin commands in chat when someone type a command. -1.0 = never show the commands in chat");
  120.     cvar_rtimer = CreateConVar("sm_weaponpaints_roundtimer", "20", "Time in seconds roundstart for can use the commands for change the paints. -1.0 = always can use the command");
  121.     cvar_rmenu = CreateConVar("sm_weaponpaints_rmenu", "1", "Re-open the menu when you select a option. 1 = enabled, 0 = disabled.");
  122.     cvar_onlyadmin = CreateConVar("sm_weaponpaints_onlyadmin", "1", "This feature is only for admins. 1 = enabled, 0 = disabled.");
  123.     cvar_zombiesv = CreateConVar("sm_weaponpaints_zombiesv", "1", "Enable this for prevent crashes in zombie servers. 1 = enabled, 0 = disabled.");
  124.    
  125.     g_c4 = GetConVarBool(cvar_c4);
  126.     g_saytimer = GetConVarInt(cvar_saytimer);
  127.     g_rtimer = GetConVarInt(cvar_rtimer);
  128.     g_rmenu = GetConVarBool(cvar_rmenu);
  129.     onlyadmin = GetConVarBool(cvar_onlyadmin);
  130.     zombiesv = GetConVarBool(cvar_zombiesv);
  131.    
  132.     HookConVarChange(cvar_c4, OnConVarChanged);
  133.     HookConVarChange(cvar_saytimer, OnConVarChanged);
  134.     HookConVarChange(cvar_rtimer, OnConVarChanged);
  135.     HookConVarChange(cvar_rmenu, OnConVarChanged);
  136.     HookConVarChange(cvar_onlyadmin, OnConVarChanged);
  137.     HookConVarChange(cvar_zombiesv, OnConVarChanged);
  138.    
  139.     int count = GetLanguageCount();
  140.     for (new i=0; i<count; i++)
  141.         ReadPaints(i);
  142.    
  143.     new String:Items[64];
  144.    
  145.     if(array_armas != INVALID_HANDLE) CloseHandle(array_armas);
  146.    
  147.     array_armas = CreateArray(128);
  148.    
  149.     Format(Items, 64, "negev");
  150.     //Format(Items[desc], 64, "Negev");
  151.     PushArrayString(array_armas, Items);
  152.    
  153.     Format(Items, 64, "m249");
  154.     //Format(Items[desc], 64, "M249");
  155.     PushArrayString(array_armas, Items);
  156.    
  157.     Format(Items, 64, "bizon");
  158.     //Format(Items[desc], 64, "PP-Bizon");
  159.     PushArrayString(array_armas, Items);
  160.    
  161.     Format(Items, 64, "p90");
  162.     //Format(Items[desc], 64, "P90");
  163.     PushArrayString(array_armas, Items);
  164.    
  165.     Format(Items, 64, "scar20");
  166.     //Format(Items[desc], 64, "SCAR-20");
  167.     PushArrayString(array_armas, Items);
  168.    
  169.     Format(Items, 64, "g3sg1");
  170.     //Format(Items[desc], 64, "G3SG1");
  171.     PushArrayString(array_armas, Items);
  172.    
  173.     Format(Items, 64, "m4a1");
  174.     //Format(Items[desc], 64, "M4A1");
  175.     PushArrayString(array_armas, Items);
  176.    
  177.     Format(Items, 64, "m4a1_silencer");
  178.     //Format(Items[desc], 64, "M4A1-S");
  179.     PushArrayString(array_armas, Items);
  180.    
  181.     Format(Items, 64, "ak47");
  182.     //Format(Items[desc], 64, "AK-47");
  183.     PushArrayString(array_armas, Items);
  184.    
  185.     Format(Items, 64, "aug");
  186.     //Format(Items[desc], 64, "AUG");
  187.     PushArrayString(array_armas, Items);
  188.    
  189.     Format(Items, 64, "galilar");
  190.     //Format(Items[desc], 64, "Galil AR");
  191.     PushArrayString(array_armas, Items);
  192.    
  193.     Format(Items, 64, "awp");
  194.     //Format(Items[desc], 64, "AWP");
  195.     PushArrayString(array_armas, Items);
  196.    
  197.     Format(Items, 64, "sg556");
  198.     //Format(Items[desc], 64, "SG 553");
  199.     PushArrayString(array_armas, Items);
  200.    
  201.     Format(Items, 64, "ump45");
  202.     //Format(Items[desc], 64, "UMP-45");
  203.     PushArrayString(array_armas, Items);
  204.    
  205.     Format(Items, 64, "mp7");
  206.     //Format(Items[desc], 64, "MP7");
  207.     PushArrayString(array_armas, Items);
  208.  
  209.     Format(Items, 64, "famas");
  210.     //Format(Items[desc], 64, "FAMAS");
  211.     PushArrayString(array_armas, Items);
  212.    
  213.     Format(Items, 64, "mp9");
  214.     //Format(Items[desc], 64, "MP9");
  215.     PushArrayString(array_armas, Items);
  216.  
  217.     Format(Items, 64, "mac10");
  218.     //Format(Items[desc], 64, "MAC-10");
  219.     PushArrayString(array_armas, Items);
  220.    
  221.     Format(Items, 64, "ssg08");
  222.     //Format(Items[desc], 64, "SSG 08");
  223.     PushArrayString(array_armas, Items);
  224.    
  225.     Format(Items, 64, "nova");
  226.     //Format(Items[desc], 64, "Nova");
  227.     PushArrayString(array_armas, Items);
  228.    
  229.     Format(Items, 64, "xm1014");
  230.     //Format(Items[desc], 64, "XM1014");
  231.     PushArrayString(array_armas, Items);
  232.    
  233.     Format(Items, 64, "sawedoff");
  234.     //Format(Items[desc], 64, "Sawed-Off");
  235.     PushArrayString(array_armas, Items);
  236.    
  237.     Format(Items, 64, "mag7");
  238.     //Format(Items[desc], 64, "MAG-7");
  239.     PushArrayString(array_armas, Items);
  240.    
  241.  
  242.    
  243.     // Secondary weapons
  244.     Format(Items, 64, "elite");
  245.     //Format(Items[desc], 64, "Dual Berettas");
  246.     PushArrayString(array_armas, Items);
  247.  
  248.     Format(Items, 64, "deagle");
  249.     //Format(Items[desc], 64, "Desert Eagle");
  250.     PushArrayString(array_armas, Items);
  251.  
  252.     Format(Items, 64, "tec9"); // 26
  253.     //Format(Items[desc], 64, "Tec-9");
  254.     PushArrayString(array_armas, Items);
  255.    
  256.     Format(Items, 64, "fiveseven");
  257.     //Format(Items[desc], 64, "Five-SeveN");
  258.     PushArrayString(array_armas, Items);
  259.  
  260.     Format(Items, 64, "cz75a");
  261.     //Format(Items[desc], 64, "CZ75-Auto");
  262.     PushArrayString(array_armas, Items);
  263.    
  264.     Format(Items, 64, "glock");
  265.     PushArrayString(array_armas, Items);
  266.    
  267.     Format(Items, 64, "usp_silencer");
  268.     //Format(Items[desc], 64, "USP-S");
  269.     PushArrayString(array_armas, Items);
  270.    
  271.     Format(Items, 64, "p250");
  272.     //Format(Items[desc], 64, "P250");
  273.     PushArrayString(array_armas, Items);
  274.    
  275.     Format(Items, 64, "hkp2000");
  276.     //Format(Items[desc], 64, "P2000");
  277.     PushArrayString(array_armas, Items);
  278.    
  279.     Format(Items, 64, "bayonet");
  280.     PushArrayString(array_armas, Items);
  281.    
  282.     Format(Items, 64, "knife_gut");
  283.     PushArrayString(array_armas, Items);
  284.    
  285.     Format(Items, 64, "knife_flip");
  286.     PushArrayString(array_armas, Items);
  287.    
  288.     Format(Items, 64, "knife_m9_bayonet");
  289.     PushArrayString(array_armas, Items);
  290.    
  291.     Format(Items, 64, "knife_karambit");
  292.     PushArrayString(array_armas, Items);
  293.    
  294.     Format(Items, 64, "knife_tactical");
  295.     PushArrayString(array_armas, Items);
  296.    
  297.     Format(Items, 64, "knife_butterfly");
  298.     PushArrayString(array_armas, Items);
  299.    
  300.     Format(Items, 64, "c4");
  301.     PushArrayString(array_armas, Items);
  302.    
  303.     Format(Items, 64, "knife_falchion");
  304.     PushArrayString(array_armas, Items);
  305.    
  306.     Format(Items, 64, "knife_push");
  307.     PushArrayString(array_armas, Items);
  308.    
  309.     Format(Items, 64, "revolver");
  310.     PushArrayString(array_armas, Items);
  311.    
  312.     Format(Items, 64, "knife_survival_bowie");
  313.     PushArrayString(array_armas, Items);
  314.    
  315.     for (new client = 1; client <= MaxClients; client++)
  316.     {
  317.         if (!IsClientInGame(client))
  318.             continue;
  319.            
  320.         OnClientPutInServer(client);
  321.         //CreateTimer(0.1, Timer_ClientLanguage, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
  322.        
  323.     }
  324.    
  325.     ComprobarDB(true, "weaponpaints");
  326. }
  327. /*
  328. public OnClientPostAdminCheck(client)
  329. {
  330.     QueryClientConVar(client, "cl_language", ConVarQueryFinished:CallBack);
  331. }
  332.  
  333. public CallBack(QueryCookie:cookie, client, ConVarQueryResult:result, const String:cvarName[], const String:cvarValue[])
  334. {
  335.     langindex = GetLanguageByName(cvarValue);
  336.     if(langindex == -1)
  337.     {
  338.         CreateTimer(0.1, Timer_ClientLanguage, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
  339.         return;
  340.     }
  341.    
  342.     clientlang[client] = langindex ;
  343.     CheckSteamID(client);
  344.    
  345.     chooset[client] = true;
  346. }
  347. */
  348.  
  349. /*
  350. public Action:EventPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
  351. {
  352.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  353.    
  354.     if(client > 0 && client <= MaxClients)
  355.     {
  356.         if(IsFakeClient(client))
  357.         {
  358.             return Plugin_Continue;
  359.         }
  360.     }
  361.        
  362.     // refresh client channel after a delay to fix invalid memory access bug
  363.     CreateTimer(0.1, Timer_ClientLanguage, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
  364.     return Plugin_Continue;
  365. }*/
  366.  
  367. public Action:Timer_ClientLanguage(Handle:timer, any:serial)
  368. {
  369.     new client = GetClientFromSerial(serial);
  370.    
  371.     if (client)
  372.     {
  373.         //if(!checked[client])
  374.         //{
  375.             clientlang[client] = GetClientLanguage(client);
  376.             CheckSteamID(client);
  377.             //checked[client] = true;
  378.         //}
  379.     }
  380.  
  381.     return Plugin_Stop;
  382. }
  383.  
  384. public Action OnJoinTeam(int client, const char[] command, int args)
  385. {
  386.     if (chooset[client])return;
  387.    
  388.     clientlang[client] = GetClientLanguage(client);
  389.     CheckSteamID(client);
  390.    
  391.     chooset[client] = true;
  392. }
  393.  
  394. public OnConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[])
  395. {
  396.     if (convar == cvar_c4)
  397.     {
  398.         g_c4 = bool:StringToInt(newValue);
  399.     }
  400.     else if (convar == cvar_saytimer)
  401.     {
  402.         g_saytimer = StringToInt(newValue);
  403.     }
  404.     else if (convar == cvar_rtimer)
  405.     {
  406.         g_rtimer = StringToInt(newValue);
  407.     }
  408.     else if (convar == cvar_rmenu)
  409.     {
  410.         g_rmenu = bool:StringToInt(newValue);
  411.     }
  412.     else if (convar == cvar_onlyadmin)
  413.     {
  414.         onlyadmin = bool:StringToInt(newValue);
  415.     }
  416.     else if (convar == cvar_zombiesv)
  417.     {
  418.         zombiesv = bool:StringToInt(newValue);
  419.     }
  420. }
  421.  
  422. public void OnConfigsExecuted() {
  423.     GameRules_SetProp("m_bIsValveDS", 1);
  424.     GameRules_SetProp("m_bIsQuestEligible", 1);
  425. }
  426.  
  427. ComprobarDB(bool:reconnect = false,String:basedatos[64] = "weaponpaints")
  428. {
  429.     if(uselocal) basedatos = "clientprefs";
  430.     if(reconnect)
  431.     {
  432.         if (db != INVALID_HANDLE)
  433.         {
  434.             //LogMessage("Reconnecting DB connection");
  435.             CloseHandle(db);
  436.             db = INVALID_HANDLE;
  437.         }
  438.     }
  439.     else if (db != INVALID_HANDLE)
  440.     {
  441.         return;
  442.     }
  443.  
  444.     if (!SQL_CheckConfig( basedatos ))
  445.     {
  446.         if(StrEqual(basedatos, "clientprefs")) SetFailState("Databases not found");
  447.         else
  448.         {
  449.             //base = "clientprefs";
  450.             ComprobarDB(true,"clientprefs");
  451.             uselocal = true;
  452.         }
  453.        
  454.         return;
  455.     }
  456.     SQL_TConnect(OnSqlConnect, basedatos);
  457. }
  458.  
  459. public OnSqlConnect(Handle:owner, Handle:hndl, const String:error[], any:data)
  460. {
  461.     if (hndl == INVALID_HANDLE)
  462.     {
  463.         LogToFileEx(g_sCmdLogPath, "Database failure: %s", error);
  464.        
  465.         SetFailState("Databases dont work");
  466.     }
  467.     else
  468.     {
  469.         db = hndl;
  470.         decl String:buffer[3096];
  471.        
  472.         SQL_GetDriverIdent(SQL_ReadDriver(db), buffer, sizeof(buffer));
  473.         ismysql = StrEqual(buffer,"mysql", false) ? 1 : 0;
  474.    
  475.         new String:temp[64][44];
  476.         for(new i=0;i<GetArraySize(array_armas);++i)
  477.         {
  478.             GetArrayString(array_armas, i, temp[i], 64);
  479.         }
  480.         if (ismysql == 1)
  481.         {
  482.             Format(buffer, sizeof(buffer), "CREATE TABLE IF NOT EXISTS `weaponpaints` (`playername` varchar(128) NOT NULL, `steamid` varchar(32) NOT NULL, `last_accountuse` int(64) NOT NULL, `%s` varchar(64) NOT NULL DEFAULT 'none', `%s` varchar(64) NOT NULL DEFAULT 'none', `%s` varchar(64) NOT NULL DEFAULT 'none', `%s` varchar(64) NOT NULL DEFAULT 'none', `%s` varchar(64) NOT NULL DEFAULT 'none', `%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`%s` varchar(64) NOT NULL DEFAULT 'none',`favorite1` varchar(64) NOT NULL DEFAULT 'none',`favorite2` varchar(64) NOT NULL DEFAULT 'none',`favorite3` varchar(64) NOT NULL DEFAULT 'none',`favorite4` varchar(64) NOT NULL DEFAULT 'none',`favorite5` varchar(64) NOT NULL DEFAULT 'none',`favorite6` varchar(64) NOT NULL DEFAULT 'none',`favorite7` varchar(64) NOT NULL DEFAULT 'none',PRIMARY KEY  (`steamid`))",temp[0],temp[1],temp[2],temp[3],temp[4],temp[5],temp[6],temp[7],temp[8],temp[9],temp[10],temp[11],temp[12],temp[13],temp[14],temp[15],temp[16],temp[17],temp[18],temp[19],temp[20],temp[21],temp[22],temp[23],temp[24],temp[25],temp[26],temp[27],temp[28],temp[29],temp[30],temp[31],temp[32],temp[33],temp[34],temp[35],temp[36],temp[37],temp[38],temp[39],temp[40], temp[41], temp[42], temp[43]);
  483.  
  484.             LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
  485.             SQL_TQuery(db, tbasicoC, buffer);
  486.  
  487.         }
  488.         else
  489.         {
  490.             Format(buffer, sizeof(buffer), "CREATE TABLE IF NOT EXISTS weaponpaints (playername varchar(128) NOT NULL, steamid varchar(32) NOT NULL, last_accountuse int(64) NOT NULL, %s varchar(64) NOT NULL DEFAULT 'none', %s varchar(64) NOT NULL DEFAULT 'none', %s varchar(64) NOT NULL DEFAULT 'none', %s varchar(64) NOT NULL DEFAULT 'none', %s varchar(64) NOT NULL DEFAULT 'none', %s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',%s varchar(64) NOT NULL DEFAULT 'none',favorite1 varchar(64) NOT NULL DEFAULT 'none',favorite2 varchar(64) NOT NULL DEFAULT 'none',favorite3 varchar(64) NOT NULL DEFAULT 'none',favorite4 varchar(64) NOT NULL DEFAULT 'none',favorite5 varchar(64) NOT NULL DEFAULT 'none',favorite6 varchar(64) NOT NULL DEFAULT 'none',favorite7 varchar(64) NOT NULL DEFAULT 'none',PRIMARY KEY  (steamid))",temp[0],temp[1],temp[2],temp[3],temp[4],temp[5],temp[6],temp[7],temp[8],temp[9],temp[10],temp[11],temp[12],temp[13],temp[14],temp[15],temp[16],temp[17],temp[18],temp[19],temp[20],temp[21],temp[22],temp[23],temp[24],temp[25],temp[26],temp[27],temp[28],temp[29],temp[30],temp[31],temp[32],temp[33],temp[34],temp[35],temp[36],temp[37],temp[38],temp[39],temp[40],temp[41], temp[42], temp[43]);
  491.        
  492.             LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
  493.             SQL_TQuery(db, tbasicoC, buffer);
  494.         }
  495.     }
  496. }
  497.  
  498. public OnClientDisconnect(client)
  499. {  
  500.     //checked[client] = false;
  501.     chooset[client] = false;
  502.     if(comprobado41[client] && !IsFakeClient(client)) SaveCookies(client);
  503.     comprobado41[client] = false;
  504.     if(arbol[client] != INVALID_HANDLE)
  505.     {
  506.         ClearTrie(arbol[client]);
  507.         CloseHandle(arbol[client]);
  508.         arbol[client] = INVALID_HANDLE;
  509.     }
  510.     if(menu1[client] != INVALID_HANDLE)
  511.     {
  512.         CloseHandle(menu1[client]);
  513.         menu1[client] = INVALID_HANDLE;
  514.     }
  515. }
  516.  
  517. public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
  518. {
  519.     MarkNativeAsOptional("IsClientInLastRequest");
  520.  
  521.     return APLRes_Success;
  522. }
  523.  
  524. public OnLibraryAdded(const String:name[])
  525. {
  526.     if (StrEqual(name, "hosties"))
  527.     {
  528.         g_hosties = true;
  529.     }
  530. }
  531.  
  532. public OnLibraryRemoved(const String:name[])
  533. {
  534.     if (StrEqual(name, "hosties"))
  535.     {
  536.         g_hosties = false;
  537.     }
  538.    
  539.    
  540. }
  541.  
  542. public Action:ReloadSkins(client, args)
  543. {  
  544.     int count = GetLanguageCount();
  545.     for (new i=0; i<count; i++)
  546.         ReadPaints(i);
  547.        
  548.    
  549.     ReplyToCommand(client, " \x04[WP]\x01 %T","Weapon paints reloaded", client);
  550.    
  551.     return Plugin_Handled;
  552. }
  553.  
  554. ShowMenu(client, item)
  555. {
  556.     SetMenuTitle(menuw[clientlang[client]], "%T","Menu title 1", client);
  557.    
  558.     //RemoveMenuItem(menuw, 2);
  559.     RemoveMenuItem(menuw[clientlang[client]], 1);
  560.     RemoveMenuItem(menuw[clientlang[client]], 0);
  561.     decl String:tdisplay[64];
  562.     //Format(tdisplay, sizeof(tdisplay), "%T", "Choose from your favorite paints", client);
  563.     //InsertMenuItem(menuw, 0, "-2", tdisplay);
  564.     Format(tdisplay, sizeof(tdisplay), "%T", "Random paint", client);
  565.     InsertMenuItem(menuw[clientlang[client]], 0, "0", tdisplay);
  566.     Format(tdisplay, sizeof(tdisplay), "%T", "Default paint", client);
  567.     InsertMenuItem(menuw[clientlang[client]], 1, "-1", tdisplay);
  568.    
  569.     DisplayMenuAtItem(menuw[clientlang[client]], client, item, 0);
  570. }
  571.  
  572. ShowMenuM(client)
  573. {
  574.     if(onlyadmin && GetUserAdmin(client) == INVALID_ADMIN_ID) return;
  575.    
  576.     new Handle:menu2 = CreateMenu(DIDMenuHandler_2);
  577.     SetMenuTitle(menu2, "%T by Franc1sco franug","Menu title 2", client, DATA);
  578.    
  579.     decl String:tdisplay[64];
  580.     Format(tdisplay, sizeof(tdisplay), "%T", "Select paint for the current weapon", client);
  581.     AddMenuItem(menu2, "1", tdisplay);
  582.     Format(tdisplay, sizeof(tdisplay), "%T", "Select paint for each weapon", client);
  583.     AddMenuItem(menu2, "2", tdisplay);
  584.     //Format(tdisplay, sizeof(tdisplay), "%T", "Favorite paints", client);
  585.     //AddMenuItem(menu2, "3", tdisplay);
  586.    
  587.     DisplayMenu(menu2, client, 0);
  588. }
  589.  
  590. public Action:GetSkins(client, args)
  591. {  
  592.     Format(s_arma[client], 64, "none");
  593.     ShowMenuM(client);
  594.    
  595.     return Plugin_Handled;
  596. }
  597.  
  598. public Action:OnClientSayCommand(client, const String:command[], const String:sArgs[])
  599. {
  600.     if(StrEqual(sArgs, "!wskins", false) || StrEqual(sArgs, "!ws", false) || StrEqual(sArgs, "!paints", false))
  601.     {
  602.         Format(s_arma[client], 64, "none");
  603.         //ShowMenuM(client);
  604.        
  605.         if(saytimer != INVALID_HANDLE || g_saytimer == -1) return Plugin_Handled;
  606.         saytimer = CreateTimer(1.0*g_saytimer, Tsaytimer);
  607.         return Plugin_Continue;
  608.        
  609.     }
  610.     else if(StrEqual(sArgs, "!ss", false) || StrEqual(sArgs, "!showskin", false))
  611.     {
  612.         ShowSkin(client);
  613.        
  614.         if(saytimer != INVALID_HANDLE || g_saytimer == -1) return Plugin_Handled;
  615.         saytimer = CreateTimer(1.0*g_saytimer, Tsaytimer);
  616.         return Plugin_Continue;
  617.     }
  618.    
  619.     return Plugin_Continue;
  620. }
  621.  
  622. ShowSkin(client)
  623. {
  624.     new weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  625.     if(weapon < 1 || !IsValidEdict(weapon) || !IsValidEntity(weapon))
  626.     {
  627.         CPrintToChat(client, " {green}[WP]{default} %T", "Paint not found", client);
  628.         return;
  629.     }
  630.    
  631.     new buscar = GetEntProp(weapon,Prop_Send,"m_nFallbackPaintKit");
  632.     for(new i=1; i<g_paintCount[clientlang[client]];i++)
  633.     {
  634.         if(buscar == g_paints[clientlang[client]][i][index])
  635.         {
  636.             CPrintToChat(client, " {green}[WP]{default} %T", "Paint found", client, g_paints[clientlang[client]][i][Nombre]);
  637.             return;
  638.         }
  639.     }
  640.    
  641.     CPrintToChat(client, " {green}[WP]{default} %T", "Paint not found", client);
  642. }
  643.  
  644. public Action:Tsaytimer(Handle:timer)
  645. {
  646.     saytimer = INVALID_HANDLE;
  647. }
  648.  
  649. public Action:roundStart(Handle:event, const String:name[], bool:dontBroadcast)
  650. {
  651.     if(g_rtimer == -1) return;
  652.    
  653.     if(rtimer != INVALID_HANDLE)
  654.     {
  655.         KillTimer(rtimer);
  656.         rtimer = INVALID_HANDLE;
  657.     }
  658.    
  659.     rtimer = CreateTimer(1.0*g_rtimer, Rtimer);
  660. }
  661.  
  662. public Action:Rtimer(Handle:timer)
  663. {
  664.     rtimer = INVALID_HANDLE;
  665. }
  666.  
  667. public DIDMenuHandler_2(Handle:menu, MenuAction:action, client, itemNum)
  668. {
  669.     if ( action == MenuAction_Select )
  670.     {
  671.  
  672.        
  673.         decl String:info[4];
  674.        
  675.         GetMenuItem(menu, itemNum, info, sizeof(info));
  676.         new theindex = StringToInt(info);
  677.         if(theindex == 1) ShowMenu(client, 0);
  678.         else if(theindex == 2 && comprobado41[client]) ShowMenuArmas(client, 0);
  679.         //else if(theindex == 3) ShowMenuFav(client);
  680.     }
  681.     else if (action == MenuAction_End)
  682.     {
  683.         CloseHandle(menu);
  684.     }
  685. }
  686.  
  687. ShowMenuArmas(client, item)
  688. {  
  689.     if(menu1[client] == INVALID_HANDLE) CrearMenu1(client);
  690.     DisplayMenuAtItem(menu1[client], client, item, 0);
  691. }
  692.  
  693. public DIDMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
  694. {
  695.     if ( action == MenuAction_Select )
  696.     {
  697.         if(!comprobado41[client])
  698.         {
  699.             if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
  700.             return;
  701.         }
  702.        
  703.         decl String:Classname[64];
  704.         decl String:info[4];
  705.        
  706.         GetMenuItem(menu, itemNum, info, sizeof(info));
  707.         new theindex = StringToInt(info);
  708.        
  709.         if(StrEqual(s_arma[client], "none"))
  710.         {
  711.             if(GetUserAdmin(client) == INVALID_ADMIN_ID && rtimer == INVALID_HANDLE && g_rtimer != -1)
  712.             {
  713.                 CPrintToChat(client, " {green}[WP]{default} %T", "You can use this command only the first seconds", client, g_rtimer);
  714.                 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
  715.                 return;
  716.             }
  717.             if(!IsPlayerAlive(client))
  718.             {
  719.                 CPrintToChat(client, " {green}[WP]{default} %T", "You cant use this when you are dead", client);
  720.                 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
  721.                 return;
  722.             }
  723.             if(g_hosties && IsClientInLastRequest(client))
  724.             {
  725.                 CPrintToChat(client, " {green}[WP]{default} %T", "You cant use this when you are in a lastrequest", client);
  726.                 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
  727.                 return;
  728.             }
  729.  
  730.             if(theindex != -1 && !StrEqual(g_paints[clientlang[client]][theindex][flag], "0"))
  731.             {
  732.                 if(!CheckCommandAccess(client, "weaponpaints_override", ReadFlagString(g_paints[clientlang[client]][theindex][flag]), true))
  733.                 {
  734.                     CPrintToChat(client, " {green}[WP]{default} %T", "You dont have access to this paint", client);
  735.                     if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
  736.                     return;
  737.                 }
  738.             }
  739.            
  740.        
  741.             new windex = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  742.             if(windex < 1)
  743.             {
  744.                 CPrintToChat(client, " {green}[WP]{default} %T", "You cant use a paint in this weapon", client);
  745.                 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
  746.                 return;
  747.             }
  748.        
  749.        
  750.             if(!GetEdictClassname(windex, Classname, 64) || StrEqual(Classname, "weapon_taser") || (!g_c4 && StrEqual(Classname, "weapon_c4")))
  751.             {
  752.                 CPrintToChat(client, " {green}[WP]{default} %T", "You cant use a paint in this weapon", client);
  753.                 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
  754.                 return;
  755.             }
  756.             ReplaceString(Classname, 64, "weapon_", "");
  757.             new weaponindex = GetEntProp(windex, Prop_Send, "m_iItemDefinitionIndex");
  758.             if(weaponindex == 42 || weaponindex == 59)
  759.             {
  760.                 CPrintToChat(client, " {green}[WP]{default} %T", "You cant use a paint in this weapon", client);
  761.                 if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
  762.                 return;
  763.             }
  764.             if(GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY) == windex || GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY) == windex || GetPlayerWeaponSlot(client, CS_SLOT_KNIFE) == windex || (g_c4 && GetPlayerWeaponSlot(client, CS_SLOT_C4) == windex))
  765.             {
  766.                 switch (weaponindex)
  767.                 {
  768.                     case 60: strcopy(Classname, 64, "m4a1_silencer");
  769.                     case 61: strcopy(Classname, 64, "usp_silencer");
  770.                     case 63: strcopy(Classname, 64, "cz75a");
  771.                     case 500: strcopy(Classname, 64, "bayonet");
  772.                     case 506: strcopy(Classname, 64, "knife_gut");
  773.                     case 505: strcopy(Classname, 64, "knife_flip");
  774.                     case 508: strcopy(Classname, 64, "knife_m9_bayonet");
  775.                     case 507: strcopy(Classname, 64, "knife_karambit");
  776.                     case 509: strcopy(Classname, 64, "knife_tactical");
  777.                     case 515: strcopy(Classname, 64, "knife_butterfly");
  778.                     case 512: strcopy(Classname, 64, "knife_falchion");
  779.                     case 516: strcopy(Classname, 64, "knife_push");
  780.                     case 64: strcopy(Classname, 64, "revolver");
  781.                     case 514: strcopy(Classname, 64, "knife_survival_bowie");
  782.                 }
  783.                
  784.                 if(arbol[client] == INVALID_HANDLE)
  785.                 {
  786.                     //checked[client] = false;
  787.                     CreateTimer(0.0, Timer_ClientLanguage, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
  788.                     return;
  789.                 }
  790.                 else
  791.                 {
  792.                     new valor = 0;
  793.                     if(!GetTrieValue(arbol[client], Classname, valor))
  794.                     {
  795.                         CPrintToChat(client, " {green}[WP]{default} %T", "You cant use a paint in this weapon", client);
  796.                         if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
  797.                         return;
  798.                     }
  799.                    
  800.                     decl String:buffer[1024], String:nombres[64];
  801.                     if(theindex == -1) Format(nombres, sizeof(nombres), "default");
  802.                     else Format(nombres, sizeof(nombres), g_paints[clientlang[client]][theindex][Nombre]);
  803.                     decl String:steamid[32];
  804.                     GetClientAuthId(client, AuthId_Steam2,  steamid, sizeof(steamid) );
  805.                     Format(buffer, sizeof(buffer), "UPDATE weaponpaints SET %s = '%s' WHERE steamid = '%s';", Classname,nombres,steamid);
  806.                     LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
  807.                     SQL_TQuery(db, tbasico, buffer, GetClientUserId(client));
  808.                     SetTrieValue(arbol[client], Classname, theindex);
  809.                 }
  810.                
  811.                 //ChangePaint(client, windex, Classname, weaponindex, true);
  812.                 decl String:Classname2[64];
  813.                 Format(Classname2, 64, "weapon_%s", Classname);
  814.                 Restore(client, windex, Classname2, weaponindex);
  815.                 FakeClientCommand(client, "use %s", Classname2);
  816.                 if(theindex == -1) CPrintToChat(client, " {green}[WP]{default} %T","You have choose your default paint for your",client, Classname);
  817.                 else if(theindex == 0) CPrintToChat(client, " {green}[WP]{default} %T","You have choose a random paint for your",client, Classname);
  818.                 else CPrintToChat(client, " {green}[WP]{default} %T", "You have choose a weapon",client, g_paints[clientlang[client]][theindex][Nombre], Classname);
  819.                
  820.                 decl String:temp[128], String:temp1[64];
  821.                 if(theindex == -1) Format(temp, 128, "%s", Classname);
  822.                 else if (theindex == 0)
  823.                 {
  824.                
  825.                     Format(temp1, sizeof(temp1), "%T", "Random paint", client);
  826.                     Format(temp, 128, "%s - %s", Classname, temp1);
  827.                 }
  828.                 else Format(temp, 128, "%s - %s", Classname, g_paints[clientlang[client]][theindex][Nombre]);
  829.                 if(menu1[client] == INVALID_HANDLE) CrearMenu1(client);
  830.                 new imenu = FindStringInArray(array_armas, Classname);
  831.                 InsertMenuItem(menu1[client], imenu, Classname, temp);
  832.                 FindStringInArray(array_armas, Classname);
  833.                 RemoveMenuItem(menu1[client], imenu+1);
  834.             }
  835.             else CPrintToChat(client, " {green}[WP]{default} %T", "You cant use a paint in this weapon",client);
  836.            
  837.            
  838.         }
  839.         else
  840.         {
  841.             Format(Classname, 64, s_arma[client]);
  842.            
  843.             if(arbol[client] == INVALID_HANDLE)
  844.             {
  845.                 //checked[client] = false;
  846.                 CreateTimer(0.0, Timer_ClientLanguage, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
  847.                 return;
  848.             }
  849.             else
  850.             {
  851.                 decl String:buffer[1024], String:nombres[64];
  852.                 if(theindex == -1) Format(nombres, sizeof(nombres), "default");
  853.                 else Format(nombres, sizeof(nombres), g_paints[clientlang[client]][theindex][Nombre]);
  854.                 decl String:steamid[32];
  855.                 GetClientAuthId(client, AuthId_Steam2,  steamid, sizeof(steamid) );
  856.                 Format(buffer, sizeof(buffer), "UPDATE weaponpaints SET %s = '%s' WHERE steamid = '%s';", Classname,nombres,steamid);
  857.                 LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
  858.                 SQL_TQuery(db, tbasico, buffer, GetClientUserId(client));
  859.                 SetTrieValue(arbol[client], Classname, theindex);
  860.             }
  861.            
  862.             if(theindex == -1) CPrintToChat(client, " {green}[WP]{default} %T","You have choose your default paint for your",client, Classname);
  863.             else if(theindex == 0) CPrintToChat(client, " {green}[WP]{default} %T","You have choose a random paint for your",client, Classname);
  864.             else CPrintToChat(client, " {green}[WP]{default} %T", "You have choose a weapon",client, g_paints[clientlang[client]][theindex][Nombre], Classname);
  865.            
  866.             decl String:temp[128], String:temp1[64];
  867.             if(theindex == -1) Format(temp, 128, "%s", Classname);
  868.             else if (theindex == 0)
  869.             {
  870.                
  871.                 Format(temp1, sizeof(temp1), "%T", "Random paint", client);
  872.                 Format(temp, 128, "%s - %s", Classname, temp1);
  873.             }
  874.             else Format(temp, 128, "%s - %s", Classname, g_paints[clientlang[client]][theindex][Nombre]);
  875.             new imenu = FindStringInArray(array_armas, Classname);
  876.             InsertMenuItem(menu1[client], imenu, Classname, temp);
  877.             FindStringInArray(array_armas, Classname);
  878.             RemoveMenuItem(menu1[client], imenu+1);
  879.             Format(s_arma[client], 64, "none");
  880.             ShowMenuArmas(client, s_sele[client]);
  881.             return;
  882.         }
  883.        
  884.         if(g_rmenu) ShowMenu(client, GetMenuSelectionPosition());
  885.        
  886.     }
  887. }
  888.  
  889. /* public Action:RestoreItemID(Handle:timer, Handle:pack)
  890. {
  891.     new entity;
  892.     new m_iItemIDHigh;
  893.     new m_iItemIDLow;
  894.    
  895.     ResetPack(pack);
  896.     entity = EntRefToEntIndex(ReadPackCell(pack));
  897.     m_iItemIDHigh = ReadPackCell(pack);
  898.     m_iItemIDLow = ReadPackCell(pack);
  899.    
  900.     if(entity != INVALID_ENT_REFERENCE)
  901.     {
  902.         SetEntProp(entity,Prop_Send,"m_iItemIDHigh",m_iItemIDHigh);
  903.         SetEntProp(entity,Prop_Send,"m_iItemIDLow",m_iItemIDLow);
  904.     }
  905. } */
  906.  
  907. ReadPaints(index_new)
  908. {
  909.     array_paints[index_new] = CreateArray(128);
  910.     char code[64], language[128];
  911.     GetLanguageInfo(index_new, code, 64, language, 128);
  912.    
  913.     BuildPath(Path_SM, path_paints, sizeof(path_paints), "configs/csgo_wpaints_%s.cfg", language);
  914.    
  915.     if(!FileExists(path_paints)) BuildPath(Path_SM, path_paints, sizeof(path_paints), "configs/csgo_wpaints_english.cfg");
  916.    
  917.     decl Handle:kv;
  918.     g_paintCount[index_new] = 1;
  919.     ClearArray(array_paints[index_new]);
  920.     PushArrayString(array_paints[index_new], "random");
  921.     Format(g_paints[index_new][0][Nombre], 64, "random")
  922.  
  923.     kv = CreateKeyValues("Paints");
  924.     FileToKeyValues(kv, path_paints);
  925.  
  926.     if (!KvGotoFirstSubKey(kv)) {
  927.  
  928.         SetFailState("CFG File not found: %s", path_paints);
  929.         CloseHandle(kv);
  930.     }
  931.     do {
  932.  
  933.         KvGetSectionName(kv, g_paints[index_new][g_paintCount[index_new]][Nombre], 64);
  934.         g_paints[index_new][g_paintCount[index_new]][index] = KvGetNum(kv, "paint", 0);
  935.         g_paints[index_new][g_paintCount[index_new]][wear] = KvGetFloat(kv, "wear", 0.01);
  936.         g_paints[index_new][g_paintCount[index_new]][stattrak] = KvGetNum(kv, "stattrak", -2);
  937.         g_paints[index_new][g_paintCount[index_new]][quality] = KvGetNum(kv, "quality", 3);
  938.         g_paints[index_new][g_paintCount[index_new]][pattern] = KvGetNum(kv, "pattern", 0);
  939.         KvGetString(kv, "flag", g_paints[index_new][g_paintCount[index_new]][flag], 8, "0");
  940.  
  941.         PushArrayString(array_paints[index_new], g_paints[index_new][g_paintCount[index_new]][Nombre]);
  942.         g_paintCount[index_new]++;
  943.     } while (KvGotoNextKey(kv));
  944.     CloseHandle(kv);
  945.    
  946.     if(menuw[index_new] != INVALID_HANDLE) CloseHandle(menuw[index_new]);
  947.     menuw[index_new] = INVALID_HANDLE;
  948.    
  949.     menuw[index_new] = CreateMenu(DIDMenuHandler);
  950.    
  951.    
  952.     // TROLLING
  953.     SetMenuTitle(menuw[index_new], "( ͡° ͜ʖ ͡°)");
  954.     decl String:item[4];
  955.     AddMenuItem(menuw[index_new], "0", "Random paint");
  956.     AddMenuItem(menuw[index_new], "-1", "Default paint");
  957.     // FORGET THIS
  958.    
  959.     for (new i=g_paintCount[index_new]; i<MAX_PAINTS; ++i) {
  960.    
  961.         g_paints[index_new][i][index] = 0;
  962.     }
  963.     //decl String:menuitem[192];
  964.     for (new i=1; i<g_paintCount[index_new]; ++i) {
  965.         Format(item, 4, "%i", i);
  966.         AddMenuItem(menuw[index_new], item, g_paints[index_new][i][Nombre]);
  967.        
  968. /*      if(StrEqual(g_paints[g_paintCount][flag], "public", false))
  969.         {
  970.             AddMenuItem(menuw, item, g_paints[i][Nombre]);
  971.         }
  972.         else
  973.         {
  974.             Format(menuitem, 192, "%s (flag %s)", g_paints[i][Nombre],g_paints[i][flag]);
  975.             AddMenuItem(menuw, item, menuitem);
  976.         } */
  977.     }
  978.     SetMenuExitButton(menuw[index_new], true);
  979. }
  980.  
  981. /* stock GetReserveAmmo(client, weapon)
  982. {
  983.     new ammotype = GetEntProp(weapon, Prop_Send, "m_iPrimaryAmmoType");
  984.     if(ammotype == -1) return -1;
  985.    
  986.     return GetEntProp(client, Prop_Send, "m_iAmmo", _, ammotype);
  987. }
  988.  
  989. stock SetReserveAmmo(client, weapon, ammo)
  990. {
  991.     new ammotype = GetEntProp(weapon, Prop_Send, "m_iPrimaryAmmoType");
  992.     if(ammotype == -1) return;
  993.    
  994.     SetEntProp(client, Prop_Send, "m_iAmmo", ammo, _, ammotype);
  995. }  */
  996.  
  997. stock GetReserveAmmo(weapon)
  998. {
  999.     new ammotype = GetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount");
  1000.     if(ammotype == -1) return -1;
  1001.    
  1002.     return ammotype;
  1003. }
  1004.  
  1005. stock SetReserveAmmo(weapon, ammo)
  1006. {
  1007.     SetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount", ammo);
  1008.     //PrintToChatAll("fijar es %i", ammo);
  1009. }
  1010.  
  1011. Restore(client, windex, String:Classname[64], weaponindex)
  1012. {
  1013.     new bool:knife = false;
  1014.     if(StrContains(Classname, "weapon_knife", false) == 0 || StrContains(Classname, "weapon_bayonet", false) == 0)
  1015.     {
  1016.         knife = true;
  1017.     }
  1018.    
  1019.     //PrintToChat(client, "weapon %s", Classname);
  1020.     new ammo, clip;
  1021.     if(!knife)
  1022.     {
  1023.         ammo = GetReserveAmmo(windex);
  1024.         clip = GetEntProp(windex, Prop_Send, "m_iClip1");
  1025.     }
  1026.     RemovePlayerItem(client, windex);
  1027.     AcceptEntityInput(windex, "Kill");
  1028.    
  1029.     new entity;
  1030.     if(zombiesv && knife) GivePlayerItem(client, "weapon_knife");
  1031.     else entity = GivePlayerItem(client, Classname);
  1032.    
  1033.     if(knife)
  1034.     {
  1035.         if (weaponindex != 42 && weaponindex != 59 && !zombiesv)
  1036.             EquipPlayerWeapon(client, entity);
  1037.     }
  1038.     else
  1039.     {
  1040.         SetReserveAmmo(entity, ammo);
  1041.         SetEntProp(entity, Prop_Send, "m_iClip1", clip);
  1042.     }
  1043. }
  1044.  
  1045. ChangePaint(entity, theindex, client)
  1046. {
  1047.     if(theindex == 0)
  1048.     {
  1049.         theindex = GetRandomInt(1, g_paintCount[clientlang[client]]-1);
  1050.     }
  1051.     else if(theindex == -1) return;
  1052.    
  1053. /*  new m_iItemIDHigh = GetEntProp(entity, Prop_Send, "m_iItemIDHigh");
  1054.     new m_iItemIDLow = GetEntProp(entity, Prop_Send, "m_iItemIDLow"); */
  1055.  
  1056.     SetEntProp(entity,Prop_Send,"m_iItemIDLow",-1);
  1057.     //SetEntProp(entity,Prop_Send,"m_iItemIDHigh",0);
  1058.  
  1059.     SetEntProp(entity,Prop_Send,"m_nFallbackPaintKit",g_paints[clientlang[client]][theindex][index]);
  1060.     if(g_paints[clientlang[client]][theindex][wear] >= 0.0) SetEntPropFloat(entity,Prop_Send,"m_flFallbackWear",g_paints[clientlang[client]][theindex][wear]);
  1061.     if(g_paints[clientlang[client]][theindex][pattern] >= 0) SetEntProp(entity,Prop_Send,"m_nFallbackSeed",g_paints[clientlang[client]][theindex][pattern]);
  1062.     if(g_paints[clientlang[client]][theindex][stattrak] != -2) SetEntProp(entity,Prop_Send,"m_nFallbackStatTrak",g_paints[clientlang[client]][theindex][stattrak]);
  1063.     if(g_paints[clientlang[client]][theindex][quality] != -2) SetEntProp(entity,Prop_Send,"m_iEntityQuality",g_paints[clientlang[client]][theindex][quality]);
  1064.    
  1065. /*  new Handle:pack;
  1066.  
  1067.     CreateDataTimer(0.2, RestoreItemID, pack);
  1068.     WritePackCell(pack,EntIndexToEntRef(entity));
  1069.     WritePackCell(pack,m_iItemIDHigh);
  1070.     WritePackCell(pack,m_iItemIDLow); */
  1071. }
  1072.  
  1073. public OnClientPutInServer(client)
  1074. {
  1075.     //CreateTimer(1.0, Timer_ClientLanguage, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
  1076.     //checked[client] = false;
  1077.     if(!IsFakeClient(client)) SDKHook(client, SDKHook_WeaponEquipPost, OnPostWeaponEquip);
  1078. }
  1079.  
  1080. public Action:OnPostWeaponEquip(client, weapon)
  1081. {
  1082.     if(onlyadmin && GetUserAdmin(client) == INVALID_ADMIN_ID) return;
  1083.    
  1084.     if(weapon < 1 || !IsValidEdict(weapon) || !IsValidEntity(weapon)) return;
  1085.    
  1086.     if (GetEntProp(weapon, Prop_Send, "m_hPrevOwner") > 0)
  1087.         return;
  1088.        
  1089.     decl String:Classname[64];
  1090.     if(!GetEdictClassname(weapon, Classname, 64) || StrEqual(Classname, "weapon_taser") || (!g_c4 && StrEqual(Classname, "weapon_c4")))
  1091.     {
  1092.         return;
  1093.     }
  1094.     ReplaceString(Classname, 64, "weapon_", "");
  1095.     new weaponindex = GetEntProp(weapon, Prop_Send, "m_iItemDefinitionIndex");
  1096.     if(weaponindex == 42 || weaponindex == 59)
  1097.     {
  1098.         return;
  1099.     }
  1100.  
  1101.     switch (weaponindex)
  1102.     {
  1103.         case 60: strcopy(Classname, 64, "m4a1_silencer");
  1104.         case 61: strcopy(Classname, 64, "usp_silencer");
  1105.         case 63: strcopy(Classname, 64, "cz75a");
  1106.         case 500: strcopy(Classname, 64, "bayonet");
  1107.         case 506: strcopy(Classname, 64, "knife_gut");
  1108.         case 505: strcopy(Classname, 64, "knife_flip");
  1109.         case 508: strcopy(Classname, 64, "knife_m9_bayonet");
  1110.         case 507: strcopy(Classname, 64, "knife_karambit");
  1111.         case 509: strcopy(Classname, 64, "knife_tactical");
  1112.         case 515: strcopy(Classname, 64, "knife_butterfly");
  1113.         case 512: strcopy(Classname, 64, "knife_falchion");
  1114.         case 516: strcopy(Classname, 64, "knife_push");
  1115.         case 64: strcopy(Classname, 64, "revolver");
  1116.         case 514: strcopy(Classname, 64, "knife_survival_bowie");
  1117.     }
  1118.     if(arbol[client] == INVALID_HANDLE) return;
  1119.     new valor = 0;
  1120.     if(!GetTrieValue(arbol[client], Classname, valor)) return;
  1121.     if(valor == -1 || (valor != 0 && g_paints[clientlang[client]][valor][index] == 0)) return;
  1122.     //PrintToChat(client, "prueba");
  1123.     ChangePaint(weapon, valor, client);
  1124. }
  1125.  
  1126. SaveCookies(client)
  1127. {
  1128.     decl String:steamid[32];
  1129.     GetClientAuthId(client, AuthId_Steam2,  steamid, sizeof(steamid) );
  1130.     new String:Name[MAX_NAME_LENGTH+1];
  1131.     new String:SafeName[(sizeof(Name)*2)+1];
  1132.     if (!GetClientName(client, Name, sizeof(Name)))
  1133.         Format(SafeName, sizeof(SafeName), "<noname>");
  1134.     else
  1135.     {
  1136.         TrimString(Name);
  1137.         SQL_EscapeString(db, Name, SafeName, sizeof(SafeName));
  1138.     }  
  1139.  
  1140.     decl String:buffer[3096];
  1141.     Format(buffer, sizeof(buffer), "UPDATE weaponpaints SET last_accountuse = %d, playername = '%s' WHERE steamid = '%s';",GetTime(), SafeName,steamid);
  1142.     LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
  1143.     SQL_TQuery(db, tbasico2, buffer);
  1144. }
  1145.  
  1146. CrearMenu1(client)
  1147. {
  1148.    
  1149.     menu1[client] = CreateMenu(DIDMenuHandler_armas);
  1150.     SetMenuTitle(menu1[client], "%T","Menu title 1", client);
  1151.    
  1152.     new String:Items[64];
  1153.    
  1154.     decl String:temp[128], String:temp1[64];
  1155.     new valor;
  1156.     for(new i=0;i<GetArraySize(array_armas);++i)
  1157.     {
  1158.         GetArrayString(array_armas, i, Items, 64);
  1159.         if(GetTrieValue(arbol[client], Items, valor))
  1160.         {
  1161.             if(valor == -1) Format(temp, 128, "%s", Items);
  1162.             else if (valor == 0)
  1163.             {
  1164.                 Format(temp1, sizeof(temp1), "%T", "Random paint", client);
  1165.                 Format(temp, 128, "%s - %s", Items, temp1);
  1166.             }
  1167.             else Format(temp, 128, "%s - %s", Items, g_paints[clientlang[client]][valor][Nombre]);
  1168.         }
  1169.         else Format(temp, 128, "%s", Items);
  1170.         AddMenuItem(menu1[client], Items, temp);
  1171.     }
  1172. }
  1173.  
  1174. public DIDMenuHandler_armas(Handle:menu, MenuAction:action, client, itemNum)
  1175. {
  1176.     if ( action == MenuAction_Select )
  1177.     {
  1178.         decl String:info[64];
  1179.        
  1180.         GetMenuItem(menu, itemNum, info, sizeof(info));
  1181.  
  1182.         Format(s_arma[client], 64, info);
  1183.         s_sele[client] = GetMenuSelectionPosition();
  1184.         ShowMenu(client, 0);
  1185.     }
  1186. }
  1187.  
  1188. CheckSteamID(client)
  1189. {
  1190.     decl String:query[255], String:steamid[32];
  1191.     GetClientAuthId(client, AuthId_Steam2,  steamid, sizeof(steamid) );
  1192.    
  1193.     Format(query, sizeof(query), "SELECT * FROM weaponpaints WHERE steamid = '%s'", steamid);
  1194.     LogToFileEx(g_sCmdLogPath, "Query %s", query);
  1195.     SQL_TQuery(db, T_CheckSteamID, query, GetClientUserId(client));
  1196. }
  1197.  
  1198. public T_CheckSteamID(Handle:owner, Handle:hndl, const String:error[], any:data)
  1199. {
  1200.     new client;
  1201.  
  1202.     /* Make sure the client didn't disconnect while the thread was running */
  1203.     if ((client = GetClientOfUserId(data)) == 0)
  1204.     {
  1205.         return;
  1206.     }
  1207.     if (hndl == INVALID_HANDLE)
  1208.     {
  1209.         ComprobarDB();
  1210.         return;
  1211.     }
  1212.     //PrintToChatAll("comprobado41");
  1213.     if (!SQL_GetRowCount(hndl) || !SQL_FetchRow(hndl))
  1214.     {
  1215.         Nuevo(client);
  1216.         return;
  1217.     }
  1218.    
  1219.     arbol[client] = CreateTrie();
  1220.  
  1221.     new String:Items[64];
  1222.    
  1223.     new String:temp[64];
  1224.     new contar = 3;
  1225.     for(new i=0;i<GetArraySize(array_armas);++i)
  1226.     {
  1227.         GetArrayString(array_armas, i, Items, 64);
  1228.         SQL_FetchString(hndl, contar, temp, 64);
  1229.         SetTrieValue(arbol[client], Items, FindStringInArray(array_paints[clientlang[client]], temp));
  1230.        
  1231.         //LogMessage("Sacado %i del arma %s", FindStringInArray(array_paints, temp),Items);
  1232.        
  1233.         contar++;
  1234.     }
  1235.  
  1236. /*      SQL_FetchString(hndl, contar, temp, 64);
  1237.     SetTrieValue(arbol[client], "favorite1", FindStringInArray(array_paints, temp));
  1238.     contar++;
  1239.    
  1240.     SQL_FetchString(hndl, contar, temp, 64);
  1241.     SetTrieValue(arbol[client], "favorite2", FindStringInArray(array_paints, temp));
  1242.     contar++;
  1243.    
  1244.     SQL_FetchString(hndl, contar, temp, 64);
  1245.     SetTrieValue(arbol[client], "favorite3", FindStringInArray(array_paints, temp));
  1246.     contar++;
  1247.    
  1248.     SQL_FetchString(hndl, contar, temp, 64);
  1249.     SetTrieValue(arbol[client], "favorite4", FindStringInArray(array_paints, temp));
  1250.     contar++;
  1251.    
  1252.     SQL_FetchString(hndl, contar, temp, 64);
  1253.     SetTrieValue(arbol[client], "favorite5", FindStringInArray(array_paints, temp));
  1254.     contar++;
  1255.    
  1256.     SQL_FetchString(hndl, contar, temp, 64);
  1257.     SetTrieValue(arbol[client], "favorite6", FindStringInArray(array_paints, temp));
  1258.     contar++;
  1259.    
  1260.     SQL_FetchString(hndl, contar, temp, 64);
  1261.     SetTrieValue(arbol[client], "favorite7", FindStringInArray(array_paints, temp));
  1262.     contar++; */
  1263.    
  1264.    
  1265.     comprobado41[client] = true;
  1266. /*  new String:equipo[64];
  1267.     SQL_FetchString( hndl, 0, equipo, 64);
  1268.     PrintToChatAll(equipo);
  1269.    
  1270.     SQL_FetchString( hndl, 1, equipo, 64);
  1271.     PrintToChatAll(equipo);
  1272.    
  1273.     SQL_FetchString( hndl, 2, equipo, 64);
  1274.     PrintToChatAll(equipo);
  1275.    
  1276.     SQL_FetchString( hndl, 3, equipo, 64); // este
  1277.     PrintToChatAll(equipo); */
  1278.    
  1279.     //PrintToChatAll("pasado");
  1280.    
  1281. /*  new String:equipo[4];
  1282.     SQL_FetchString( hndl, 0, equipo, 4);
  1283.    
  1284.     if(StrEqual(equipo, "CT", false))
  1285.     {
  1286.         ft[client] = CS_TEAM_CT;
  1287.     }
  1288.     else if(StrEqual(equipo, "T", false))
  1289.     {
  1290.         ft[client] = CS_TEAM_T;
  1291.     } */
  1292.     Renovar(client);
  1293.  
  1294. }
  1295.  
  1296. Renovar(client)
  1297. {
  1298.     if(IsPlayerAlive(client))
  1299.     {
  1300.         char classname[64];
  1301.         int weaponIndex;
  1302.         for (new i = 0; i <= 3; i++)
  1303.         {
  1304.             if(i == CS_SLOT_GRENADE) continue;
  1305.            
  1306.             if ((weaponIndex = GetPlayerWeaponSlot(client, i)) != -1)
  1307.             {
  1308.                 GetEdictClassname(weaponIndex, classname, 64);
  1309.                
  1310.                 Restore(client, weaponIndex, classname, GetEntProp(weaponIndex, Prop_Send, "m_iItemDefinitionIndex"));
  1311.             }
  1312.         }
  1313.     }
  1314. }
  1315.  
  1316. Nuevo(client)
  1317. {
  1318.     //PrintToChatAll("metido");
  1319.     decl String:query[255], String:steamid[32];
  1320.     GetClientAuthId(client, AuthId_Steam2,  steamid, sizeof(steamid) );
  1321.     new userid = GetClientUserId(client);
  1322.    
  1323.     new String:Name[MAX_NAME_LENGTH+1];
  1324.     new String:SafeName[(sizeof(Name)*2)+1];
  1325.     if (!GetClientName(client, Name, sizeof(Name)))
  1326.         Format(SafeName, sizeof(SafeName), "<noname>");
  1327.     else
  1328.     {
  1329.         TrimString(Name);
  1330.         SQL_EscapeString(db, Name, SafeName, sizeof(SafeName));
  1331.     }
  1332.        
  1333.     Format(query, sizeof(query), "INSERT INTO weaponpaints(playername, steamid, last_accountuse) VALUES('%s', '%s', '%d');", SafeName, steamid, GetTime());
  1334.     LogToFileEx(g_sCmdLogPath, "Query %s", query);
  1335.     SQL_TQuery(db, tbasico3, query, userid);
  1336. }
  1337.  
  1338.  
  1339. public PruneDatabase()
  1340. {
  1341.     if (db == INVALID_HANDLE)
  1342.     {
  1343.         LogToFileEx(g_sCmdLogPath, "Prune Database: No connection");
  1344.         ComprobarDB();
  1345.         return;
  1346.     }
  1347.  
  1348.     new maxlastaccuse;
  1349.     maxlastaccuse = GetTime() - (IDAYS * 86400);
  1350.  
  1351.     decl String:buffer[1024];
  1352.  
  1353.     if (ismysql == 1)
  1354.         Format(buffer, sizeof(buffer), "DELETE FROM `weaponpaints` WHERE `last_accountuse`<'%d' AND `last_accountuse`>'0';", maxlastaccuse);
  1355.     else
  1356.         Format(buffer, sizeof(buffer), "DELETE FROM weaponpaints WHERE last_accountuse<'%d' AND last_accountuse>'0';", maxlastaccuse);
  1357.  
  1358.     LogToFileEx(g_sCmdLogPath, "Query %s", buffer);
  1359.     SQL_TQuery(db, tbasicoP, buffer);
  1360. }
  1361.  
  1362. public tbasico(Handle:owner, Handle:hndl, const String:error[], any:data)
  1363. {
  1364.     if (hndl == INVALID_HANDLE)
  1365.     {
  1366.         LogToFileEx(g_sCmdLogPath, "Query failure: %s", error);
  1367.     }
  1368.     new client;
  1369.  
  1370.     /* Make sure the client didn't disconnect while the thread was running */
  1371.     if ((client = GetClientOfUserId(data)) == 0)
  1372.     {
  1373.         return;
  1374.     }
  1375.     comprobado41[client] = true;
  1376.    
  1377. }
  1378.  
  1379. public tbasico2(Handle:owner, Handle:hndl, const String:error[], any:data)
  1380. {
  1381.     if (hndl == INVALID_HANDLE)
  1382.     {
  1383.         LogToFileEx(g_sCmdLogPath, "Query failure: %s", error);
  1384.         ComprobarDB();
  1385.     }
  1386. }
  1387.  
  1388. public tbasico3(Handle:owner, Handle:hndl, const String:error[], any:data)
  1389. {
  1390.     if (hndl == INVALID_HANDLE)
  1391.     {
  1392.         LogToFileEx(g_sCmdLogPath, "Query failure: %s", error);
  1393.         ComprobarDB();
  1394.     }
  1395.     new client;
  1396.  
  1397.     /* Make sure the client didn't disconnect while the thread was running */
  1398.     if ((client = GetClientOfUserId(data)) == 0)
  1399.     {
  1400.         return;
  1401.     }
  1402.    
  1403.     arbol[client] = CreateTrie();
  1404.  
  1405.     new String:Items[64];
  1406.    
  1407.     for(new i=0;i<GetArraySize(array_armas);++i)
  1408.     {
  1409.         GetArrayString(array_armas, i, Items, 64);
  1410.         SetTrieValue(arbol[client], Items, -1);
  1411.     }
  1412.    
  1413.     SetTrieValue(arbol[client], "favorite1", -1);
  1414.     SetTrieValue(arbol[client], "favorite2", -1);
  1415.     SetTrieValue(arbol[client], "favorite3", -1);
  1416.     SetTrieValue(arbol[client], "favorite4", -1);
  1417.     SetTrieValue(arbol[client], "favorite5", -1);
  1418.     SetTrieValue(arbol[client], "favorite6", -1);
  1419.     SetTrieValue(arbol[client], "favorite7", -1);
  1420.    
  1421.     comprobado41[client] = true;
  1422. }
  1423.  
  1424. public tbasicoC(Handle:owner, Handle:hndl, const String:error[], any:data)
  1425. {
  1426.     if (hndl == INVALID_HANDLE)
  1427.     {
  1428.         LogToFileEx(g_sCmdLogPath, "Query failure: %s", error);
  1429.     }
  1430.     //LogMessage("Database connection successful");
  1431.    
  1432.     for(new client = 1; client <= MaxClients; client++)
  1433.     {
  1434.         if(IsClientInGame(client))
  1435.         {
  1436.             //checked[client] = false;
  1437.             CreateTimer(0.0, Timer_ClientLanguage, GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
  1438.         }
  1439.     }
  1440. }
  1441.  
  1442. public tbasicoP(Handle:owner, Handle:hndl, const String:error[], any:data)
  1443. {
  1444.     if (hndl == INVALID_HANDLE)
  1445.     {
  1446.         LogToFileEx(g_sCmdLogPath, "Query failure: %s", error);
  1447.         ComprobarDB();
  1448.     }
  1449.     //LogMessage("Prune Database successful");
  1450. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement