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 231 32 33338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Blazzingxx has written
Very simple , just where is problem?
It sets health for only source , but not for id.

1
2
3
4
5
addhook("hit","hits")
function hits(id,source)
	parse("sethealth "..source.." "..player(source,"health")+100) 
	parse("sethealth "..id.." "..player(id,"health")+100) 
end


Try this:

1
2
3
4
5
addhook("hit","hits")
function hits(id,source)
	parse("sethealth "..source.." "..(player(source,"health")+100)) 
	parse("sethealth "..id.." "..(player(id,"health")+100)) 
end

It seems that you have to put the whole operation between parenthesis when contatenating. Don't ask me why because I don't know o.O

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Flacko has written
It seems that you have to put the whole operation between parenthesis when contatenating. Don't ask me why because I don't know o.O

Its some kind of bug becouse with "source" everything alright.

And that yours script not working too. (You tested it?)

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Blazzingxx has written
nosence.
I get number of victim... But parse still not working.
Even If I would do
parse("sethealth "..id.." 100")
Your script looks to long

Heal gun heals victim & it was working before month


...

try this

1
2
3
function hits(id, source)
	print(player(id, "health"))
end

You will have to be attentive enough to at least figure out that the player's health has not been afflicted yet. The Hook Function comes BEFORE dealing out the damage. This is the only way to make sure that you can return 1 and cancel the hit event. Making more sense now?

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
then my script is wrong. there are no errors in console
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
if not string.split then dofile("sys/lua/string.lua") end 

god = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

--Hooks
addhook("join", "godzero")
addhook("say", "hook_say")
addhook("hit","hook_hit")

--Functions
function godzero(id)
	god[id] = 0
end

function hook_say(id, text)
	--text:qsplit() splits a string based on spaces and quotes
	local cmd = text:qsplit()

	if cmd[1] == "!makegod" then
		local id2 = tonumber(cmd[2])
		if not (id) then return end
		god[""..id2..""] = 1
	end
end

function hook_hit(id,source,weapon,hpdmg,apdmg)
	if (god[id] == 1) then
		return 1
	end
end

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
1
god[""..id2..""] = 1

That should be

1
god[id2] = 1

Since the i-index are integer values, you don't need to (and can't) convert them to strings.

old Thanks! :)

MatheusMK3
User Off Offline

Quote
leegao has written
Matheus - Please for future say commands, download this first so you don't get hang up on writing the command's say structure itself

http://www.unrealsoftware.de/files_show.php?file=1054

for PM

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if not string.split then dofile("sys/lua/string.lua") end
if not msg2 then dofile("sys/lua/wrapper.lua") end

addhook("say", "hook_say_pm")

function hook_say_pm(p, text)
	--text:qsplit() splits a string based on spaces and quotes
	local cmd = text:qsplit()

	if cmd[1] == "!pm" then
		local p2 = tonumber(cmd[2])
		local msg = tonumber(cmd[3])
		if not (p and msg) then return end
		msg2(p, "Message sent to "..player(p2, "name"))
		msg2(p2, "[PM]"..player(p, "name") .. ": "..msg)
	end
end

here, type in !pm 3 "Text that you want to send" to send player 3 this pm.


Man, thank you veeeeeeeeery much, without it, i never can end my server...

old Re: Lua Scripts/Questions/Help

BoosterxD
User Off Offline

Quote
bertykiller has written
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

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


I think the problem is here.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
and then FIX it

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
BoosterxD has written
I think the problem is here.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
and then FIX it


Can you explain what needs to be fixed?

old Re: Lua Scripts/Questions/Help

BoosterxD
User Off Offline

Quote
leegao has written
BoosterxD has written
I think the problem is here.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
and then FIX it


Can you explain what needs to be fixed?


When Zombie dead He can choose a new one. But when starting a new round,They choose it is a CT Zombie's. problem is how to make him choose at start up a new department without the T?

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
There is no PROBLEM with this script!
I already create like Zombie Plague mod
which human can buy extra item and
zombies can buy extra item to.
maybe when in changing that script
got a little wrong? did you check what you edit?

old Re: Lua Scripts/Questions/Help

KaiserWilhelm
User Off Offline

Quote
sorry for asking, but in your description on the download page it says that you have an improved infection system. What exactly does that mean, and where is it? I'm interested because i'm looking for some code to splice into my own for my zombie maps. I want to create a random chance (1 in 10 or something) that when attacked by a zombie with its claw, a survivor is"infected" and in a set amount of time turns into a zombie. it would be even better if this happened ON THE SPOT. instead of just killing the survivor and sending it to the Terrorist spawn. Woukd the latter part even be allowed in Lua or is that to high level?
To the start Previous 1 231 32 33338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview