Forum

> > CS2D > Scripts > What this error means?
Forums overviewCS2D overview Scripts overviewLog in to reply

English What this error means?

3 replies
To the start Previous 1 Next To the start

old Re: What this error means?

DC
Admin Off Offline

Quote
You probably never assigned any value to
moneyz[id]
(with the id value which is currently used at that point)

Therefore it is nil (does not exist / has no value). You can't compare nil and you can't add something to nil. That's what the errors mean.

You have to initialize the value first by doing
moneyz[id] = YOUR INITIAL VALUE
e.g.
moneyz[id] = 0


And you have to do that for all possible id values (probably 1-32 if those are player IDs). This must happen in the beginning. BEFORE you try to access these values.

old Re: What this error means?

Cure Pikachu
User Off Offline

Quote
Right. Make sure your script has something like this:
1
2
3
4
5
6
7
8
9
10
11
moneyz = {}

addhook("join","initvalue")
function initvalue(id)
	moneyz[id] = 0
end

addhook("leave","resetvalue")
function resetvalue(id)
	moneyz[id] = nil
end

old Re: What this error means?

script favor
User Off Offline

Quote
You're attempting to compare a value with nil value like
1
1 > n
, but we don't know what n is , in other words n is not defined
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview