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 2265 266 267338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Ha4r
BANNED Off Offline

Quote
Someone make a script for me where i can get exp,money for killing npcs like headcrabs,zombies,snarks and by pressing F2 i can buy items like Chainsaw,Rpg,Rocket launcher,m249.

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
Snake_Eater has written
Hi guys

How I can let read a special line (like the 4. line) in a .txt file?

pls help


use the split function

Heres an simple reading function with split

thanks to flacko for the split and thanks to me for the code lool!!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function string.split(text,delimiter)
     local buff = {}
     delimiter = delimiter or "%s"
     delimiter = "[^"..delimiter.."]+"
     for w in string.gmatch(text,delimiter) do
          table.insert(buff,w)
     end
     return buff
end

addhook("spawn","readfunc") function readfunc(id)
	for l in io.lines("sys/lua/whatever.txt") 
		l = l:split()
		local whatever = tonumber(l[4]) -- line 4
	end
end

old NEED HELP

Jaso
BANNED Off Offline

Quote
Can some one help me with a npc wave script please?

old Re: Lua Scripts/Questions/Help

RyceR
User Off Offline

Quote
why this script dont work?:
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
parse("mp_wpndmg deagle 0")
function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end
lives=initArray(32)
function lives_hud(id)
	parse('hudtxt2 '..id..' 1 "©000100255Lives: '..lives[id]..' " 13 117')
end
addhook("spawn","lives_spawn")
function lives_spwan(id)
	lives[id]=5
	lives_hud(id)
	parse("equip "..id.." 3")	
end
addhook("hit","lives_hit")
function lives_hit(id)
	if lives[id] == 1 then
		return 0
	else
		lives[id]=lives[id]-1
	end
end
addhook("buy","lives_buy")
function lives_buy()
	return 1
end
addhook("walkover","lives_walkover")
function lives_walkover(id)
	return 1
end
addhook("drop","lives_drop")
function lives_drop()
	return 1
end
addhook("die","lives_die")
function lives_die()
	return 1
end

EDIT: Fixed
edited 1×, last 26.09.10 02:05:41 pm

old Re: Lua Scripts/Questions/Help

Snake_Eater
User Off Offline

Quote
Help again I don't get it how to make...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function string.split(text,delimiter)
local buff = {}
delimiter = delimiter or "%s"
delimiter = "[^"..delimiter.."]+"
for w in string.gmatch(text,delimiter) do
table.insert(buff,w)
end
return buff
end

addhook("say","readfunc") function readfunc(id)
     for l in io.lines("sys/lua/whatever.txt") do
          l = l:split()
          local whatever = tonumber(l[4]) -- line 4
     end
end

If somebody say somrthing the 4. line will show up in msg how to make?

old .YeaH.

FiiD
User Off Offline

Quote
Thank you really MUCH HaRe...but all you maked wanted I to make...I dont need this script really...I have read something that a guy in 2009 wanted this script and than I tried to make it...but you done all...so I need to make something new...post it in the Lua scripts thread...its a great script...I will test it later...

old help with gun buy

Casper-
User Off Offline

Quote
i want to make something like cod5 nazi zombies gun buying on wall and i stopped right here ... *facepalm* stupid me...
1
2
--addhook("usebutton","gunbuy")
--function gunbuy(id,x,y)

(EDIT 1st time>>)i know how tile id's work (x,y tiles i mean) .. i knewed how to do this before ... (EDIT 2nd time >>)and how i can do so there shall be only four players in one team ?
edited 2×, last 26.09.10 03:05:38 pm

old Re: Lua Scripts/Questions/Help

Blacko
User Off Offline

Quote
Hello guys, I need your help for scripts !
> First, a script for save money, license, add-ons in my RolePlay server, in USGN ...
> After, just a little script, when ->CT<- say : !car a car picture appear in him. My car is called : car_04 ...
I hope you help me ...
Tanks you very much !

old Re: Lua Scripts/Questions/Help

Casper-
User Off Offline

Quote
can somebody tell me why this doesnt work ?
1
2
3
addhook("second","healsystem")
function healsystem()
parse("sethealth "..id.." +10")
i had 200 health and suddenly i get 10 health please help
i wanted to get when i got hurt i get refill health points by 10

old Re: Lua Scripts/Questions/Help

TimeQuesT
User Off Offline

Quote
1
2
3
4
5
6
7
8
addhook("second","healsystem")
function healsystem()
for id=1,32 do
if player(id,"exists") then
parse("sethealth "..id.." "..player(id,"health")+10)
end
end
end

try this

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
BureX has written
i want to make something like cod5 nazi zombies gun buying on wall and i stopped right here ... *facepalm* stupid me...
1
2
--addhook("usebutton","gunbuy")
--function gunbuy(id,x,y)

(EDIT 1st time>>)i know how tile id's work (x,y tiles i mean) .. i knewed how to do this before ... (EDIT 2nd time >>)and how i can do so there shall be only four players in one team ?


1
2
3
4
5
addhook("usebutton","gunbuy") function gunbuy(id,event,data,x,y)
	if x==x and y==y then
		--
	end
end

old Re: Lua Scripts/Questions/Help

Blacko
User Off Offline

Quote
Lol, I don't understand tiiger87, you want make a deal ?!
And i have my RP lua, i just want the save !
What is your pseudo in game ?
...

old Re: Lua Scripts/Questions/Help

Casper-
User Off Offline

Quote
how do i do so this doors can be opened if player has money (like buying a ticket or smthing...)
1
2
3
4
if (title == "Hell door") then
		if (key == 1) then
		end
	end

old Re: Lua Scripts/Questions/Help

martis67
User Off Offline

Quote
Hi,all i making gunxp script im now how to do lvls and exps.But i need litle script that if i up my level to me gives somthing like glock.

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
BureX has written
how do i do so this doors can be opened if player has money (like buying a ticket or smthing...)
1
2
3
4
if (title == "Hell door") then
		if (key == 1) then
		end
	end


1
2
3
4
5
6
7
8
9
if (title == "Hell door") then
		if (key == 1) then
			local money = player(id,"money")
			if money>3999 then -- if player has 4000 or more then
				-- What ever
			end
		end
	end
end

old Re: Lua Scripts/Questions/Help

Casper-
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
if (title == "Hell door") then
		if (key == 1) then
			local money = player(id,"money")
			if money>3999 then
			-- over here i want to lose money
			end
		end
	end
end
but i want to lose money
i tried like this
1
2
3
4
5
6
7
8
9
if (title == "Hell door") then
		if (key == 1) then
			local money = player(id,"money")
			if money>999 then
			parse("setmoney "..id.." -1000")
			end
		end
	end
end

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
BureX has written
1
2
3
4
5
6
7
8
9
if (title == "Hell door") then
		if (key == 1) then
			local money = player(id,"money")
			if money>3999 then
			-- over here i want to lose money
			end
		end
	end
end
but i want to lose money
i tried like this
1
2
3
4
5
6
7
8
9
if (title == "Hell door") then
		if (key == 1) then
			local money = player(id,"money")
			if money>999 then
			parse("setmoney "..id.." -1000")
			end
		end
	end
end


change
1
2
3
parse("setmoney "..id.." -1000")
to
               parse("setmoney "..id.." "..(player(id,"money") - 1000))
To the start Previous 1 2265 266 267338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview