Jump to content

Ayuda con tablas


Narutimmy

Recommended Posts

Hola ammm hasta aqui llegue por mas que intente nose que mas hacer... asi que vengo a por ayuda :S

Sucede que a como yo lo tengo funciona pero los usuarios pierden municion y con la otra forma si tienes 2 armas del mismo tipo al disprarar te descuenta ammo de las 2.

Formar 1:

weaponAmmoTable = { 
["Berta Mag"] = {{"Berta", 22}},
["PB1s Mag"] = {{"PB1s", 23}},
---Nuevas
["Taser Battery"] = {{"Taser", 23}},
["Nails"] = {{"Nailgun", 23}},
 
---
["Desert Eagle Mag"] = {{"Desert Eagle", 24}},
["PDW Mag"] = {{"PDW", 28}},
["Viper 5 Mag"] = {{"Viper 5", 29}},
["AK Mag"] = {{"Ak74", 30}},
["14mm Ammo"] = {{"Hammerhead 47", 30}},
["LR300 Mag"] = {{"LR300", 31}},
["Thompson 1928 Mag"] = {{"Thompson 1928", 31}},
["Type 99 Mag"] = {{"Type 99", 30}},
["GAU-19 Mag"] = {{"GAU-19", 38}},
["TOS 34 Pellet"] = {{"TOS 34", 25}},
["BM16 Pellet"] = {{"BM16", 26}},
["SPSA 14 Pellet"] = {{"SPSA 14", 27}},
["SVDm 2 Mag"] = {{"SVDm 2", 34}},
["Gauss Rifle Mag"] = {{"Gauss Rifle", 34}},
["M-14 Camouflage Grid Mag"] = {{"M-14 Camouflage Grid", 34}},
[".50 Barret Mag"] = {{".50 Barret", 34}},
["Ballesta Mag"] = {{"Ballesta", 33}},
["Sig550 Mag"] = {{"Sig550", 33}},
["M136 Rocket"] = {{"Heat-Seeking RPG", 36},{"M136 Rocket Launcher", 35}},
["others"] = {{"Parachute", 46},{"C4", 39},{"Tear Gas", 17},{"Grenade", 16},{"Hunting Knife", 4},{"Machete", 8},{"Katana", 8},{"Fire Axe", 8},{"Binoculars", 43},{"Baseball Bat", 5},{"Shovel", 6},{"Golf Club", 2}}
}
 
function getWeaponAmmoType2(weaponName)
  for i, weaponData in ipairs(weaponAmmoTable.others) do
    if weaponName == weaponData[2] then
      return weaponData[1], weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["Berta Mag"]) do
    if weaponName == weaponData[2] then
      return "Berta Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["PB1s Mag"]) do
    if weaponName == weaponData[2] then
      return "PB1s Mag", weaponData[2]
    end
  end
  ---Nuevas 2
  for i, weaponData in ipairs(weaponAmmoTable["Taser Battery"]) do
    if weaponName == weaponData[2] then
      return "Taser Battery", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["Nails"]) do
    if weaponName == weaponData[2] then
      return "Nails", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["14mm Ammo"]) do
    if weaponName == weaponData[2] then
      return "14mm Ammo", weaponData[2]
    end
  end
 
 
 
  ---
  for i, weaponData in ipairs(weaponAmmoTable["Desert Eagle Mag"]) do
    if weaponName == weaponData[2] then
      return "Desert Eagle Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["PDW Mag"]) do
    if weaponName == weaponData[2] then
      return "PDW Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["Viper 5 Mag"]) do
    if weaponName == weaponData[2] then
      return "Viper 5 Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["AK Mag"]) do
    if weaponName == weaponData[2] then
      return "AK Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["LR300 Mag"]) do
    if weaponName == weaponData[2] then
      return "LR300 Mag", weaponData[2]
    end
  end
  ---Nuevas
  for i, weaponData in ipairs(weaponAmmoTable["Thompson 1928 Mag"]) do
    if weaponName == weaponData[2] then
      return "Thompson 1928 Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["Type 99 Mag"]) do
    if weaponName == weaponData[2] then
      return "Type 99 Mag", weaponData[2]
    end
  end
 
 
 
  ----
  for i, weaponData in ipairs(weaponAmmoTable["GAU-19 Mag"]) do
    if weaponName == weaponData[2] then
      return "GAU-19 Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["TOS 34 Pellet"]) do
    if weaponName == weaponData[2] then
      return "TOS 34 Pellet", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["SPSA 14 Pellet"]) do
    if weaponName == weaponData[2] then
      return "SPSA 14 Pellet", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["BM16 Pellet"]) do
    if weaponName == weaponData[1] then
      return "BM16 Pellet", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["SVDm 2 Mag"]) do
    if weaponName == weaponData[2] then
      return "SVDm 2 Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["SVDm 2 Mag"]) do
    if weaponName == weaponData[2] then
      return "Gauss Rifle Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["SVDm 2 Mag"]) do
    if weaponName == weaponData[2] then
      return "M-14 Camouflage Grid Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable[".50 Barret Mag"]) do
    if weaponName == weaponData[2] then
      return ".50 Barret Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["Ballesta Mag"]) do
    if weaponName == weaponData[2] then
      return "Ballesta Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["Sig550 Mag"]) do
    if weaponName == weaponData[2] then
      return "Sig550 Mag", weaponData[2]
    end
  end
  for i, weaponData in ipairs(weaponAmmoTable["M136 Rocket"]) do
    if weaponName == weaponData[2] then
      return "M136 Rocket", weaponData[2]
    end
  end
end
 
 
function weaponSwitch(weapon)
   
       
   
   if source == getLocalPlayer() then
   
   
    local wpn = getElementData(getLocalPlayer(), "currentweapon_1")
    if wpn == "BM16" then
        if getElementData(getLocalPlayer(), "BM16 Pellet") > 0 then
         setElementData(getLocalPlayer(), "BM16 Pellet", getElementData(getLocalPlayer(), "BM16 Pellet") - 1)
        end
    end
    local wpn = getElementData(getLocalPlayer(), "currentweapon_1")
    if wpn == ".50 Barret" then
        if getElementData(getLocalPlayer(), ".50 Barret Mag") > 0 then
         setElementData(getLocalPlayer(), ".50 Barret Mag", getElementData(getLocalPlayer(), ".50 Barret Mag") - 1)
        end
    end
    local wpn = getElementData(getLocalPlayer(), "currentweapon_1")
    if wpn == "Sig550" then
        if getElementData(getLocalPlayer(), "Sig550 Mag") > 0 then
         setElementData(getLocalPlayer(), "Sig550 Mag", getElementData(getLocalPlayer(), "Sig550 Mag") - 1)
        end
    end
    local wpn = getElementData(getLocalPlayer(), "currentweapon_1")
    if wpn == "Gauss Rifle" then
        if getElementData(getLocalPlayer(), "Gauss Rifle Mag") > 0 then
         setElementData(getLocalPlayer(), "Gauss Rifle Mag", getElementData(getLocalPlayer(), "Gauss Rifle Mag") - 1)
        end
    end
    local wpn = getElementData(getLocalPlayer(), "currentweapon_1")
    if wpn == "M-14 Camouflage Grid" then
        if getElementData(getLocalPlayer(), "M-14 Camouflage Grid Mag") > 0 then
         setElementData(getLocalPlayer(), "M-14 Camouflage Grid Mag", getElementData(getLocalPlayer(), "M-14 Camouflage Grid Mag") - 1)
        end
    end
    local wpn = getElementData(getLocalPlayer(), "currentweapon_1")
    if wpn == "Thompson 1928" then
        if getElementData(getLocalPlayer(), "Thompson 1928 Mag") > 0 then
         setElementData(getLocalPlayer(), "Thompson 1928 Mag", getElementData(getLocalPlayer(), "Thompson 1928 Mag") - 1)
        end
    end
    local wpn = getElementData(getLocalPlayer(), "currentweapon_1")
    if wpn == "Type 99" then
        if getElementData(getLocalPlayer(), "Type 99 Mag") > 0 then
         setElementData(getLocalPlayer(), "Type 99 Mag", getElementData(getLocalPlayer(), "Type 99 Mag") - 1)
        end
        end
    local wpn = getElementData(getLocalPlayer(), "currentweapon_1")
    if wpn == "Ak74" then
        if getElementData(getLocalPlayer(), "AK Mag") > 0 then
         setElementData(getLocalPlayer(), "AK Mag", getElementData(getLocalPlayer(), "AK Mag") - 1)
        end
    end
    local wpn2 = getElementData(getLocalPlayer(), "currentweapon_2")
    if wpn2 == "Nailgun" then
        if getElementData(getLocalPlayer(), "Nails") > 0 then
         setElementData(getLocalPlayer(), "Nails", getElementData(getLocalPlayer(), "Nails") - 1)
        end
    end
    local wpn2 = getElementData(getLocalPlayer(), "currentweapon_2")
    if wpn2 == "Taser" then
        if getElementData(getLocalPlayer(), "Taser Battery") > 0 then
         setElementData(getLocalPlayer(), "Taser Battery", getElementData(getLocalPlayer(), "Taser Battery") - 1)
        end
    end
    ---
    local wpn2 = getElementData(getLocalPlayer(), "currentweapon_2")
    if wpn2 == "PB1s" then
        if getElementData(getLocalPlayer(), "PB1s Mag") > 0 then
         setElementData(getLocalPlayer(), "PB1s Mag", getElementData(getLocalPlayer(), "PB1s Mag") - 1)
        end
    end
    local wpn2 = getElementData(getLocalPlayer(), "currentweapon_2")
    if wpn2 == "Berta" then
        if getElementData(getLocalPlayer(), "Berta Mag") > 0 then
         setElementData(getLocalPlayer(), "Berta Mag", getElementData(getLocalPlayer(), "Berta Mag") - 1)
        end
    end
    local wpn2 = getElementData(getLocalPlayer(), "currentweapon_2")
    if wpn2 == "Desert Eagle" then
        if getElementData(getLocalPlayer(), "Desert Eagle") > 0 then
         setElementData(getLocalPlayer(), "Desert Eagle Mag", getElementData(getLocalPlayer(), "Desert Eagle Mag") - 1)
        end
    end
   
Link to comment
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...