Jump to content

[HELP] Arithmetics issue


Recommended Posts

Hi there. I'm ahving some problems with my payday script. It gets the cost of the car a player has and divides it for 1000 to get the tax you have to pay for owning it. The problem is that when i try to perform this arithmetic:

local tax2 = itscost /1000

I get this error:

attempt to perform arithmetic on global 'tax2'

I have already checked if itscost is true by using some outputchatbox and printing it. It shows the car cost correctly. Thanks for helping! :D

Link to comment

Alright. That 2 ouputchatboxs were written to check if the variables were wroking fine.

function PayDay(plr, givepay)
 
local reincome = 200
local account = getPlayerAccount (plr)
local findcar = tonumber(getAccountData (account, "car"))
if findcar ~= 481 then
local itscost = tonumber(getAccountData (account, "carcost"))
outputChatBox("cost is " ..itscost)
outputChatBox("car is " ..findcar)
 
local tax2 = itscost/1000
else
local tax2 = "0"
end
 
local whatisgiven = reincome - tax2
 
local playerList = getElementsByType("player")
for key,val in ipairs(playersList) do
givePlayerMoney(val, whatisgiven)
 
end

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