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 299 100 101338 339 Next To the start

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

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

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

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

old Re: Lua Scripts/Questions/Help

Lord_CTF
User Off Offline

Quote
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!!
edited 1×, last 24.11.09 09:51:26 pm

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

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

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

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

old Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Quote
jackisokay2 has written
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
edited 2×, last 24.11.09 10:47:10 pm

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

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

but here

Spoiler >

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
-WiLSoN- has written
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)

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

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

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
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

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
-WiLSoN- has written
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
To the start Previous 1 299 100 101338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview