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 2 3 4338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
bertykiller has written
ok thanks.
Sorry again but i don't know this code in classes.lua
1
2
3
4
5
6
function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
I know its a loop but i don't know why his utility?


This is a simplified version to create a table with 'm' number of elements in there, and each of them will have a 0. This was originally a sample I submitted to DC, a revised version is as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function initArray(i, x, d)
	local array = {}

	if type(i) == "table" then 
		array = i
		i = x
		x = d
	end

	if (x == nil) then x = 0 end

	for m = 1 , i do
		if (array[m] == nil) then
			array[m] = x
		end
	end

	return array
end

Use as follows:

old_table = initArray(4, 1)

old_table now = {1, 1, 1, 1}

old_table = initArray(old_table, 10)

old_table now = {1, 1, 1, 1, 0, 0,0,0,0,0}

Quote
Is it possible oder it will be possible to change sprite/name/sound of character/weapon?

Not at the moment no.

old Re: Lua Scripts/Questions/Help

Carton
User Off Offline

Quote
Thanks for all.
its my code
1
2
3
4
5
6
7
8
addhook("trigger","mn")
function mn(trigger)
if trigger==lol then
money=player(id,"money")
money=money+100
parse("setmoney "..id.." "..money)
end
end

I have a "trigger_use" which triggers "lol" and i would like have 800$ + my actual money when i use the trigger but my code don't do anything. Why?

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
bertykiller has written
Thanks for all.
its my code
1
2
3
4
5
6
7
8
addhook("trigger","mn")
function mn(trigger)
if trigger==lol then
money=player(id,"money")
money=money+100
parse("setmoney "..id.." "..money)
end
end

I have a "trigger_use" which triggers "lol" and i would like have 800$ + my actual money when i use the trigger but my code don't do anything. Why?


you have to use "lol" instead of lol as the trigger name.

Try using this
1
2
3
4
5
6
addhook("trigger","mn")
function mn(trigger)
	if trigger=="lol" then
		parse("setmoney "..id.." "..player(id,"money")+100)
	end
end

old Re: Lua Scripts/Questions/Help

Carton
User Off Offline

Quote
1
2
3
4
5
6
addhook("use","mn")
function mn(id, event, data, x, y)
if x==4 and y==4 then
parse("setmoney "..id.." "..player(id,"money")+100)
end
end
Now this code is perfect thanks leegao

Another problem, i would know if it's possible to can move an func_dynwall(x and y)? If yes can you explain me?

I create a LUA script. Is it good?

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
----------------------------------------------------------------------------------------------------
-- Survivors/Zombies Classes Script by Bertykiller --
-- 20.04.2009 - Go to my server !!! --
-- Adds Survivors/Zombies Classes to your server --
----------------------------------------------------------------------------------------------------

if sdz==nil then sdz={} end
sdz.classes={} 

----------------------------------------------------------------------------------------------------

function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end
sdz.classes.classt=initArray(32)
sdz.classes.classct=initArray(32)
function sdz.classes.classmenut(id)
	menu(id,"Select your Zombie,Living-Dead,Slow-Hulk,Banshee,Pyro-Driffter")
end

function sdz.classes.classmenuct(id)
	menu(id,"Select your Survivor,Rebel,Heavy-Soldier,Light-Fighter,Arsonist")	
end

----------------------------------------------------------------------------------------------------

addhook("team","sdz.classes.team")
function sdz.classes.team(id,team)
	if (team==1) then
		sdz.classes.classmenut(id)
	elseif (team==2) then
		sdz.classes.classmenuct(id)
	end
end

----------------------------------------------------------------------------------------------------	

addhook("menu","sdz.classes.menu")
function sdz.classes.menu(id,menu,sel)
	if (menu=="Select your Zombie") then
		if (sel>=0 and sel<=4) then
			sdz.classes.classt[id]=sel
			if (player(id,"health")>0) then
				parse("killplayer "..id)
			end
		end
	elseif (menu=="Select your Survivor") then
		if (sel>=0 and sel<=4) then
			sdz.classes.classct[id]=sel
			if (player(id,"health")>0) then
				parse("killplayer "..id)
			end
		end
	end
end

----------------------------------------------------------------------------------------------------

addhook("spawn","sdz.classes.spawn")
function sdz.classes.spawn(id)
		
		-- LIVING-DEAD	
		if (sdz.classes.classt[id]==1) then
			parse ("setmaxhealth "..id.." 150")
			return "";
		end
		-- SLOW HULK
		if (sdz.classes.classt[id]==2) then
			parse ("setmaxhealth "..id.." 250")
			parse ("speedmod "..id.." -4")
			return "69";
		end
		-- BANSHEE
		if (sdz.classes.classt[id]==3) then
			parse ("setmaxhealth "..id.." 55")
			parse ("speedmod "..id.." 8")
			return "x";
		end
		-- PYRO-DRIFFTER
		if (sdz.classes.classt[id]==4) then
			parse ("setmaxhealth "..id.." 125")
			parse ("speedmod "..id.." -2")
			return "73";
		end

		-- REBEL
		if (sdz.classes.classct[id]==1) then
			parse ("setmaxhealth "..id.." 80")
			parse ("setarmor "..id.." 45")
			parse ("speedmod "..id.." 2")
			return "38,23,4,72";
		end
		-- HEAVY-SOLDIER
		if (sdz.classes.classct[id]==2) then
			parse ("setmaxhealth "..id.." 150")
			parse ("setarmor "..id.." 75")
			parse ("speedmod "..id.." -4")
			return "10,31,3,51";
		end
		-- LIGHT-FIGHTER
		if (sdz.classes.classct[id]==3) then
			parse ("setmaxhealth "..id.." 70")
			parse ("setarmor "..id.." 20")
			parse ("speedmod "..id.." 4")
			return "5,6,51,52,53,59";
		end
		-- ARSONIST
		if (sdz.classes.classct[id]==4) then
			parse ("setmaxhealth "..id.." 105")
			parse ("setarmor "..id.." 25")
			parse ("speedmod "..id.." -2")
			return "46,6,72,73,53";
		end
end

----------------------------------------------------------------------------------------------------

addhook("buy","sdz.classes.buy")
function sdz.classes.buy()
	return 1
end

----------------------------------------------------------------------------------------------------

addhook("drop","sdz.classes.drop")
function sdz.classes.drop()
	return 1
end

----------------------------------------------------------------------------------------------------

addhook("die","sdz.classes.die")
function sdz.classes.die()
	return 1
end

----------------------------------------------------------------------------------------------------
edited 2×, last 20.04.09 06:57:49 pm

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
Can someone make me a script. Please read all.
Script searches every 1 minute for a human player. i want, if there are any human players, script kicks any bots. if there aren't any human players, script adds two bots.

I asked 1 minute, so the game doesn't lag

old Re: Lua Scripts/Questions/Help

Carton
User Off Offline

Quote
LinuxGuy has written
Can someone make me a script. Please read all.
Script searches every 1 minute for a human player. i want, if there are any human players, script kicks any bots. if there aren't any human players, script adds two bots.

I asked 1 minute, so the game doesn't lag

I will try it if it's possible, you want two T bot, two CT bot or one T and CT bot?

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
bertykiller has written
I will try it if it's possible, you want two T bot, two CT bot or one T and CT bot?

one T and CT.
thanks soo much

Oh and BTW, if there aren't any humans, but there are bots, it doesn't add bots.
thanks

old Re: Lua Scripts/Questions/Help

Carton
User Off Offline

Quote
LinuxGuy has written
bertykiller has written
I will try it if it's possible, you want two T bot, two CT bot or one T and CT bot?

one T and CT.
thanks soo much

Oh and BTW, if there aren't any humans, but there are bots, it doesn't add bots.
thanks


Try this, this is not perfect warning,i'm a beginner.

1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("spawn","lol")
function lol(id)
	if player(id,"bot") then msg("The new player is a bot.")
			else parse("bot_remove_all ")
				addhook("leave","mdr")
					function mdr(id,reason)
						if reason==0 then
							parse("bot_add_t ")
							parse("bot_add_ct ")
						end
					end
	end
end

old Re: Lua Scripts/Questions/Help

Tehmasta
User Off Offline

Quote
berty, you script wouldn't work and you would see why if you had correctly tabbed it, instead of tabbing every single line
your script is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("spawn","lol")
function lol(id)
	if player(id,"bot") then 
		msg("The new player is a bot.")
	else
		parse("bot_remove_all ")
-- missing an end here...

addhook("leave","mdr")
function mdr(id,reason)
	if reason==0 then
		parse("bot_add_t ")
		parse("bot_add_ct ")
	end
end
--you have two extra ends here...
end
end
also, linuxguy did say check every minute, so i remade the script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("minute","check")
function check()
	local bots = 0
	local players = 0
	for i = 1,32 do
		if player(i,"exists") then 
			if player(i,"bot") then
				bots = bots + 1
			else
				players = players + 1
			end
		end
	end
	if players == 0 and bots == 0 then
		parse("bot_add_ct")
		parse("bot_add_t")
	elseif players > 0 and bots > 0 then
		parse("bot_remove_all")
	end
end
this had been tested and works 100%

old Re: Lua Scripts/Questions/Help

Carton
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
addhook("say","sdz.say")
function sdz.say(id, message)
	-- FREEZE/DEFREEZE PLAYER
	if message=="!frz" then
		vav=player(id, "speedmod")
		parse("speedmod "..id.." -100")	
	end
	if message=="!dfrz" then
		parse("speedmod "..id.. " vav")	
	end
	return 1
end
I have another problem, this script freeze me and defreeze me. I would like it freeze/defreeze not me lol, but a player !
Can someone help mir?
To the start Previous 1 2 3 4338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview