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 299 100 101338 339 Nächste Zum Anfang

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
try this:
1
2
3
4
5
6
addhook("say","Prison.dead")
function Prison.dead(id,t)
	if (player(id,"health") >= 0) then
		msg("©255000000Player "..player(id,"name").."is dead")
	end
end
or the thing you want to do
EDIT: lol Flacko had answered already...

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
-WiLSoN- hat geschrieben
1
2
3
4
5
6
addhook("say","Prison.dead")
function Prison.dead(id,t)
	if (player(id,"health") >= 0) then
		msg("©255000000Player "..player(id,"name").."is dead")
	end
end


That would be wrong because of this line:
1
if (player(id,"health") >= 0) then
Because ">= 0" means "greater or equal than 0", and a player with more than 0 HP isn't dead.

alt Re: Lua Scripts/Questions/Help

Lord_CTF
User Off Offline

Zitieren
i really need help. I dont know anything about LUA(basicly)
and i am making a RPG map.
I want to make a shop to buy guns. I made a trigger in the map. You need to press the knob button at the shop that the item would apear next to you. so what would be the script that in the process of buying a gun, you would lose some money?
i might start learning Lua myself so please help
EDIT: a full script to buy a gun would be awesome!!
1× editiert, zuletzt 24.11.09 21:51:26

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
It seems i have bad luck at making scripts
Spoiler >


The Thing is I'm trying to
A) Make it +1 when you join to local lognum1
B) Make it add [lognum1] after the usgn in filename when leave(saving the log) in order to have it more "clean"
C) This sh*t won't work

And finally
D) Could you help me fix it please?

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
CmDark hat geschrieben
It seems i have bad luck at making scripts
Spoiler >


The Thing is I'm trying to
A) Make it +1 when you join to local lognum1
B) Make it add [lognum1] after the usgn in filename when leave(saving the log) in order to have it more "clean"
C) This sh*t won't work

And finally
D) Could you help me fix it please?


Sorry can't make it more readable T_T you'd have to copy and paste it into wordpad or scite

~~ :S

alt Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Zitieren
jackisokay2 hat geschrieben
Thanks starkkz!!!

but now i have a new question, i'm sure i'm doing something stupid, but this is my script so far, but if i start a new game in cs2d, it doesn't work. what am i doing wrong? as a matter of fact none of the parse("") stuff doesn't work. help?

Spoiler >


uhh i can say all but.. i can fix it.

Spoiler >


you add this
Spoiler >


the parse function not need end, too dofile.
only if you type

1
2
3
function function_name(id)
parse("the command here")
end

this is good only on function.
the part if.. too need end
2× editiert, zuletzt 24.11.09 22:47:10

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
I can't read my script correctly in edit mode
in forums

but here

Spoiler >

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
-WiLSoN- hat geschrieben
how can i refer to a players primary weapon,secondary weapon,melee and grenades ?
(each type separately)


with playerweapons(id) you can get a table with all the weapons he has equipped.
You can cycle through that table.
1
2
3
4
5
6
7
8
9
10
function getslotweps(id,slot)
	local myweapons = playerweapons(id)
	local rt = {}
	for v in pairs(myweapons)
		if itemtype(v,"slot") == slot then
			table.insert(rt,v)
		end
	end
	return rt
end
That should (more or less work)

alt Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Zitieren
-WiLSoN- hat geschrieben
uhm so what should i do on that to separate primary,secondary,melee and nades ?


Just call the function and get the table.
getslotweps(1,2) would return a table with all the pistols the player has, for example.

alt Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Zitieren
so to use it'd be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function getslotweps(id,slot)
     local myweapons = playerweapons(id)
     local rt = {}
     for v in pairs(myweapons)
          if itemtype(v,"slot") == slot then
               table.insert(rt,v)
          end
     end
     return rt
end 
addhook("startround",sround")
function sround()
	getslotweps(1,2)
	for i= 1, 32 do
		parse("strip "..i..""..1) -- primary
		parse("strip "..i..""..2) -- Secondary
	end
end
correct me please

alt Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Zitieren
Rofl i just made a awesome norm script
1
2
3
4
5
6
7
8
9
10
11
addhook("say","bombplant") 
	function bombplant(i,txt)

	cmdxb = player(i,"tilex")
	cmdyb = player(i,"tiley")

	if (txt=="plant") then
		parse("spawnitem 63 "..cmdxb.." "..cmdyb)
		parse("sv_sound radio/bombpl.ogg")
	end
end

alt Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Zitieren
-WiLSoN- hat geschrieben
this:
when round starts player gets striped his primary and secondary weapons


1
2
3
4
5
6
7
8
addhook("startround","rstart")
function rstart()
	for i = 1,32 do
		if (player(i,"exists")) then
			parse("strip "..i.." 0")
		end
	end
end

long code for it
Zum Anfang Vorherige 1 299 100 101338 339 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht