Jump to content

[Help]|[Ayuda] Error!! Please Fix!!!


elfetoperez

Recommended Posts

Hola tienen alguna idea de este error ?

Hey you have some idea of this error?

login.lua:292: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

survivorSystem.lua:560: Bad argument @ 'giveWeapon' [Expected number at argument 3, got boolean]

  
-----survivorSystem.lua 
function rearmPlayerWeapon (weaponName,slot) 
  takeAllWeapons (source) 
  local ammoData,weapID = getWeaponAmmoType (weaponName) 
  if getElementData(source,ammoData) <= 0 then triggerClientEvent (source, "displayClientInfo", source,"Rearm",shownInfos["nomag"],89, 161, 58, 255) return end 
  setElementData(source,"currentweapon_"..slot,weaponName) 
  local weapon = getElementData(source,"currentweapon_1")  
    if weapon then  
    local ammoData,weapID = getWeaponAmmoType (weapon)  
    giveWeapon(source,weapID,getElementData(source,ammoData), false )  
    end 
  local weapon = getElementData(source,"currentweapon_2") 
  if weapon then 
    local ammoData,weapID = getWeaponAmmoType (weapon) 
    giveWeapon(source,weapID,getElementData(source,ammoData), false ) 
  end 
  local weapon = getElementData(source,"currentweapon_3") 
  if weapon then 
    local ammoData,weapID = getWeaponAmmoType (weapon) 
    giveWeapon(source,weapID,getElementData(source,ammoData), false ) 
  end 
  if elementWeaponBack[source] then 
    detachElementFromBone(elementWeaponBack[source]) 
    destroyElement(elementWeaponBack[source]) 
    elementWeaponBack[source] = false 
  end  
  if elementWeaponBack[source] then 
    detachElementFromBone(elementWeaponBack[source]) 
    destroyElement(elementWeaponBack[source])  
    elementWeaponBack[source] = false 
  end 
  setElementModel(source, getElementData(source,"skin")) 
end 
addEvent("onPlayerRearmWeapon",true) 
addEventHandler("onPlayerRearmWeapon",getRootElement(),rearmPlayerWeapon) 

  
-----login.lua  
function playerLogin(username, pass, player) 
  local playerID = getAccountData(getPlayerAccount(player),"playerID") 
  account = getPlayerAccount(player) 
  local x,y,z =  getAccountData(account,"last_x"),getAccountData(account,"last_y"),getAccountData(account,"last_z") 
  local skin = getAccountData(account,"skin") 
  createZombieTable (player) 
  if getAccountData(account,"isDead") then 
    spawnDayZPlayer(player) 
    return 
  end 
  spawnPlayer (player, x,y,z+0.5, math.random(0,360), skin, 0, 0) 
  setElementFrozen(player, true) 
  fadeCamera (player, true) 
  setCameraTarget (player, player) 
  setTimer( function(player) 
    if isElement(player) then 
      setElementFrozen(player, false) 
    end 
  end,500,1,player) 
  playerCol = createColSphere(x,y,z,1.5) 
  setElementData(player,"playerCol",playerCol) 
  attachElements ( playerCol, player, 0, 0, 0 ) 
  setElementData(playerCol,"parent",player) 
  setElementData(playerCol,"player",true) 
  for i,data in ipairs(playerDataTable) do 
    local elementData = getAccountData(account,data[1]) 
    if not elementData then 
      if data[1] == "brokenbone" or data[1] == "pain" or data[1] == "cold" or data[1] == "infection" or data[1] == "currentweapon_1" or data[1] == "currentweapon_2" or data[1] == "currentweapon_3" or data[1] == "bandit" then 
        elementData = elementData 
      else 
        elementData = 0 
      end 
    end 
    setElementData(player,data[1],elementData) 
  end 
  setElementData(player,"logedin",true) 
  --Weapons 
  --Old Weapons 
  local weapon = getElementData(player,"currentweapon_1") 
  if weapon then 
    local ammoData,weapID = getWeaponAmmoType (weapon) 
    giveWeapon(player,weapID,getElementData(player,ammoData), true ) 
  end 
  local weapon = getElementData(player,"currentweapon_2") 
  if weapon then 
    local ammoData,weapID = getWeaponAmmoType (weapon) 
    giveWeapon(player,weapID,getElementData(player,ammoData), false ) 
  end 
  local weapon = getElementData(player,"currentweapon_3") 
  if weapon then 
    local ammoData,weapID = getWeaponAmmoType (weapon) 
    giveWeapon(player,weapID,getElementData(player,ammoData), false ) 
  end 
  setElementModel(player, getElementData(player,"skin")) 
  
  setElementData(player,"admin",getAccountData(account,"admin") or false) 
  setElementData(player,"supporter",getAccountData(account,"supporter") or false) 
  triggerClientEvent(player, "onClientPlayerDayZLogin", player) 
   
end 
addEvent("onPlayerDayZLogin", true) 
addEventHandler("onPlayerDayZLogin", getRootElement(), playerLogin) 
  

Hay Solucion ?

Ayuda u.u Muchas gracias!!

-----------------------------------

No solution?

Please help!!!!!!

Link to comment

Does your setElementData name is actually a string from "ammoData" ?

   local ammoData,weapID = getWeaponAmmoType (weapon) 
 giveWeapon(source,weapID,getElementData(source,ammoData), false ) 
  

Your error means

getElementData(source,ammoData) 

returned false, so that there's no setElementData(source,ammoData,value).

Link to comment
No tested, but should work

Juste replace getElementData(player, ammoData) everytime by:

local iChangeThis = getElementData(player, ammoData) 
   giveWeapon(player,weapID,iChangeThis, false ) 

Does your setElementData name is actually a string from "ammoData" ?
   local ammoData,weapID = getWeaponAmmoType (weapon) 
 giveWeapon(source,weapID,getElementData(source,ammoData), false ) 
  

Your error means

getElementData(source,ammoData) 

returned false, so that there's no setElementData(source,ammoData,value).

Thanks brothers, I'll try!!!!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...