Forum

> > CS2D > Scripts > Speed added
Forums overviewCS2D overview Scripts overviewLog in to reply

English Speed added

6 replies
To the start Previous 1 Next To the start

old Speed added

Precel97
User Off Offline

Quote
Hi! I got problem with script
1
2
3
4
5
6
7
8
9
10
11
addhook("menu","save_mx")
function save_mx(id,m,b)
local speed = player(id,"speed")
if m=="Skills" then
if b==1 and (points[id] > 0) then
spe[id]=spe[id]+1
points[id]=points[id]-1
parse("speedmod "..id.." "..player(id,"speed")+1)
end
end
end
Not work console say something about boolean value.
Problem in this :
1
parse("speedmod "..id.." "..player(id,"speed")+1)

When i delete this all is good but when i put this script not work
Can someone fix it for me?

old Re: Speed added

Yasday
User Off Offline

Quote
It's "speedmod", not "speed" ( player(id, "speedmod") ).
The boolean value is nil, because player(id, "speed") returns nil.

old Re: Speed added

Flacko
User Off Offline

Quote
Yasday has written
It's "speedmod", not "speed" ( player(id, "speedmod") ).
The boolean value is nil, because player(id, "speed") returns nil.


When player() finds that you're requesting an invalid value, it actually returns false.

old Re: Speed added

Yasday
User Off Offline

Quote
Thought it returns nil because the value isn't found.
Like
1
2
3
4
5
c = function(s)
	if s == "speedmod" then return 100 end
end

print(tostring(c("speed"))) -- nil

old Re: Speed added

Flacko
User Off Offline

Quote
print(tostring(player(1,"speed"))) -> false

The reason why your function prints nil is because all lua functions that don't return any value will return nil.

So when you called c with "speed" it returned nil.

It's important that you understand that nil is not equal to false, as nil represents no data while false represents a boolean value.

old Re: Speed added

Yasday
User Off Offline

Quote
That was what I wanted to say, it's nil because it won't return anything. I do understand that nil is not equal to false, didn't ever say that it is. And the function doesn't return false, it doesn't return anything if s != speedmod, so if you use
1
a = c("speed")
a will be nil ( nothing ), that means it isn't declared.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview