Skymagnum

Create a Class - Call of Duty(Multiplayer)

May 6th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.53 KB | None | 0 0
  1. function createClass(primaryWeapon, secondaryWeapon, taticalWeapons)
  2.  
  3. --[[ >>> EXAMPLE <<<
  4. createClass({"AN-94", attachment = {"Red Hot Sight", "Laser Sight", "Supressor"}, {"Executioner", attachment = {"Fast Reload", "Laser Sight", "Extended Mags"}, {"C-4", "Tatical Grenades"}}})
  5. ]]
  6.  
  7. local error = nil
  8.  
  9.     local primary = nil
  10.     local secondary = nil
  11.     local pAttachment = nil
  12.     local sAttachment = nil
  13.     local taticals = nil
  14.  
  15.     if type(primaryWeapon) ~= 'table' then
  16.         error = debug.traceback("Table expected(got, " .. type(primaryWeapon) .. ").")
  17.     end
  18.    
  19.     if type(secondaryWeapon) ~= 'table' then
  20.         error = debug.traceback("Table expected(got, " .. type(secondaryWeapon) .. ").")
  21.     end
  22.  
  23.     if type(taticalWeapons) ~= 'table' then
  24.         error = debug.traceback("Table expected(got, " .. type(taticalWeapons) .. ").")
  25.     end
  26.  
  27.     primary = setPrimaryWeapon(custom1, primaryWeapon[1])
  28.     secondary = setSecondaryWeapon(custom1, secondaryWeapon[1])
  29.    
  30.     for _, P in pairs(primaryWeapon.attachment)
  31.         pAttachment = addAttachment(custom1, primary, P)
  32.     end
  33.  
  34.     for _, S in pairs(secondaryWeapon.attachment)
  35.         sAttachment = addAttachment(custom1, secondary, S)
  36.     end
  37.  
  38.     for T = 1, #taticalWeapons do
  39.         taticals = addTaticals(custom1, taticalWeapons[T])
  40.     end
  41.  
  42.     if not error then
  43.         class = setClassWeapons(custom1, primary, secondary, pAttachment, sAttachment, taticals)
  44.     else
  45.         print(error)
  46.     end
  47.  
  48.     return classOutput(class)
  49. end
Advertisement
Add Comment
Please, Sign In to add comment