Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Lua Scripts/Questions/Help

6.770 Antworten
Seite
Zum Anfang Vorherige 1 274 75 76338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
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
1× editiert, zuletzt 31.10.09 04:11:30

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
@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

alt Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

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

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

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
-WiLSoN- hat geschrieben
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.

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Zitieren
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

alt Re: Lua Scripts/Questions/Help

BetaM
User Off Offline

Zitieren
@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

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
sorry i did not understan that very well
Spoiler >

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
@-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

alt Re: Lua Scripts/Questions/Help

JaBoo
User Off Offline

Zitieren
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
Zum Anfang Vorherige 1 274 75 76338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht