Advertisement
Alelluja

Untitled

Dec 18th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.94 KB | None | 0 0
  1. public skinsMenu(index, csw)
  2. {
  3.     new item[MAX_CHARS + 8],
  4.         menuIndex,
  5.         hasAccess[2],
  6.  
  7.         skinFlags,
  8.         skinLevelData,
  9.         skinCostData,
  10.  
  11.         costData[25],
  12.         levelData[25];
  13.  
  14.     log_amx("ID BRONI: (%i) 1", csw);
  15.  
  16.     isVip = get_user_flags(index) & vipFlag ? 1 : (get_user_flags(index) & svipFlag ? 2 : 0);
  17.  
  18.     // Get skin name if not default.
  19.     if(userSkin[index][csw] != -1)
  20.     {
  21.         ArrayGetString(skinName[csw], userSkin[index][csw], item, charsmax(item));
  22.     }
  23.    
  24.     // Create menu handler.
  25.     menuIndex = menu_create(fmt("Aktualny skin:\w %s\y^nWybierz nowego skina:", userSkin[index][csw] > -1 ? item : "Brak"), "skinsMenu_handler");
  26.  
  27.     // Add formated data as menu item.
  28.     menu_additem(menuIndex, "Domyslny", fmt("1#0#%i", csw));
  29.  
  30.     // Loop through every skin assigned to CSW_ index and add it's data to menu item.
  31.     ForDynamicArray(i, skinName[csw])
  32.     {
  33.         // Get skin access-data.
  34.         skinFlags = ArrayGetCell(skinAccess[csw], i);
  35.         skinLevelData = ArrayGetCell(skinLevel[csw], i);
  36.         skinCostData = ArrayGetCell(skinCost[csw], i);
  37.  
  38.         // Get skin name.
  39.         ArrayGetString(skinName[csw], i, item, charsmax(item));
  40.  
  41.         // User has access to that skin?
  42.         getSkinAccess(hasAccess, index, skinFlags, skinLevelData, skinCostData, item);
  43.  
  44.         if(isVip == 2)
  45.         {
  46.             skinCostData = floatround(float(skinCostData) * 0.55);
  47.         }
  48.         else if(isVip == 1)
  49.         {
  50.             skinCostData = floatround(float(skinCostData) * 0.75);
  51.         }
  52.  
  53.         if(skinLevelData)
  54.         {
  55.             formatex(levelData, charsmax(levelData), " Od: %i Levela", skinLevelData);
  56.         }
  57.  
  58.         if(skinCostData)
  59.         {
  60.             formatex(costData, charsmax(costData), " | Koszt: %i", skinCostData);
  61.         }
  62.  
  63.         // Add data to menu.
  64.         menu_additem(menuIndex, fmt("%s%s%s%s", hasAccess[0] ? "\w" : "\r", item, levelData, costData),
  65.             fmt("%i#%i#i", hasAccess[0], hasAccess[1], csw));
  66.     }
  67.  
  68.     menu_display(index, menuIndex);
  69.  
  70.     return PLUGIN_HANDLED;
  71. }
  72. /////OD TĄD///////
  73. public skinsMenu_handler(index, menu, item)
  74. {
  75.     if(item == MENU_EXIT)
  76.     {
  77.         menu_destroy(menu);
  78.         return PLUGIN_HANDLED;
  79.     }
  80.    
  81.     new readData[16],
  82.         intData[10][10],
  83.         weaponIndex,
  84.  
  85.         skinDataInt[4];
  86.    
  87.     // Read menu data.
  88.     menu_item_getinfo(menu, item, _, readData, charsmax(readData));
  89.    
  90.     // Get no-access data from menu info.
  91.     split(readData, intData[0], charsmax(intData[]), intData[1], charsmax(intData[]), "#");
  92.     split(intData[1], intData[1], charsmax(intData[]), intData[2], charsmax(intData[]), "#");
  93.  
  94.     menu_destroy(menu);
  95.  
  96.     // Convert string-data to integers.
  97.     ForRange(i, 0, 2)
  98.     {
  99.         skinDataInt[i] = str_to_num(intData[i]);
  100.     }
  101.    
  102.     // Return if user has no access.
  103.     if(!skinDataInt[0])
  104.     {
  105.         ColorChat(index, RED, "%s^x01 Nie masz dostepu do tego skina. %s.", logPrefix, (skinDataInt[1] == 1 ? "Brakuje Ci levela" : (skinDataInt[1] == 2 ? "Skin jest za drogi" : "Brakuje Ci flag")));
  106.    
  107.         return PLUGIN_HANDLED;
  108.     }
  109.    
  110.     new chosenWeaponName[MAX_CHARS];
  111.    
  112.     // Get CSW_ index.
  113.     weaponIndex = skinDataInt[2];
  114.    
  115.     // Get chosen weapon name.
  116.     getWeaponName(weaponIndex, chosenWeaponName, charsmax(chosenWeaponName));
  117.    
  118.     // Set user skin to chosen one.
  119.     userSkin[index][weaponIndex] = !item ? -1 : item - 1;
  120.  
  121.     log_amx("ID BRONI: (%i) 2", weaponIndex);
  122.    
  123.     // Notify about skin being set to chosen one.
  124.     if(!item)
  125.     {
  126.         ColorChat(index, RED, "%s^x01 Ustawiles domyslnego skina dla ^"^x03%s^x01^".", logPrefix, chosenWeaponName);
  127.     }
  128.     else
  129.     {
  130.         new chosenSkinName[MAX_CHARS];
  131.        
  132.         ArrayGetString(skinName[weaponIndex], userSkin[index][weaponIndex], chosenSkinName, charsmax(chosenSkinName));
  133.        
  134.         if(skinDataInt[0] == 1)
  135.         {
  136.             isVip = get_user_flags(index) & vipFlag ? 1 : (get_user_flags(index) & svipFlag ? 2 : 0);
  137.            
  138.             new cost = ArrayGetCell(skinCost[weaponIndex], userSkin[index][weaponIndex]);
  139.            
  140.             if(isVip == 2)
  141.             {
  142.                 cost = floatround(float(cost) * 0.55);
  143.             }
  144.             else if(isVip == 1)
  145.             {
  146.                 cost = floatround(float(cost) * 0.75);
  147.             }
  148.            
  149.             setUserCoins(index, getUserCoins(index) - cost);
  150.            
  151.             ColorChat(index, RED, "%s^x01 Kupiles skina ^"^x03%s^x01^" dla broni ^"^x03%s^x01^" za^x03 %i^x01.", logPrefix, chosenSkinName, chosenWeaponName, cost);
  152.            
  153.             saveUserSkins(index);
  154.  
  155.             log_amx("Kupienie Broni");
  156.         }
  157.         else
  158.         {
  159.             ColorChat(index, RED, "%s^x01 Ustawiles skina ^"^x03%s^x01^" dla broni ^"^x03%s^x01^".", logPrefix, chosenSkinName, chosenWeaponName);
  160.         }
  161.     }
  162.    
  163.     // Set new model if his current weapon is the one he just changed skin on.
  164.     if(get_user_weapon(index) == weaponIndex)
  165.     {
  166.         setViewmodel(index, weaponIndex);
  167.         log_amx("Ustawienie Modelu Broni: ID(%i) 1", weaponIndex);
  168.     }
  169.    
  170.     return PLUGIN_HANDLED;
  171. }
  172. /////DO TĄD////////
  173. public weaponDeploy(entity) ////TO DZIAŁA
  174. {
  175.     new index = pev(entity, pev_owner),
  176.         weapon = cs_get_weapon_id(entity);
  177.  
  178.     // Return if player isnt alive or his skin is default.
  179.     if(!is_user_alive(index) || userSkin[index][weapon] == -1)
  180.     {
  181.         return;
  182.     }
  183.  
  184.     setViewmodel(index, weapon);
  185.     log_amx("Ustawienie Modelu BRONI: ID(%i) 2", weapon);
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement