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 228 29 30338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

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

old Re: Lua Scripts/Questions/Help

RedPillow
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
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)

old Re: Lua Scripts/Questions/Help

RedPillow
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

Admin
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

Admin
User Off Offline

Quote
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?

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

Admin
User Off Offline

Quote
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!

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Admin has written
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.

old Re: Lua Scripts/Questions/Help

Admin
User Off Offline

Quote
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.
edited 1×, last 14.07.09 04:53:24 pm

old Re: Lua Scripts/Questions/Help

sonnenschein
User Off Offline

Quote
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
edited 1×, last 14.07.09 05:05:37 pm
To the start Previous 1 228 29 30338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview