Guest User

xd

a guest
Nov 27th, 2019
187
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <cstrike>
  4. #include <clientprefs>
  5. #include <colors>
  6. #include <loghelper>
  7. #include <sdkhooks>
  8.  
  9. #pragma semicolon 1
  10.  
  11. #define MAX_WEAPON_COUNT 32
  12. #define SHOW_MENU -1
  13. #define CS_TEAM_SPECTATOR   1
  14. #define CS_TEAM_T           2
  15. #define CS_TEAM_CT          3
  16.  
  17. public Plugin:myinfo =
  18. {
  19.     name = "VIP",
  20.     author = "",
  21.     description = "",
  22.     version = "1.0",
  23.     url = ""
  24. };
  25.  
  26. new Handle:HP;
  27. new Handle:Gravity;
  28. new Handle:Speedy;
  29. new Handle:Smokegrenade;
  30. new Handle:Flashbang;
  31. new Handle:Hegrenade;
  32. new Handle:Molotov;
  33. new Handle:Decoy;
  34. new Handle:Tagrenade;
  35. new Handle:Healthshot;
  36. new Handle:Remove_grenade;
  37. new Handle:Armorvalue;
  38. new Handle:Bhashelmet;
  39. new Handle:Defuser;
  40. new Handle:Moneystart;
  41. new Handle:Bombplanted;
  42. new Handle:Bombdefused;
  43. new Handle:Headshot_money;
  44. new Handle:Headshot_hp;
  45. new Handle:Kill_money;
  46. new Handle:Kill_hp;
  47. new Handle:Tagtable;
  48. new Handle:Tagsay;
  49. new Handle:Double_jump;
  50. new Handle:Advertising;
  51. new Handle:Menu_round;
  52. new Handle:Menu_command;
  53. new Handle:Menu_onspawn;
  54.  
  55. new g_PrimaryGunCount;
  56. new g_SecondaryGunCount;
  57. new String:g_PrimaryGuns[MAX_WEAPON_COUNT][32];
  58. new String:g_SecondaryGuns[MAX_WEAPON_COUNT][32];
  59. new bool:g_MenuOpen[MAXPLAYERS+1] = {false, ...};
  60. new Handle:g_PrimaryMenu = INVALID_HANDLE;
  61. new Handle:g_SecondaryMenu = INVALID_HANDLE;
  62. new g_PlayerPrimary[MAXPLAYERS+1] = {-1, ...};
  63. new g_PlayerSecondary[MAXPLAYERS+1] = {-1, ...};
  64. new Rounds = 0;
  65. new const g_iaGrenadeOffsets[] = {15, 17, 16, 14, 18, 17};
  66.  
  67. public OnPluginStart()
  68. {
  69.     CreateConVar("sm_vip_version", "1.0", "VIP Plugin by ALP", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  70.    
  71.     HP = CreateConVar("vip_hp_start", "100", "Ilosc HP na start rundy", FCVAR_NOTIFY);
  72.     Gravity = CreateConVar("vip_gravity", "1.0", "Grawitacja (1.0 - standardowa)", FCVAR_PLUGIN);
  73.     Speedy = CreateConVar("vip_speed", "1.0", "Szybkosc biegania (1.0 - standardowo)", FCVAR_PLUGIN);
  74.     Smokegrenade = CreateConVar("vip_grenade_smokegrenade", "0", "Smoke na start rundy", FCVAR_NONE, true, 0.0, true, 1.0);
  75.     Flashbang = CreateConVar("vip_grenade_flashbang", "0", "Flash na start rundy (0-2))", FCVAR_NOTIFY);
  76.     Hegrenade = CreateConVar("vip_grenade_hegrenade", "0", "Granat na start rundy", FCVAR_NONE, true, 0.0, true, 1.0);
  77.     Molotov = CreateConVar("vip_grenade_molotov", "0", "Molotov dla tt lub Incendiary dla ct na start rundy",FCVAR_NONE, true, 0.0, true, 1.0);
  78.     Decoy = CreateConVar("vip_grenade_decoy", "0", "Decoy na start rundy", FCVAR_NONE, true, 0.0, true, 1.0);
  79.     Tagrenade = CreateConVar("vip_grenade_tagrenade", "0", "Granat taktyczny na start rundy",FCVAR_NONE, true, 0.0, true, 1.0);
  80.     Healthshot = CreateConVar("vip_grenade_healtshot", "0", "Apteczka na start rundy (0-4)", FCVAR_NOTIFY);
  81.     Remove_grenade = CreateConVar("vip_grenade_remove", "0", "Na początku rundy/respawn usuwa wszystkie granaty (Przydatne przy wypadaniu granatów", FCVAR_NONE, true, 0.0, true, 1.0);
  82.     Armorvalue = CreateConVar("vip_armorvalue", "0", "Kamizelka na start rundy", FCVAR_NONE, true, 0.0, true, 1.0);
  83.     Bhashelmet = CreateConVar("vip_bhashelmet", "0", "Kask na start rundy", FCVAR_NONE, true, 0.0, true, 1.0);
  84.     Defuser = CreateConVar("vip_defuser", "0", "Zestaw do rozbrajania dla CT na start rundy", FCVAR_NONE, true, 0.0, true, 1.0);
  85.     Moneystart = CreateConVar("vip_money_start", "0", "Ilosc $ na start rundy", FCVAR_NOTIFY);
  86.     Bombplanted = CreateConVar("vip_bomb_planted", "0", "Ilosc $ za podlozenie bomby", FCVAR_NOTIFY);
  87.     Bombdefused = CreateConVar("vip_bomb_defused", "0", "Ilosc $ za rozbrojenie bomby", FCVAR_NOTIFY);
  88.     Headshot_money = CreateConVar("vip_headshot_money", "0", "Ilosc $ za Headshot", FCVAR_NOTIFY);
  89.     Headshot_hp = CreateConVar("vip_headshot_hp", "0", "Ilosc HP za Headshot", FCVAR_NOTIFY);
  90.     Kill_money = CreateConVar("vip_kill_money", "0", "Ilosc $ za fraga", FCVAR_NOTIFY);
  91.     Kill_hp = CreateConVar("vip_kill_hp", "0", "Ilosc HP za fraga", FCVAR_NOTIFY);
  92.     Tagtable = CreateConVar("vip_tag_table", "0", "Tag VIP w tabeli wynikow", FCVAR_NONE, true, 0.0, true, 1.0);
  93.     Tagsay = CreateConVar("vip_tag_say", "0", "Tag VIP + kolorowy nick w say", FCVAR_NONE, true, 0.0, true, 1.0);
  94.     Double_jump = CreateConVar("vip_double_jump", "0", "Podwojny skok", FCVAR_NONE, true, 0.0, true, 1.0);
  95.     Advertising = CreateConVar("vip_advertising", "1", "Informacja o autorze pluginu", FCVAR_NONE, true, 0.0, true, 1.0);
  96.     Menu_round = CreateConVar("vip_menu", "0", "Od ktorej rundy menu broni jest aktywne (0-menu broni nieaktywne)", FCVAR_NOTIFY);
  97.     Menu_command = CreateConVar("vip_menu_command", "0", "Otwieranie menu broni po wpisaniu !bronie/!menu", FCVAR_NONE, true, 0.0, true, 1.0);
  98.     Menu_onspawn = CreateConVar("vip_menu_onspawn", "0", "Wyswietlanie menu przy respawn (Start rundy)", FCVAR_NONE, true, 0.0, true, 1.0);
  99.  
  100.     AutoExecConfig(true, "vip_alp");
  101.     CheckConfig("configs/vip_alp_weapons.ini");
  102.    
  103.     RegConsoleCmd("say", Command_SendToAll);
  104.     //RegConsoleCmd("say_team", Command_SendToTeam);
  105.     RegConsoleCmd("sm_menu", Command_VipMenu);
  106.     RegConsoleCmd("sm_bronie", Command_VipMenu);
  107.    
  108.     HookEvent("player_spawn", Event_OnPlayerSpawn);
  109.     HookEvent("bomb_planted", Event_BombPlanted);
  110.     HookEvent("bomb_defused", Event_BombDefused);
  111.     HookEvent("player_death",  Event_PlayerDeath);
  112.     HookEvent("player_team", Event_TagTable);
  113.     HookEvent("player_spawn", Event_TagTable);
  114.     HookEvent("round_start", Event_RoundStart);
  115.     HookEvent("announce_phase_end", RestartRound);
  116.     HookEvent("cs_intermission", RestartRound);
  117.    
  118.     CreateTimer(300.0, Timer_Advert, _, TIMER_REPEAT);
  119. }
  120.  
  121. public OnPluginEnd()
  122. {
  123.     CancelMenu(g_PrimaryMenu);
  124.     CheckCloseHandle(g_PrimaryMenu);
  125.     CancelMenu(g_SecondaryMenu);
  126.     CheckCloseHandle(g_SecondaryMenu);
  127. }
  128.  
  129.  
  130. public Action:Timer_Advert(Handle:timer)
  131. {
  132.     if (GetConVarBool(Advertising))
  133.     {
  134.     PrintToChatAll("\x01[\x04VIP\x01]\x04 Plugin VIP by ALP");
  135.     }
  136. }
  137.  
  138. public Event_OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
  139. {
  140.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  141.     new money = GetEntProp(client, Prop_Send, "m_iAccount");
  142.     new team = GetClientTeam(client);
  143.     new g_HP = GetConVarInt(HP);
  144.     new g_moneystart = GetConVarInt(Moneystart);
  145.     new g_Flashbang = GetConVarInt(Flashbang);
  146.     new g_Healthshot = GetConVarInt(Healthshot);
  147.    
  148.     if (client > 0 && IsPlayerAlive(client))
  149.     {
  150.         if (GetConVarBool(Remove_grenade)) StripNades(client);
  151.         if (IsPlayerGenericAdmin(client))
  152.  
  153.         {
  154.             SetEntityHealth(client, g_HP); //hp
  155.             SetEntityGravity(client, GetConVarFloat(Gravity)); //grawitacja
  156.             SetEntPropFloat(client, Prop_Send, "m_flLaggedMovementValue", GetConVarFloat(Speedy)); //predkosc biegania
  157.             if (GetConVarBool(Smokegrenade)) GivePlayerItem(client, "weapon_smokegrenade"); //smoke
  158.             if (GetConVarBool(Flashbang))
  159.             {
  160.                 for (new i = 1; i <= g_Flashbang; i++)
  161.                 GivePlayerItem(client, "weapon_flashbang");
  162.             }
  163.             if (GetConVarBool(Healthshot))
  164.             {
  165.                 for (new i = 1; i <= g_Healthshot; i++)
  166.                 GivePlayerItem(client, "weapon_healthshot");
  167.             }
  168.             if (GetConVarBool(Hegrenade)) GivePlayerItem(client, "weapon_hegrenade"); //grenade
  169.             if (GetConVarBool(Molotov) && team == CS_TEAM_T) GivePlayerItem(client, "weapon_molotov"); //molotov tt
  170.             if (GetConVarBool(Molotov) && team == CS_TEAM_CT) GivePlayerItem(client, "weapon_incgrenade"); //Incendiary ct
  171.             if (GetConVarBool(Decoy)) GivePlayerItem(client, "weapon_decoy"); //decoy
  172.             if (GetConVarBool(Tagrenade)) GivePlayerItem(client, "weapon_tagrenade"); //Taktyczny
  173.             SetEntProp(client, Prop_Send, "m_iAccount", money + g_moneystart); // plus $ na start
  174.             if (GetConVarBool(Armorvalue)) SetEntProp(client, Prop_Send, "m_ArmorValue", 100); //kamizelka
  175.             new g_menu_round = GetConVarInt(Menu_round);
  176.             if (GetConVarBool(Bhashelmet) && Rounds >= g_menu_round > 0 ){
  177.                  SetEntProp(client, Prop_Send, "m_bHasHelmet", 1);//helm
  178.             }
  179.            
  180.             if(team == CS_TEAM_CT)
  181.             {
  182.                 if (GetConVarBool(Defuser) && GetEntProp(client, Prop_Send, "m_bHasDefuser") == 0) GivePlayerItem(client, "item_defuser"); //kombinerki
  183.    
  184.             }
  185.             CreateTimer(0.1, Event_HandleSpawn, GetEventInt(event, "userid"));
  186.         }
  187.    
  188.     }
  189. }
  190.  
  191. stock StripNades(client)
  192. {
  193.     while(RemoveWeaponBySlot(client, 3)){}
  194.     for(new i = 0; i < 6; i++)
  195.     SetEntProp(client, Prop_Send, "m_iAmmo", 0, _, g_iaGrenadeOffsets[i]);
  196. }
  197. stock bool:RemoveWeaponBySlot(client, iSlot)
  198. {
  199.     new iEntity = GetPlayerWeaponSlot(client, iSlot);
  200.     if(IsValidEdict(iEntity)) {
  201.         RemovePlayerItem(client, iEntity);
  202.         AcceptEntityInput(iEntity, "Kill");
  203.         return true;
  204.     }
  205.     return false;
  206. }
  207.  
  208. public Event_BombPlanted(Handle:event, const String:name[], bool:dontBroadcast)
  209. {
  210.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  211.     new money = GetEntProp(client, Prop_Send, "m_iAccount");
  212.     new g_bombplanted = GetConVarInt(Bombplanted);
  213.    
  214.     if (IsPlayerGenericAdmin(client))
  215.    
  216.    
  217.     {
  218.         SetEntProp(client, Prop_Send, "m_iAccount", money + g_bombplanted);//plus $ for Bomb Planted
  219.        
  220.        
  221.     }
  222. }
  223.  
  224. public Event_BombDefused(Handle:event, const String:name[], bool:dontBroadcast)
  225. {
  226.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  227.     new money = GetEntProp(client, Prop_Send, "m_iAccount");
  228.     new g_bombdefused = GetConVarInt(Bombdefused);
  229.    
  230.     if (IsPlayerGenericAdmin(client))
  231.    
  232.    
  233.     {
  234.         SetEntProp(client, Prop_Send, "m_iAccount", money + g_bombdefused); //plus $ for Bomb Defused
  235.        
  236.        
  237.     }
  238. }
  239.  
  240. public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
  241. {
  242.     new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  243.     new money = GetEntProp(attacker, Prop_Send, "m_iAccount");
  244.     new health = GetEntProp(attacker, Prop_Send, "m_iHealth");
  245.     new g_headshot_money = GetConVarInt(Headshot_money);
  246.     new g_headshot_hp = GetConVarInt(Headshot_hp);
  247.     new g_kill_money = GetConVarInt(Kill_money);
  248.     new g_kill_hp = GetConVarInt(Kill_hp);
  249.    
  250.     new bool:headshot = GetEventBool(event, "headshot");
  251.     if (IsPlayerGenericAdmin(attacker))
  252.    
  253.    
  254.     {
  255.         if(headshot)
  256.        
  257.         {
  258.             SetEntProp(attacker, Prop_Send, "m_iAccount", money + g_headshot_money); //plus for hs
  259.             SetEntProp(attacker, Prop_Send, "m_iHealth", health + g_headshot_hp); //plus hp for hs
  260.            
  261.            
  262.         }
  263.         else
  264.        
  265.         {
  266.             SetEntProp(attacker, Prop_Send, "m_iAccount", money + g_kill_money); //plus for kill
  267.             SetEntProp(attacker, Prop_Send, "m_iHealth", health + g_kill_hp); //plus hp for kill
  268.            
  269.            
  270.         }
  271.        
  272.        
  273.     }
  274. }
  275.  
  276. public Action:Event_TagTable(Handle:event, String:name[], bool:dontBroadcast)
  277. {
  278.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  279.     if (IsPlayerGenericAdmin(client))
  280.    
  281.    
  282.     {
  283.         if (GetConVarBool(Tagtable)) CS_SetClientClanTag(client, "[VIP]");
  284.        
  285.        
  286.     }
  287. }
  288.  
  289. public Action:Command_SendToAll(client, args)
  290. {
  291.     if ((IsPlayerGenericAdmin(client)) && GetConVarBool(Tagsay))
  292.     {
  293.         new String:text[256];
  294.         GetCmdArg(1, text, sizeof(text));
  295.        
  296.         if (text[0] == '/' || text[0] == '@' || text[0] == '!' || text[0] == 0 || IsChatTrigger())
  297.         {
  298.             return Plugin_Handled;
  299.         }
  300.         if(IsPlayerAlive(client) && GetClientTeam(client) != 1)
  301.         {
  302.         PrintToChatAll("\x01[\x04VIP\x01]\x05 %N: \x01%s", client, text);
  303.         }
  304.         else if(!IsPlayerAlive(client) && GetClientTeam(client) != 1)
  305.         {
  306.         PrintToChatAll("\x01*NIE ZYJE* [\x04VIP\x01]\x05 %N: \x01%s", client, text);
  307.         }
  308.         else if(!IsPlayerAlive(client) && GetClientTeam(client) == 1)
  309.         {
  310.         PrintToChatAll("\x01*OBSERWATOR* [\x04VIP\x01]\x05 %N: \x01%s", client, text);
  311.         }
  312.         return Plugin_Handled;
  313.     }
  314.     return Plugin_Continue;
  315. }
  316.  
  317. public Action:Command_SendToTeam(client, args)
  318. {
  319.     if ((IsPlayerGenericAdmin(client)) && GetConVarBool(Tagsay))
  320.     {
  321.         new String:text[256];
  322.         GetCmdArg(1, text, sizeof(text));
  323.        
  324.         if (text[0] == '/' || text[0] == '@' || text[0] == '!' || text[0] == 0 || IsChatTrigger())
  325.         {
  326.             return Plugin_Handled;
  327.         }
  328.         for (new i = 1; i <= MaxClients; i++)
  329.         {
  330.             if (IsClientInGame(i) && IsClientConnected(i))
  331.             {
  332.                 if (GetClientTeam(client) == GetClientTeam(i))
  333.                 {
  334.                     if(GetClientTeam(client) == 2)
  335.                     {
  336.                         if(IsPlayerAlive(client))
  337.                         {
  338.                             PrintToChat(i, "\x01(Terrorysta) [\x04VIP\x01]\x05 %N \x01%s", client, text);
  339.                         }
  340.                         else if(!IsPlayerAlive(client))
  341.                         {
  342.                             PrintToChat(i, "\x01*NIE ZYJE*(Terrorysta) [\x04VIP\x01]\x05 %N \x01%s", client, text);
  343.                         }
  344.                         return Plugin_Handled;
  345.                     }
  346.                     else if(GetClientTeam(client) == 3)
  347.                     {
  348.                         if(IsPlayerAlive(client))
  349.                         {
  350.                         PrintToChat(i, "\x01(Antyterrorysta) [\x04VIP\x01]\x05 %N \x01%s", client, text);
  351.                         }
  352.                         else if(!IsPlayerAlive(client))
  353.                         {
  354.                         PrintToChat(i, "\x01*NIE ZYJE*(Antyterrorysta) [\x04VIP\x01]\x05 %N \x01%s", client, text);
  355.                         }
  356.                         return Plugin_Handled;
  357.                     }
  358.                     else if(GetClientTeam(client) == 1)
  359.                     {
  360.                         PrintToChat(i, "\x01[OBSERWATOR] [\x04VIP\x01]\x05 %N \x01%s", client, text);
  361.                         return Plugin_Handled;
  362.                     }
  363.                 }
  364.             }
  365.         }
  366.     }
  367.     return Plugin_Continue;
  368. }
  369.  
  370. public Action:OnPlayerRunCmd(iClient, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
  371. {
  372.     if ((IsPlayerGenericAdmin(iClient)) && IsPlayerAlive(iClient) && GetConVarBool(Double_jump))
  373.    
  374.    
  375.     {
  376.         static g_fLastButtons[MAXPLAYERS+1], g_fLastFlags[MAXPLAYERS+1], g_iJumps[MAXPLAYERS+1], fCurFlags, fCurButtons;
  377.         fCurFlags = GetEntityFlags(iClient);
  378.         fCurButtons = GetClientButtons(iClient);
  379.         if (g_fLastFlags[iClient] & FL_ONGROUND && !(fCurFlags & FL_ONGROUND) && !(g_fLastButtons[iClient] & IN_JUMP) && fCurButtons & IN_JUMP) g_iJumps[iClient]++;
  380.         else if(fCurFlags & FL_ONGROUND) g_iJumps[iClient] = 0;
  381.         else if(!(g_fLastButtons[iClient] & IN_JUMP) && fCurButtons & IN_JUMP && g_iJumps[iClient] == 1)
  382.        
  383.        
  384.         {
  385.             g_iJumps[iClient]++;
  386.             decl Float:vVel[3];
  387.             GetEntPropVector(iClient, Prop_Data, "m_vecVelocity", vVel);
  388.             vVel[2] = 250.0;
  389.             TeleportEntity(iClient, NULL_VECTOR, NULL_VECTOR, vVel);
  390.            
  391.            
  392.         }
  393.        
  394.         g_fLastFlags[iClient] = fCurFlags;
  395.         g_fLastButtons[iClient] = fCurButtons;
  396.        
  397.        
  398.     }
  399.     return Plugin_Continue;
  400. }
  401.  
  402. public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  403. {
  404.     Rounds = Rounds + 1;
  405. }
  406.  
  407. public Action:RestartRound(Handle:event, const String:name[], bool:dontBroadcast)
  408. {
  409.     Rounds = 0;
  410. }
  411.  
  412. public OnClientPutInServer(client)
  413. {
  414.     g_MenuOpen[client]=false;
  415.  
  416.     g_PlayerPrimary[client] = SHOW_MENU;
  417.     g_PlayerSecondary[client] = SHOW_MENU;
  418. }
  419.  
  420. public Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
  421. {
  422.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  423.     new team = GetClientTeam(client);
  424.  
  425.     if (g_MenuOpen[client] && team == CS_TEAM_SPECTATOR)
  426.     {
  427.         CancelClientMenu(client);       // Delayed
  428.         g_MenuOpen[client] = false;
  429.     }
  430. }
  431.  
  432. stock CheckConfig(const String:ini_file[])
  433. {
  434.     decl String:file[PLATFORM_MAX_PATH];
  435.     BuildPath(Path_SM, file, sizeof(file), ini_file);
  436.  
  437.     new timestamp = GetFileTime(file, FileTime_LastChange);
  438.  
  439.     if (timestamp == -1) SetFailState("\nCould not stat config file: %s.", file);
  440.  
  441.     InitializeMenus();
  442.     if (ParseConfigFile(file))
  443.     {
  444.         FinalizeMenus();
  445.     }
  446.    
  447. }
  448.  
  449. stock InitializeMenus()
  450. {
  451.     g_PrimaryGunCount=0;
  452.     CheckCloseHandle(g_PrimaryMenu);
  453.     g_PrimaryMenu = CreateMenu(MenuHandler_ChoosePrimary, MenuAction_Display|MenuAction_Select|MenuAction_Cancel);
  454.     SetMenuTitle(g_PrimaryMenu, "[VIP] Wybierz darmowa bron:");
  455.  
  456.     g_SecondaryGunCount=0;
  457.     CheckCloseHandle(g_SecondaryMenu);
  458.     g_SecondaryMenu = CreateMenu(MenuHandler_ChooseSecondary, MenuAction_Display|MenuAction_Select|MenuAction_Cancel);
  459.     SetMenuTitle(g_SecondaryMenu, "[VIP] Wybierz darmowa bron:");
  460. }
  461.  
  462. stock FinalizeMenus()
  463. {
  464.     AddMenuItem(g_PrimaryMenu, "FF", "None");
  465.     AddMenuItem(g_SecondaryMenu, "FF", "None");
  466. }
  467.  
  468. bool:ParseConfigFile(const String:file[]) {
  469.  
  470.     new Handle:parser = SMC_CreateParser();
  471.     SMC_SetReaders(parser, Config_NewSection, Config_UnknownKeyValue, Config_EndSection);
  472.     SMC_SetParseEnd(parser, Config_End);
  473.  
  474.     new line = 0;
  475.     new col = 0;
  476.     new String:error[128];
  477.     new SMCError:result = SMC_ParseFile(parser, file, line, col);
  478.     CloseHandle(parser);
  479.  
  480.     if (result != SMCError_Okay) {
  481.         SMC_GetErrorString(result, error, sizeof(error));
  482.         LogError("%s on line %d, col %d of %s", error, line, col, file);
  483.     }
  484.  
  485.     return (result == SMCError_Okay);
  486. }
  487.  
  488. new g_configLevel;
  489. public SMCResult:Config_NewSection(Handle:parser, const String:section[], bool:quotes)
  490. {
  491.     g_configLevel++;
  492.     if (g_configLevel==2)
  493.     {
  494.         if (StrEqual("PrimaryMenu", section, false)) SMC_SetReaders(parser, Config_NewSection, Config_PrimaryKeyValue, Config_EndSection);
  495.         else if (StrEqual("SecondaryMenu", section, false)) SMC_SetReaders(parser, Config_NewSection, Config_SecondaryKeyValue, Config_EndSection);
  496.     }
  497.     else SMC_SetReaders(parser, Config_NewSection, Config_UnknownKeyValue, Config_EndSection);
  498.     return SMCParse_Continue;
  499. }
  500.  
  501. public SMCResult:Config_UnknownKeyValue(Handle:parser, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes)
  502. {
  503.     SetFailState("\nDidn't recognize configuration: Level %i %s=%s", g_configLevel, key, value);
  504.     return SMCParse_Continue;
  505. }
  506.  
  507. public SMCResult:Config_PrimaryKeyValue(Handle:parser, const String:weapon_class[], const String:weapon_name[], bool:key_quotes, bool:value_quotes) {
  508.     if (g_PrimaryGunCount>=MAX_WEAPON_COUNT) SetFailState("\nToo many weapons declared!");
  509.  
  510.     decl String:weapon_id[4];
  511.     strcopy(g_PrimaryGuns[g_PrimaryGunCount], sizeof(g_PrimaryGuns[]), weapon_class);
  512.     Format(weapon_id, sizeof(weapon_id), "%02.2X", g_PrimaryGunCount++);
  513.     AddMenuItem(g_PrimaryMenu, weapon_id, weapon_name);
  514.     return SMCParse_Continue;
  515. }
  516.  
  517. public SMCResult:Config_SecondaryKeyValue(Handle:parser, const String:weapon_class[], const String:weapon_name[], bool:key_quotes, bool:value_quotes)
  518. {
  519.     if (g_SecondaryGunCount>=MAX_WEAPON_COUNT) SetFailState("\nToo many weapons declared!");
  520.  
  521.     decl String:weapon_id[4];
  522.     strcopy(g_SecondaryGuns[g_SecondaryGunCount], sizeof(g_SecondaryGuns[]), weapon_class);
  523.     Format(weapon_id, sizeof(weapon_id), "%02.2X", g_SecondaryGunCount++);
  524.     AddMenuItem(g_SecondaryMenu, weapon_id, weapon_name);
  525.     return SMCParse_Continue;
  526. }
  527.  
  528. public SMCResult:Config_EndSection(Handle:parser)
  529. {
  530.     g_configLevel--;
  531.     SMC_SetReaders(parser, Config_NewSection, Config_UnknownKeyValue, Config_EndSection);
  532.     return SMCParse_Continue;
  533. }
  534.  
  535. public Config_End(Handle:parser, bool:halted, bool:failed)
  536. {
  537.     if (failed) SetFailState("\nPlugin error");
  538. }
  539.  
  540. public MenuHandler_ChoosePrimary(Handle:menu, MenuAction:action, param1, param2)
  541. {
  542.     if (action == MenuAction_Display) g_MenuOpen[param1] = true;
  543.     else if (action == MenuAction_Select)
  544.     {
  545.         new client = param1;
  546.         new team = GetClientTeam(client);
  547.         decl String:weapon_id[4];
  548.         GetMenuItem(menu, param2, weapon_id, sizeof(weapon_id));
  549.         new weapon = StringToInt(weapon_id, 16);
  550.  
  551.         g_PlayerPrimary[client] = weapon;
  552.         if (team > CS_TEAM_SPECTATOR) GivePrimary(client);
  553.  
  554.         DisplayMenu(g_SecondaryMenu, client, MENU_TIME_FOREVER);
  555.     }
  556.     else if (action == MenuAction_Cancel)
  557.     {
  558.         g_MenuOpen[param1] = false;
  559.         if (param2 == MenuCancel_Exit)  // CancelClientMenu sends MenuCancel_Interrupted reason
  560.         {
  561.             if (g_SecondaryMenu != INVALID_HANDLE) DisplayMenu(g_SecondaryMenu, param1, MENU_TIME_FOREVER);
  562.         }
  563.     }
  564. }
  565.  
  566. public MenuHandler_ChooseSecondary(Handle:menu, MenuAction:action, param1, param2)
  567. {
  568.     if (action == MenuAction_Display) g_MenuOpen[param1] = true;
  569.     else if (action == MenuAction_Select)
  570.     {
  571.         new client = param1;
  572.         new team = GetClientTeam(client);
  573.         decl String:weapon_id[4];
  574.         GetMenuItem(menu, param2, weapon_id, sizeof(weapon_id));
  575.         new weapon = StringToInt(weapon_id, 16);
  576.  
  577.         g_PlayerSecondary[client] = weapon;
  578.         if (team > CS_TEAM_SPECTATOR) GiveSecondary(client);
  579.     }
  580.     else if (action == MenuAction_Cancel) g_MenuOpen[param1] = false;
  581. }
  582.  
  583. public Action:Event_HandleSpawn(Handle:timer, any:user)
  584. {
  585.     new client = GetClientOfUserId(user);
  586.     new g_menu_round = GetConVarInt(Menu_round);
  587.     if (!client) return;
  588.  
  589.     if (GetConVarBool(Menu_onspawn) && Rounds >= g_menu_round > 0 )
  590.     {
  591.         if (g_PlayerPrimary[client]==SHOW_MENU && g_PlayerSecondary[client]==SHOW_MENU)
  592.         {
  593.             if (g_PrimaryMenu != INVALID_HANDLE) DisplayMenu(g_PrimaryMenu, client, MENU_TIME_FOREVER);
  594.             else if (g_SecondaryMenu != INVALID_HANDLE) DisplayMenu(g_SecondaryMenu, client, MENU_TIME_FOREVER);
  595.         }
  596.         else
  597.         {
  598.             GivePrimary(client);
  599.             GiveSecondary(client);
  600.         }
  601.     }
  602. }
  603.  
  604. stock GivePrimary(client)
  605. {
  606.     new weapon = g_PlayerPrimary[client];
  607.     RemoveWeaponBySlot(client, 0);
  608.     if (weapon >= 0 && weapon < g_PrimaryGunCount) GivePlayerItem(client, g_PrimaryGuns[weapon]);
  609. }
  610.  
  611. stock GiveSecondary(client)
  612. {
  613.     new weapon = g_PlayerSecondary[client];
  614.     RemoveWeaponBySlot(client, 1);
  615.     if (weapon >= 0 && weapon < g_SecondaryGunCount) GivePlayerItem(client, g_SecondaryGuns[weapon]);
  616. }
  617.  
  618. public Action:Command_VipMenu(client, args)
  619. {
  620.     new g_menu_round = GetConVarInt(Menu_round);
  621.     if (IsPlayerGenericAdmin(client))
  622.     {
  623.         if (IsClientInGame(client) && Rounds >= g_menu_round > 0 && GetConVarBool(Menu_command))
  624.         {
  625.             if (g_PrimaryMenu != INVALID_HANDLE) DisplayMenu(g_PrimaryMenu, client, MENU_TIME_FOREVER);
  626.             else if (g_SecondaryMenu != INVALID_HANDLE) DisplayMenu(g_SecondaryMenu, client, MENU_TIME_FOREVER);
  627.         }
  628.     }
  629.     return Plugin_Continue;
  630. }
  631.  
  632. stock CheckCloseHandle(&Handle:handle)
  633. {
  634.     if (handle != INVALID_HANDLE)
  635.     {
  636.         CloseHandle(handle);
  637.         handle = INVALID_HANDLE;
  638.     }
  639. }
  640.  
  641.  
  642. stock min(a, b) {return (a<b) ? a:b;}
  643. stock max(a, b) {return (a>b) ? a:b;}
  644.  
  645. /*
  646. @param client id
  647.  
  648. return bool
  649. */
  650. bool:IsPlayerGenericAdmin(client)
  651. {
  652.     if (!CheckCommandAccess(client, "sm_vip", 0, true)) return false;  
  653.     {
  654.         return true;
  655.  
  656.     }
  657. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×