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 2313 314 315338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Infinite Rain
Reviewer Off Offline

Quote
help i need script:
bots dont has wrench (construction)
only ak 47
and players cant join to terrorists if he click on the terrorist force automaticly makes counter terrorists (makect)

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
factis699 has written
help i need script:
bots dont has wrench (construction)
only ak 47
and players cant join to terrorists if he click on the terrorist force automaticly makes counter terrorists (makect)


try test, didn't test yet.

1
2
3
4
5
6
7
8
9
addhook("spawn","cons_nowrench")
function cons_nowrench(id)
	if game("sv_gm")==3 then
		if player(id,"bot") then
			parse("equip "..id.." 30") -- Give AK
			parse("strip "..id.." 74") -- Remove wrench from bot
		end
	end
end
^ this is bot don't have wrench when SPAWN only.

1
2
3
4
5
6
7
addhook("team","no_ts")
function no_ts(id,team
	if (team == 1) then
		parse("makect "..id) -- Automatic go CT who want join T's
		msg2(id,"No Terrorists allowed!")
	end
end
^ this, make people can't join T's

old Re: Lua Scripts/Questions/Help

Rainoth
Moderator Off Offline

Quote
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
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end
level=initArray(32)
exp=initArray(32)
credits=initArray(32)
hacker=initArray(32)

function string.split(text,b)
local cmd = {}
if b then
b = b
else
b = "%s"
end
b = "[^"..b.."]+"
for o in string.gmatch(text,b) do
table.insert(cmd,o)
end
return cmd
end

if hacker==nil then hacker={} end
hacker={}

addhook("second","hack")
function hack()
if (hacker[id]==1) then
credits[id]=credits[id]+15
	end
end

addhook("spawn","class")
function class(id)
parse("equip "..id.." 56") -- Equips Ct's with defuse kit.
hacker[id] = 1 -- The Hacker Special is on
	parse("strip "..id)

Anybody help me with this ?
edited 1×, last 20.11.10 02:37:59 pm

old Re: Lua Scripts/Questions/Help

kNedLiik
User Off Offline

Quote
HaRe has written
kNedLiik has written
Someone can help me?
Spoiler >


It is kill | deaths shower but It is showing totall kill | deaths at server but i want it for each player .. Someone please try fix.


already tould u

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("second","kills_gui")
function kills_gui()
	kills_gui_create(p)
end

function kills_gui_create(p)
	for p = 1,32 do
		if player(p,"exists") then
			text = ("©000255000Kills : "..kills.." | Deaths : "..deaths)
			x = 235
			y = 400
			parse('hudtxt 1 '..p..' "'..text..'" '..x..' '..y)
		end
	end
end


ok you told me but ur fix is wrong omg!

old Re: Lua Scripts/Questions/Help

HaRe
User Off Offline

Quote
kNedLiik has written
HaRe has written
kNedLiik has written
Someone can help me?
Spoiler >


It is kill | deaths shower but It is showing totall kill | deaths at server but i want it for each player .. Someone please try fix.


already tould u

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addhook("second","kills_gui")
function kills_gui()
	kills_gui_create(p)
end

function kills_gui_create(p)
	for p = 1,32 do
		if player(p,"exists") then
			text = ("©000255000Kills : "..kills.." | Deaths : "..deaths)
			x = 235
			y = 400
			parse('hudtxt 1 '..p..' "'..text..'" '..x..' '..y)
		end
	end
end


ok you told me but ur fix is wrong omg!


try this

1
text = ('©000255000Kills : '..kills..' | Deaths : '..deaths)

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
kNedLiik has written
It is not in text shower but
Deaths
Kills counting
I need something that will count for each player not the total server


Here is my Killstreak script...
Spoiler >


Why do you want soemthing to say your deaths and kills anyway? Just hold tab?

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
I've got a question about Tables:
How can I add a Table in a Table? Like this:

1
2
3
4
5
lol = {123,156,14896}
a = {12,32}
lol = {lol..a}
print(lol[4])
--should print 12

I know it's not right like this, but how is it possible?

edit// omg i'm so silly weinow i know

edit2// oops i wrote in german
edited 2×, last 20.11.10 08:07:38 pm

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Yasday has written
I've got a question about Tables:
How can I add a Table in a Table? Like this:

1
2
3
4
5
lol = {123,156,14896}
a = {12,32}
lol = {lol..a}
print(lol[4])
--should print 12

I know it's not right like this, but how is it possible?

edit// omg bin ich dumm weiß jetz schon


I think you might have to use a plus sign instead of ".." between lol and a. But that wouldn't work either (: I don't know. But a plus sign is needed i believe!

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Yasday has written
Lol just use this :
1
table.insert(<tablename>,<things to insert>)


Haha! I didn't knew you found out how, because you wrote in Deutsch!

old Re: Lua Scripts/Questions/Help

Blacko
User Off Offline

Quote
Hello, I have a problem with this code :

1
2
3
4
5
6
addhook("say","broadcast") function broadcast(id,t)
     if string.sub(t,1,10) == "!broadcast" then
          local bt = string.sub(t,12)
          msg("©000255000"..player(id,"name").."(Broadcast): "..bt)
     end
end

It's in a Prison Map, when the player talk with "!broadcast" the others players can see what he write for example if he say "!broadcast Hi" The text appear in green with (Broadcast) but too with "!broadcast Hi" in normal text ... I don't know if you understand but I hope ! Please help me ! Thanks you !

old Re: Lua Scripts/Questions/Help

Fehu
User Off Offline

Quote
1
2
3
4
addhook([[hit]],[[mt2_hit]])
function mt2_hit(id,source,weapon,hpdmg,apdmg)
	player(source,"health")-hpdmg*str[id]/def[source]
end

how to change this , to work? i need hpdmg*str[id]/def[source] but if i only write this , dont work...


_______________________
Sry my english is very bad!

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Fehuziom has written
1
2
3
4
addhook([[hit]],[[mt2_hit]])
function mt2_hit(id,source,weapon,hpdmg,apdmg)
	player(source,"health")-hpdmg*str[id]/def[source]
end

how to change this , to work? i need hpdmg*str[id]/def[source] but if i only write this , dont work...


I think this should work:
1
player(source,"health")=player(source,"health")-hpdmg*str[id]/def[source]

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
no you have to use sethealth
lke this :
1
parse([[sethealth ]]..id..[[ ]]..player(id,"health")-hpdmg*str[source]/def[id])
like this i think

edit// can s1 pls tell me whats wrong with this -.- :

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
43
44
45
46
47
function minuted()
	ttiv = ttiv + 1
	if ttiv >= 1440 then
		for l in io.lines("sys/lua/tempvips/all.txt") do
			local line = totable(l)
			for i = 1,#line do
				for li in io.lines("sys/lua/tempvips/"..tonumber(line[i])..".txt") do
					local lines = totable(li)
					if lines[1] == 0 then
						--nix
					elseif lines[1] == 1 then
						local file = assert(io.open("sys/lua/tempvips/"..tonumber(line[i])..".txt","w"))
						file:write("fart")
						file:close()
						local file = assert(io.open("sys/lua/tempvips/all.txt"),"w")
						if tonumber(lines[1]) ~= 1 then
							file:write(tonumber(line[i]).."\n")
						end
						file:close()
						for is = 1,#tempviplist do
							if tempviplist[is] == tonumber(line[i]) then
								table.remove(tempviplist,is)
							end
						end
					elseif lines[1] == 2 then
						local file = assert(io.open("sys/lua/tempvips/"..tonumber(line[i])..".txt","w"))
						file:write("1")
						file:close()
					elseif lines[1] == 3 then
						local file = assert(io.open("sys/lua/tempvips/"..tonumber(line[i])..".txt","w"))
						file:write("2")
						file:close()
					elseif lines[1] == 4 then
						local file = assert(io.open("sys/lua/tempvips/"..tonumber(line[i])..".txt","w"))
						file:write("3")
						file:close()
					elseif lines[1] == 5 then
						local file = assert(io.open("sys/lua/tempvips/"..tonumber(line[i])..".txt","w"))
						file:write("4")
						file:close()
					end
				end
			end
		end
		ttiv = 0
	end
end

edit2//
P.S.: there are no errors
edited 3×, last 21.11.10 09:50:58 pm

old Re: Lua Scripts/Questions/Help

kNedLiik
User Off Offline

Quote
I want show what lua.org/pil learned me when i readed 1-5
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
players_online = 0

addhook("join","add_player")
function add_player(id)
	players_online = players_online + 1
end

addhook("leave","remove_player")
function remove_player(id,reason)
	players_online = players_online - 1
end

addhook("second","player_hud")
function player_hud()
	for id = 1,32 do
		if player(id,"exists") then
			display_player_hud(id)
		end
	end
end

function display_player_hud(id)
text = ("©000255000| Players online : "..players_online.." |")
y = 50
x = 100
align = 1
parse('hudtxt '..id..' "'..text..'" '..x..' '..y)
end

old Re: Lua Scripts/Questions/Help

cartel
User Off Offline

Quote
I would like to write a script lua .. tt is to spec "0" ct "0" and the one who sits on specu sees everything that happens, that spec "1" .. help someone?

old Re: Lua Scripts/Questions/Help

Hador
User Off Offline

Quote
no idea what you mean...


but I have a question myself:

I need a script (don't ask me why), to save weapons.
it should save the weapon IDs as a text-file in a directory (/userweap), according to the USGN ID.
a bit like this:
1
2
3
4
21
51
with the USGN ID of the Player as the Name of the Text file.
When the player joins, he should get the weapons, and a text should appear saying "[USGN ID]: weapons loaded succesfully", and if not, a text which says "failed to load weapons".

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
kNedLiik has written
I want show what lua.org/pil learned me when i readed 1-5
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
players_online = 0

addhook("join","add_player")
function add_player(id)
	players_online = players_online + 1
end

addhook("leave","remove_player")
function remove_player(id,reason)
	players_online = players_online - 1
end

addhook("second","player_hud")
function player_hud()
	for id = 1,32 do
		if player(id,"exists") then
			display_player_hud(id)
		end
	end
end

function display_player_hud(id)
text = ("©000255000| Players online : "..players_online.." |")
y = 50
x = 100
align = 1
parse('hudtxt2 '..id..' 1 "'..text..'" '..x..' '..y..' -1')
end


You only needed to change it to hudtxt2
It was that simple
To the start Previous 1 2313 314 315338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview