Jump to content

attempt to perform arithmetic on a boolean value


Recommended Posts

TankPedSkins = {44,45,46,47,48 } --ALTERNATE SKIN LISTS FOR ZOMBIES (SHORTER LIST IS TEXTURED ZOMBIES ONLY) 
  
setElementData(getRootElement(),"tankstotal",0) 
setElementData(getRootElement(),"tanksalive",0) 
createTeam("Tanks") 
  
itemTableTanks = { 
{"Box of Matches",328,0.4,90,5}, 
{"Wood Pile",1463,0.4,0,5}, 
{"M1911",346,1,90,0.4}, 
{"M9 SD",347,1,90,0.4}, 
{"Winchester 1866",349,1,90,0.4}, 
{"PDW",352,1,90,0.3}, 
{"Hunting Knife",335,1,90,7}, 
{"Hatchet",339,1,90,7}, 
{"Pizza",1582,1,0,7}, 
{"Soda Bottle",2647,1,0,7}, 
{"Empty Gas Canister",1650,1,0,5}, 
{"Roadflare",324,1,90,9}, 
{"Milk",2856,1,0,5}, 
{"Assault Pack (ACU)",3026,0.5,0,6}, 
{"Painkiller",2709,0.5,0,7}, 
{"Empty Soda Cans",2673,0.5,0,6}, 
{"Scruffy Burgers",2675,0.5,0,6}, 
{"Grenade",342,1,0,0.5}, 
{"Desert Eagle",348,1,90,0.3}, 
{"Sawn-Off Shotgun",350,1,90,0.2}, 
{"SPAZ-12 Combat Shotgun",351,1,90,0.2}, 
{"MP5A5",353,1,90,0.1}, 
{"Watch",2710,1,0,3}, 
{"Heat Pack",1576,1,0,6}, 
{"Wire Fence",933,0.25,0,1}, 
{"Lee Enfield",357,1,90,0.2}, 
{"Alice Pack",3026,1,0,0.5}, 
{"Tire",1073,1,0,1}, 
{"Morphine",1579,1,0,2}, 
{"Civilian Clothing",1577,1,0,12}, 
{"Map",1277,0.8,90,4}, 
{"GPS",2976,0.15,0,1}, 
{"Pasta Can",2770,0.1,0,5}, 
{"Beans Can",2601,1,0,5}, 
{"Burger",2768,1,0,2}, 
{"Radio Device",2966,0.5,0,3}, 
{"Golf Club",333,1,90,0.5}, 
{"Baseball Bat",336,1,90,0.5}, 
{"Shovel",337,1,90,0.5}, 
} 
  
function createTankTable (player) 
      --createtabel 
      setElementData(player,"playerTanks",{"no","no","no","no","no","no","no","no","no"}) 
      setElementData(player,"spawnedtanks",0) 
end 
  
function createTankForPlayer (x,y,z) 
   x,y,z = getElementPosition(source) 
   counter = 0 
   if getElementData(source,"lasttankspawnposition") then 
      local xL,yL,zL = getElementData(source,"lasttankspawnposition")[1] or false,getElementData(source,"lasttankspawnposition")[2] or false,getElementData(source,"lasttankspawnposition")[3] or false 
      if xL then 
         if getDistanceBetweenPoints3D (x,y,z,xL,yL,zL) < 50 then 
            --outputChatBox("Server: canceled zombie create (reason: is near old position)") 
            return 
         end 
      end 
   end    
   if getElementData(source,"spawnedtanks")+3 <= gameplayVariables.playertanks then -- If spawned zombies + 3 lower or equal to 9 -> Create zombies -> Increase digit (default: 9) to let more zombies spawn. WARNING: THE HIGHER THE VALUE, THE MORE LAG CAN OCCUR! 
   for i = 1, gameplayVariables.amounttanks do --Amount of zombies to be spawned (default: 3) WARNING: THE HIGHER THE VALUE, THE MORE LAG CAN OCCUR! 
      counter = counter+1 
      local number1 = math.random(-50,50) 
      local number2 = math.random(-50,50) 
      if number1 < 18 and number1 > -18 then 
         number1 = 20 
      end 
      if number2 < 18 and number2 > -18 then 
         number2 = -20 
      end 
      randomTskin = math.random ( 1, table.getn ( TankPedSkins ) )    
      tank = call (getResourceFromName("slothbot"),"spawnBot",x+number1,y+number2,z,math.random(0,360),TankPedSkins[randomTskin],0,0,getTeamFromName("Tanks")) 
      setElementData(tank,"tank",true) 
      setElementData(tank,"blood",gameplayVariables["tankblood"]) -- [iD:0000009 - Zombie menace] //L 
      setElementData(tank,"owner",source) 
      call ( getResourceFromName ( "slothbot" ), "setBotGuard", tank, x+number1,y+number2,z, false) 
      --outputChatBox("Server: zombie created (reason: )") 
      ------------------- 
   end 
   setElementData(source,"lasttankspawnposition",{x,y,z}) 
   setElementData(source,"spawnedtanks",getElementData(source,"spawnedtanks")+3) 
   end 
end 
addEvent("createTankForPlayer",true) 
addEventHandler("createTankForPlayer",getRootElement(),createTankForPlayer) 
  
function tankCheck1 () 
for i,ped in ipairs(getElementsByType("ped")) do 
   if getElementData(ped,"tank") then  
      goReturn = false 
      local tankCreator = getElementData(ped,"owner") 
      if not isElement(tankCreator) then  
         outputDebugString("test") 
         setElementData ( ped, "status", "dead" )    
         setElementData ( ped, "target", nil ) 
         setElementData ( ped, "leader", nil ) 
         destroyElement(ped) 
         goReturn = true 
      end 
      if not goReturn then 
      local xZ,yZ,zZ = getElementPosition(getElementData(ped,"owner")) 
      local x,y,z = getElementPosition(ped) 
      if getDistanceBetweenPoints3D (x,y,z,xZ,yZ,zZ) > 60 then 
         if getElementData(tankCreator,"spawnedtanks")-1 >= 0 then 
            setElementData(tankCreator,"spawnedtanks",getElementData(tankCreator,"spawnedtanks")-1) 
         end    
         setElementData ( ped, "status", "dead" )    
         setElementData ( ped, "target", nil ) 
         setElementData ( ped, "leader", nil ) 
         destroyElement(ped) 
      end 
      end 
   end             
end       
end 
setTimer(tankCheck1,20000,0) 
  
function botAttack (ped) 
   call ( getResourceFromName ( "slothbot" ), "setBotFollow", ped, source) 
end 
addEvent("botAttack",true) 
addEventHandler("botAttack",getRootElement(),botAttack) 
  
function botStopFollow (ped) 
   local x,y,z = getElementPositon(ped) 
   call ( getResourceFromName ( "slothbot" ), "setBotGuard", ped, x, y, z, false) 
end 
addEvent("botStopFollow",true) 
addEventHandler("botStopFollow",getRootElement(),botStopFollow) 
  
function outputChange(dataName,oldValue) 
   if getElementType(source) == "player" then -- check if the element is a player 
      if dataName == "spawnedtanks" then 
         local newValue = getElementData(source,dataName) -- find the new value 
         outputChatBox(oldValue.." to "..newValue) -- output the change for the affected player 
      end 
   end 
end 
--addEventHandler("onElementDataChange",getRootElement(),outputChange) 
  
function destroyTable () 
for i,ped in ipairs(getElementsByType("ped")) do 
   if getElementData(ped,"tank") then  
      if getElementData(ped,"owner") == source then 
         setElementData(getElementData(ped,"owner"),"spawnedtanks",getElementData(getElementData(ped,"owner"),"spawnedtanks")-1) 
         setElementData ( ped, "status", "dead" ) 
         setElementData ( ped, "target", nil ) 
         setElementData ( ped, "leader", nil ) 
         destroyElement(ped) 
      end 
   end             
end 
end 
--addEventHandler("kilLDayZPlayer",getRootElement(),destroyTable) 
--addEventHandler("onPlayerQuit",getRootElement(),destroyTable) 
  
function destroyDeadTank (ped,pedCol) 
   destroyElement(ped) 
   destroyElement(pedCol) 
end 
  
function tankKilled (killer,headshot) 
--outputChatBox("Server: destroyed zombie (reason: zombie died)") 
   if killer then 
      setElementData(killer,"tankskilled",getElementData(killer,"tankskilled")+1) 
   end    
      local skin = getElementModel(source) 
      local x,y,z = getElementPosition(source) 
      local ped = createPed(skin,x,y,z) 
      local pedCol = createColSphere(x,y,z,1.5) 
      killPed(ped) 
      setTimer(destroyDeadTank,360000 ,1,ped,pedCol) 
      attachElements (pedCol,ped,0,0,0) 
      setElementData(pedCol,"parent",ped) 
      setElementData(pedCol,"playername","Tank") 
      setElementData(pedCol,"deadman",true) 
      setElementData(ped,"deadtank",true) 
      setElementData(pedCol,"deadman",true) 
      local time = getRealTime() 
      local hours = time.hour 
      local minutes = time.minute 
      setElementData(pedCol,"deadreason","Looks like it's finally dead. Estimated time of death: "..hours..":"..minutes.." o'clock.") 
      for i, item in ipairs(itemTableTanks) do 
         local value =  math.percentChance (item[5]/2.5,1) 
            setElementData(pedCol,item[1],value) 
         --weapon Ammo 
         local ammoData,weapID = getWeaponAmmoType (item[1],true) 
            if ammoData and value > 0 then 
               setElementData(pedCol,ammoData,1) 
            end 
         end 
      local tankCreator = getElementData(source,"owner") 
      setElementData(tankCreator,"spawnedtanks",getElementData(tankCreator,"spawnedtanks")-1) 
      destroyElement(source) 
      if headshot == true then 
         setElementData(killer,"headshots",getElementData(killer,"headshots")+1) 
      end    
end 
addEvent("onTankGetsKilled",true) 
addEventHandler("onTankGetsKilled",getRootElement(),tankKilled) 

boss.lua:67: attempt to perform arithmetic on a boolean value :?

gameplayVariables = {} 
  
    gameplayVariables["zombieblood"] = 3000 -- Zombie Blood/Health - DEFAULT: 6000 
    gameplayVariables["tankblood"] = 15000 -- 
    gameplayVariables["foodrestore"] = math.random(50,100) -- Amount of hunger to be restored when eating - DEFAULT: math.random(40,100) - FOR FULL RESTORE, JUST WRITE 100 
    gameplayVariables["thirstrestore"] = math.random(50,100) -- Amount of hunger to be restored when drinking - DEFAULT: math.random(40,100) - FOR FULL RESTORE, JUST WRITE 100 
    gameplayVariables["loseHunger"] = -1.5 -- Amount of losing hunger per minute - DEFAULT: -1.5 
    gameplayVariables["loseThirst"] = -1.5 -- Amount of losing thirst per minute - DEFAULT: -1.5 
    gameplayVariables["playerzombies"] = 1 -- Amount of spawning zombies per player - DEFAULT: 3 - THE HIGHER THIS VALUE, THE MORE LAG CAN OCCUR! 
    gameplayVariables["amountzombies"] = 2 -- Amount of zombies - DEFAULT: 4 - THE HIGHER THIS VALUE, THE MORE LAG CAN OCCUR! 
    gameplayVariables["playertanks"] = 3 -- 
    gameplayVariables["amounttanks"] = 5 

pls help me :cry:

Link to comment

Are you sure this is correct?

if getElementData(source,"spawnedtanks")+3 

I think that "+3" is the problem because you're using "<= gameplayVariables.playertanks" against the existing element data..

try

if getElementData(source,"spawnedtanks") <= gameplayVariables.playertanks then 

Your debug error does say line 67, I'm guessing it's this.

Or maybe 'gameplayVariables.playertanks' is indecipherable within your code?

Link to comment
  • Moderators

At line 49:

function createTankTable ( player ) 
      if source and not player then player = source end 
      setElementData(player,"playerTanks",{"no","no","no","no","no","no","no","no","no"}) 
      setElementData(player,"spawnedtanks",0) 
end 
addEventHandler("onPlayerJoin", root, createTankTable) 

Link to comment

Always read about the functions thoroughly. If you had, you'd of seen this;

This function returns a variable containing the requested element data, or false if the element or the element data does not exist. When getting data corresponding to a XML attribute, this is always a string.

Just convert it to a number.

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...