Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 274 75 76338 339 Next To the start

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
What's a table and a nil ?
i keep getting this on my menu:
1
LUA ERROR: attempt to call a table value
and sometimes i get this
1
LUA ERROR: attempt to call a nil value
edited 1×, last 31.10.09 04:11:30 am

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
I think ima try to make a admin script that parses you some equips and setmaxhealth and crap

for ppl that dunno how to do that

er nvm... dun wanna upload crap

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
@Wilson
When you get the 'Attempt to call a table value' error, you should check your code, because you might be doing something like this:
1
2
a = {0,2,4}
b = a + 4
This returns the error 'Attempt to perform arithmetic on "a" (a table value)', it is similar to your error

When you get the 'Attempt to call a nil value' is because you are calling a variable that hasn't been declared, or is nil.
1
a = b + 3
1
2
b = nil
a = b/2

I'm sorry but I couldn't supply any good examples

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
a table is:
1
somthing = {12,"sv_name",88}
something like that

question
what is the source function used for in the hit hook?
edited 1×, last 31.10.09 07:11:29 am

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
-WiLSoN- has written
What's a table and a nil ?

There is True and there is False.
But nil is nothing. Someone call it as zero.
It's using to be different value from anothers, shows the absence of value.

As I see, most people here don't know that.

1st Example:
1
2
3
if (value == nil) then
	print('value doesn't exist!')
end

2nd Example:
1
2
3
if (value ~= nil) then
	print('value exist!')
end

@Flacko, better you would explain it like this, I think.

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
is there some (value or something like that) that can "replace" the total players ? and only a team?
sorry i couldn't think of another way to tell you
maybe an "example" helps:
Spoiler >

both of this were just examples

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
for i=1,36,1 do
	if (player(i,"exists")) then
		totalplayers = totalplayers+1
		if player(i,"team") = 1 then
			team1 = team1+1
		end
		if player(i,"team") = 2 then
			team2 = team2+2
		end
	end
end
Totalplayers has total number of players, team1 and team2 the team players. Don't know which of both is Terrorists and which is CounterTerrorists, try it out yourself

old Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Quote
@mortyr: Aren't you tired of this asking?

Well don't cry, here it is:

1
2
3
4
5
6
addhook("team","my_class")
function my_class(id)
	if player(id,"team")==2 then
		<your script goes here>
	end
end

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
sorry i did not understan that very well
Spoiler >

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
@-WiLSoN-,
This code will show how many terrorists, counter-terrorists, spectators is on you server. + Total players.
It will show as message on chosing team. (team hook)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
addhook("team","teams")
function teams(p,t)
	local i
	local team_t = 0
	local team_ct = 0
	local team_spec = 0
	for i = 1,32 do 
		 if (player(i,"exists")) then 
			if player(i,"team") == 1 then
				 team_t =  team_t + 1 
			end
			if player(i,"team") == 2 then 
				 team_ct =  team_ct + 1
			end
			if player(i,"team") == 0 then 
				 team_spec =  team_spec + 1
			end
		end
	end
	msg('=========================')
	msg('Terrorists:'.. team_t)
	msg('Counter-Terrorists:'.. team_ct)
	msg('Spectators:'.. team_spec)
	msg('Total Players:'.. team_ct + team_t + team_spec)
end

old Re: Lua Scripts/Questions/Help

JaBoo
User Off Offline

Quote
I am wondering, if I want to add many Walls to a map with a command, but i want them in random location, like in LaG server, what would I have to do??
I am stuck because I have no clue.
If someone can help me, would be very helpful
To the start Previous 1 274 75 76338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview