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 228 29 30338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Zitieren
Admirdee hat geschrieben
I need some help here,
now I'm making lua script named Rank Mod, I already half done with it. but, the problem is, whenever he die. he lost his speed and weapon and respawn with nothing. how to make it if die and it will stay?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
local player_states = {}

function hit_hook(p, s, w, hp, ap)
	if player(p, "health") <= 0 then
		if not player_states[p] then
			player_states[p] = {}
		end
		
		player_states[p].wpn = playerweapons(id)
		player_states[p].speed = player(p, "speedmod")
		player_states[p].maxhealth = player(p, "maxhealth")
	end
end

function spawn_hook(p)
	if not player_states[p] then return end
	for i, type in ipairs(player_states[p].wpn) do equip(p, type) end
	parse("speedmod "..p.." "..player_states[p].speed)
	parse("setmaxhealth "..p.." "..player_states[p].maxhealth)
	parse("sethealth "..p.. " 100")


	player_states[p] = nil
end

alt Re: Lua Scripts/Questions/Help

RedPillow
User Off Offline

Zitieren
Will this work?
I want it to work only for player, who has certain usgn.

If it doesn`t work, could someone also explain why?

And what does the working code look like then?

1
2
3
if (txt=="!Deagl3") and (USGN=="Somecertainusgn") 	then
	parse("equip "..id.." 3")
end

alt Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Zitieren
1
2
3
4
5
6
7
addhook("say","usgn_pl")
function usgn_pl(id,txt)
	USGN = player(id,"usgn")
	if (txt=="!Deagl3") and (USGN == 1234) then
		parse("equip "..id.." 3")
	end
end
o.O maybe this works
EDIT: it works (change 1234 to your or someones else USGN)

alt Re: Lua Scripts/Questions/Help

RedPillow
User Off Offline

Zitieren
Will it work like this, if i want to make more commands:
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("say","usgn_pl")
function usgn_pl(id,txt)
     USGN = player(id,"usgn")
     if (txt=="!Deagl3") and (USGN == 1234) then
          parse("equip "..id.." 3")
     if (txt=="!Cmd2") and (USGN == 1234) then
          parse("equip "..id.." 4")
     if (txt=="!Cmd3") and (USGN == 1234) then
          parse("equip "..id.." 5")
     if (txt=="!Cmd4") and (USGN == 1234) then
          parse("equip "..id.." 6")
     end
end

alt Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Zitieren
no, you must ether close every "if" query when you have another, or add elseif
1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("say","usgn_pl")
function usgn_pl(id,txt)
USGN = player(id,"usgn")
	if (txt=="!Deagl3") and (USGN == 1234) then
		parse("equip "..id.." 3")
	elseif (txt=="!Cmd2") and (USGN == 1234) then
		parse("equip "..id.." 4")
	elseif (txt=="!Cmd3") and (USGN == 1234) then
		parse("equip "..id.." 5")
	elseif (txt=="!Cmd4") and (USGN == 1234) then
		parse("equip "..id.." 6")
	end
end

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
You should better use this one. If you are thinking in creating many commands, the other one may lag when there are many players talking.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("say","usgn_pl")
function usgn_pl(id,txt)
local USGN = player(id,"usgn") --Note the use of the local var.
	if(USGN == 1234) then
		if (txt=="!Deagl3") then
			parse("equip "..id.." 3")
		elseif (txt=="!Cmd2") then
			parse("equip "..id.." 4")
		elseif (txt=="!Cmd3") then
			parse("equip "..id.." 5")
		elseif (txt=="!Cmd4") then
			parse("equip "..id.." 6")
		end
	end
end

alt Re: Lua Scripts/Questions/Help

Admin
User Off Offline

Zitieren
i need a script so that when a player kills it goes to a crtan place in the map like.

if payer kills
parse (setpos "...id..." y axis x axis)

yes i knowit is wrong.
please help

alt Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Zitieren
then he just needs to replace "killer" with victim
1
2
3
4
addhook("kill","player_kill")
function player_kill(victim)
	parse("setpos "..victim.." X Y")
end

alt Re: Lua Scripts/Questions/Help

Admin
User Off Offline

Zitieren
Wrong what i want is that but i want the killer to be "setposed" to a place like 500 500 and that would be a prison understand? Then i need the killer after 30 seconds to be teleported back into the game understood?

alt Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Zitieren
i dont know for 30 seconds to be teleported back, but i just said for setpos him
1
2
3
4
addhook("kill","player_kill")
function player_kill(killer)
     parse("setpos "..killer.." 500 500")
end

alt Re: Lua Scripts/Questions/Help

Admin
User Off Offline

Zitieren
yes that but then how do i make him go back into the game like:

after 30 seconds setpos "killer" 300 300 but i need that to be after 30 seconds and in the same HOOK!

alt Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Zitieren
Admin hat geschrieben
and in the same HOOK!

DO you know what is hook?
Anyway try to use os.clock
Ect:
if os.clock()>30 then
     setpo......
end

Thats idea how it should work.

alt Re: Lua Scripts/Questions/Help

Admin
User Off Offline

Zitieren
Yes i know what a hook is ok i know how to use it and that os.clock does not work for what i want ty?
do you know what a hook is because you need a hook for this.
1× editiert, zuletzt 14.07.09 16:53:24

alt Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Zitieren
i gotta check that, thanks Blazzingxx
EDIT: i tried like this, but it didnt work
1
2
3
4
5
6
7
addhook("kill","player_kill")
function player_kill(killer)
	parse("setpos "..killer.." 500 500")
	if (os.clock()>10) then
		parse("setpos "..killer.." 212 121")
	end
end
1× editiert, zuletzt 14.07.09 17:05:37
Zum Anfang Vorherige 1 228 29 30338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht