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 229 30 31338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

RedPillow
User Off Offline

Zitieren
Zitat
1
2
3
4
5
addhook("kill","player_kill")
function player_kill(killer)
	if (os.clock()>10) then
	parse("setpos "..killer.." 500 500")
end


How about that?

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
Jonzku777 hat geschrieben
Zitat
1
2
3
4
5
addhook("kill","player_kill")
function player_kill(killer)
	if (os.clock()>10) then
	parse("setpos "..killer.." 500 500")
end


How about that?


That would fail.
You have to use 2 hooks and and 2 tables
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
function initArray(s,v)
	local tbl={}
	for i=1, s do
		tbl[i]=v
	end
	return tbl
end

jailtime = initArray(32,os.clock())
onjail = initArray(32,false)

addhook("kill","player_kill")
function player_kill(killer,victim)
	parse("setpos "..killer.." 300 300") -- Put him into jail
	jailtime[killer]=os.clock
	onjail[killer] = true
end

addhook("second","func_second")
function func_second()
	for i=1,32 do
		if(onjail[i]==true) then
			if(os.clock() - jailtime[i]>= 30) then --30 secs
				onjail[i] = false
				parse("setpos "..i.." 10 10")--Get out from jail
			end
		end
	end
end

I don't guarantee that could work because I haven't tested it and writing code here is a pain, I should have opened worpad...
1× editiert, zuletzt 14.07.09 20:07:03

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
oh. Linux guy.
Anyway kill hook shoud be activated by someone else death.
Otherwise it shurely not work.
Flack shows good example , but it uses "second hook"

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
There's no other way to take the player out from jail automatically (Without using second).
You could put a button in prison and use the trigger entity if you don't want to use second.

But look what has the RPG script i'm working in in the 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
26
27
28
29
30
addhook("second","flacko.rpg.second")
function flacko.rpg.second()
	for i=1, 32 do
		if player(i,"exists") and player(i,"health")>0 then
			if(flacko.rpg.poisoned[i]~=0) then
				local pfactor = flacko.rpg.idtosid(1,true).factor
				local poisonlevel = flacko.rpg.speciallvl[flacko.rpg.poisoned[i]]
				if(player(i,"health") <= pfactor*poisonlevel) then
					parse("customkill "..flacko.rpg.poisoned[i].." Poison "..i)
				else
					parse("sethealth "..i.." "..player(i,"health") - pfactor*poisonlevel)
				end
			elseif(flacko.rpg.paralyzed[i]~=0) then
				local mx_speed = flacko.rpg.speed[i] 
				if(flacko.rpg.item[i][1]==12 or flacko.rpg.item[i][2]==12) then
					mx_speed = mx_speed + flacko.rpg.idtosid(12,true).factor 
				end
				if (player(i,"speedmod") < mx_speed) then
					parse("speedmod "..i.." "..player(i,"speedmod")+1)
					if player(i,"speedmod")  == mx_speed then
						flacko.rpg.paralyzed[i] = 0
					end
				end
			end
			if(flacko.rpg.special[i]==3) then
				parse("sethealth "..i.." "..player(i,"health") + flacko.rpg.idtosid(3,true).factor*flacko.rpg.speciallvl[i])
			end
		end
	end
end

And I don't feel any slowdown or experience any ping problems.

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
Admirdee hat geschrieben
@leegao

it's not working to me, I already copy paste it to script.
no error, but also spawn with n0thing >.<


T.T, I assumed that you would add

1
2
addhook("hit", "hit_hook")
addhook("spawn", "spawn_hook")

at the start of the file

alt Wondering if its even possible?

KaiserWilhelm
User Off Offline

Zitieren
I'm still looking for a way to prevent the building of certain buildings, and now im wondering if its even possible. when I posted my original question yesterday i received no response, but the guy after me had a huge problem solved. So im guessing that that is an indicator that this would be imposssible in Lua? or is it so hard you have to think it over for a day? I've tried my best to write or obtain this script, i still have to leave it up to you. excuse my english

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
KaiserWilhelm hat geschrieben
I'm still looking for a way to prevent the building of certain buildings, and now im wondering if its even possible. when I posted my original question yesterday i received no response, but the guy after me had a huge problem solved. So im guessing that that is an indicator that this would be imposssible in Lua? or is it so hard you have to think it over for a day? I've tried my best to write or obtain this script, i still have to leave it up to you. excuse my english


The correct response would have been that the solution is so easy that you probably wouldn't believe it. However, the solution does not require Lua as an intermediate step.

http://cs2d.com/help.php?cat=settings&cmd=mp_unbuildable#cmd

Zitat
mp_unbuildable
Categories
settings, server

Parameters
- buildings (text): list of buildings which are unbuildable, seperated with ","

Info
Select which buildings are not available for building.

alt Re: Lua Scripts/Questions/Help

KimKat
GAME BANNED Off Offline

Zitieren
Otherwise you could simply do a console command for example: mp_building_limit "Gate Field" 0

I'm not sure how you make it using lua. Although it feels somewhat pointless when you can enter simple commands... but would be nice to see a lua version of how to disable certain buildings.

alt Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Zitieren
leegao hat geschrieben
T.T, I assumed that you would add

1
2
addhook("hit", "hit_hook")
addhook("spawn", "spawn_hook")

at the start of the file


T.T I still don't get it. same problem

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
Admirdee hat geschrieben
T.T I still don't get it. same problem


This will only work if you are killed by a weapon. Inside the first IF condition in hit_hook, print out all of the relevant variables, do the same inside the spawn_hook

alt Script Not Working

MatheusMK3
User Off Offline

Zitieren
Yesterday, i have written this code, but it does not works!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("say", "mk3.utils.say") 
function mk3.utils.say(id, message) 
     if(player(id,"team")==1) then 
          parse("sv_msg ©025025255"..player(id,"name").." diz: ©255255255"..message) 
     elseif(player(id,"team")==1) then 
          parse("sv_msg ©255025025"..player(id,"name").." diz: ©255255255"..message) 
     elseif(player(id,"team")==0) then 
          parse("sv_msg ©255255000"..player(id,"name").." diz: ©255255255"..message) 
     end 
     print("===CHAT: Jogador ["..player(id,"name").."] (ID "..id..") do time "..player(id,"team").." disse: 

"..message) 
     return 1 
end
But i don't know what is wrong...

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
MatheusMK3 hat geschrieben
Yesterday, i have written this code, but it does not works!
But i don't know what is wrong...


Can you give us more info? Why doesn't it work, what do you want it to do, and what if any error messages were displayed on the console?

alt Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Zitieren
Did you tried to make multiple colors in the same line? its not supported

EDIT: Here you go:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("say", "lol_said")
function lol_said(id, txt)
	print("===CHAT: Jogador ["..player(id,"name").."] (ID "..id..") do time "..player(id,"team").." disse: "..txt)
	if(player(id,"team")==1) then
		parse("sv_msg ©025025255"..player(id,"name").." diz: "..txt)
		return 1
	end
	if(player(id,"team")==2) then
		parse("sv_msg ©255025025"..player(id,"name").." diz: "..txt)
		return 1
	end
	if(player(id,"team")==0) then
		parse("sv_msg ©255255000"..player(id,"name").." diz: "..txt)
		return 1
	end
end
only You now have red for couter terrorist and Blue fror terrorist o.O

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
LinuxGuy hat geschrieben
only You now have red for couter terrorist and Blue fror terrorist o.O


Try switching the 1 and the 2

alt Can one Help me ????

Captain Kenpachi
User Off Offline

Zitieren
WHat is here wrong i dont know
addhook("kill","sample.ut.kill")
function sample.ut.kill(killer,victim,weapon)
     if (os.clock()-sample.ut.timer[killer])>3 then
          sample.ut.level[killer]=0;
     end
     level=sample.ut.level[killer]
     level=level+1
     sample.ut.level[killer]=level
     sample.ut.timer[killer]=os.clock()
     -- FIRST BLOOD?
     if (sample.ut.fblood==0) then
          sample.ut.fblood=1
          parse("sv_sound \"env/firstblood.wav\"");
          msg (player(killer,"name").." sheds FIRST BLOOD by killing "..player(victim,"name").."!")
     end
     -- HUMILIATION? (KNIFEKILL)
     if (weapon==50) then
          -- HUMILIATION!
          parse("sv_sound \"env/humiliation.wav\"");
          msg (player(killer,"name").." humiliated "..player(victim,"name").."!")
     else
          -- REGULAR KILL
          if (level==1) then
               -- Single Kill! Nothing Special!

          elseif (level==2) then
               parse("sv_sound \"env/doublekill.wav\"");
               msg (player(killer,"name").." made a Doublekill!")

          elseif (level==3) then
               parse("sv_sound \"env/multikill.wav\"")
               msg (player(killer,"name").." made a Multikill!")

          elseif (level==4) then
               parse("sv_sound \"env/ultrakill.wav\"")
               msg (player(killer,"name").." made an ULTRAKILL!")

          elseif (level==5) then
               parse("sv_sound \"env/monsterkill.wav\"")
               msg (player(killer,"name").." made a MO-O-O-O-ONSTERKILL-ILL-ILL!")
          
elseif (level==6) then
               parse("sv_sound \"env/unstoppable.wav\"")
               msg (player(killer,"name").." is UNSTOPPABLE !")

          elseif (level==7) then
               parse("sv_sound \"env/rampage.wav\"")
               msg (player(killer,"name").." made a Rampage !")

          elseif
(level==8) then
               parse("sv_sound \"env/ownage.wav\"")
               msg (player(killer,"name").." made a Onwnage !")
          
elseif
(level==9) then
               parse("sv_sound \"env/killingspree.wav\"")
               msg (player(killer,"name").." made a Killingspree !")

elseif
(level==10) then
               parse("sv_sound \"env/ludicrouskill.wav\"")
               msg (player(killer,"name").." made a ludicrouskill !")
end
     end
end

alt Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Zitieren
leegao hat geschrieben
Try switching the 1 and the 2


MasterKadjik hat geschrieben
WHat is here wrong i dont know

What does console say? Do you have any errors?

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
MasterKadjik hat geschrieben
WHat is here wrong i dont know


For future references - If you do not tell us what it is that You Want The Script To Do AND Where the Problem is Occuring And if possible, if you don't want the world to think that you're incapable of independent though Where the error possible might be located at We can not help you

@LinuxGuy good to see you're still as sharp as always

alt Re: Lua Scripts/Questions/Help

Captain Kenpachi
User Off Offline

Zitieren
Hm.... ok made that right now
And how i can make when i make a monster kill its in many secounds over and i cant make a unstoppable
how i can make that when save that for one round how on the [LaG] clan server ?

alt Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Zitieren
Oh hi all, i forgot, i fixed it and i played LONG sorry
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
if sample==nil then sample={} end
sample.ut={}

-----------------------
-- INITIAL SETUP     --
-----------------------
function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end
sample.ut.timer=initArray(32)
sample.ut.level=initArray(32)
sample.ut.fblood=0



addhook("kill","sample.ut.kill")
function sample.ut.kill(killer,victim,weapon)
	if (os.clock()-sample.ut.timer[killer])>3 then
		sample.ut.level[killer]=0;
	end
	level=sample.ut.level[killer]
	level=level+1
	sample.ut.level[killer]=level
	sample.ut.timer[killer]=os.clock()
	-- FIRST BLOOD?
	if (sample.ut.fblood==0) then
		sample.ut.fblood=1
		parse("sv_sound \"env/firstblood.wav\"");
		msg (player(killer,"name").." sheds FIRST BLOOD by killing "..player(victim,"name").."!")
	end
		-- HUMILIATION? (KNIFEKILL)
	if (weapon==50) then
		-- HUMILIATION!
		parse("sv_sound \"env/humiliation.wav\"");
		msg (player(killer,"name").." humiliated "..player(victim,"name").."!")
	else
		-- REGULAR KILL
	if (level==1) then
		-- Single Kill! Nothing Special!

	elseif (level==2) then
		parse("sv_sound \"env/doublekill.wav\"");
		msg (player(killer,"name").." made a Doublekill!")

	elseif (level==3) then
		parse("sv_sound \"env/multikill.wav\"")
		msg (player(killer,"name").." made a Multikill!")

	elseif (level==4) then
		parse("sv_sound \"env/ultrakill.wav\"")
		msg (player(killer,"name").." made an ULTRAKILL!")

	elseif (level==5) then
		parse("sv_sound \"env/monsterkill.wav\"")
		msg (player(killer,"name").." made a MO-O-O-O-ONSTERKILL-ILL-ILL!")
          
	elseif (level==6) then
		parse("sv_sound \"env/unstoppable.wav\"")
		msg (player(killer,"name").." is UNSTOPPABLE !")

	elseif (level==7) then
		parse("sv_sound \"env/rampage.wav\"")
		msg (player(killer,"name").." made a Rampage !")
	elseif (level==8) then
		parse("sv_sound \"env/ownage.wav\"")
		msg (player(killer,"name").." made a Onwnage !")
          
	elseif (level==9) then
		parse("sv_sound \"env/killingspree.wav\"")
		msg (player(killer,"name").." made a Killingspree !")

	elseif (level==10) then
		parse("sv_sound \"env/ludicrouskill.wav\"")
		msg (player(killer,"name").." made a ludicrouskill !")
	end
end
end

alt Re: Lua Scripts/Questions/Help

Captain Kenpachi
User Off Offline

Zitieren
oh thank you linuxguy i love you
and my last ask i dont know how i can make a hud text i wandet to make it over left at the radar
EDIT
And how i can make when i make a monster kill its in many secounds over and i cant make a unstoppable
how i can make that when save that for one round how on the [LaG] clan server
1× editiert, zuletzt 16.07.09 00:40:03
Zum Anfang Vorherige 1 229 30 31338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht