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 225 26 27338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Alpha Beta
User Off Offline

Quote
info.txt has written
[PLAYER]
- player(id,"value")          Return a value of a player:
                    exists, name, ip, port, usgn, ping,
                    idle, bot, team, look, x, y,
                    rot, tilex, tiley, health,
                    armor, money, score, deaths,
                    teamkills, hostagekills,
                    teambuildingkills, weaponid,
                    weapontype, nightvision,
                    defusekit, bomb, flag,
                    reloading, process,
                    sprayname, spraycolor,
                    votekick, votemap, favteam,
                    speedmod, maxhealth
                    Moreover there is:
                    player(0,"table"): table with all player IDs

"10" also don't exist.

old Re: Lua Scripts/Questions/Help

DC
Admin Off Offline

Quote
how to edit WHAT?
what do you want to do with that script?
you should read a Lua tutorial + the info.txt! Lua scripting DOES NOT WORK when you don't invest some time and try to learn it.

by the way: "reload" is a local command without player parameter. It would only work for the player who is the server. So the server player would reload every time the condition is true for any player. All the other players would never reload with this script.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Quote
i create my reloading after two shot but is dont work


1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("attack", "reload")
m3reload = {}

function reload(p, weapon)
	if not m3reload[p] then m3reload[p] = 0 end
	if weapon == 10 then
		m3reload[p] =  m3reload[p] + 1
		if m3reload[p] >= 2 then
			m3reload[p] = nil
			parse("equip "..p.." ".. 10)
		end
	end
end

Please code your script next time you ask for help.

old makemect

NEMESIS_P
User Off Offline

Quote
when player say !makemect , player join CT.
how make it?

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
addhook("say", "makeTeam")
function makeTeam(id, txt)
if (txt == "!makemect") then	
	parse("makect "..id)
end
if (txt == "!makemet") then
	parse("maket "..id)
end
end

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Hey guys, I just wanted to share with you this two functions:
The first one, is the split function leegao submitted time ago. And the second one (The interesting one) returns the script's path (It needs lee's function). I find it useful when I have to include various files + working with file I/O.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function split_p(t)
	local d = "[^/]+"
	local cmd = {}
	for word in string.gmatch(t,d) do
		table.insert(cmd,word)
	end
	return cmd
end

function getfilefolder()
	local path = debug.getinfo(debug.getinfo(1).func).short_src
	local split = split_p(path)
	local returnstr = ""
	for i = 1, #split-1 do
		returnstr = returnstr..split[i].."/"
	end
	return  returnstr
end

I guess Garry's mod wiki deserves a big part of the merit
http://wiki.garrysmod.com/?title=Common_Code_Snippets#Obtain_the_file_and_path_of_a_script
edited 2×, last 07.07.09 06:30:14 pm

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
wolfteam32 has written
How to change CT name and T name in chosing team screen

× Thats not possible to make it in lua.

old Re: Lua Scripts/Questions/Help

Zune5
COMMUNITY BANNED Off Offline

Quote
Blazzingxx has written
wolfteam32 has written
How to change CT name and T name in chosing team screen

× Thats not possible to make it in lua.


It's possible to modify some of the letters in the CT and T name in chosing screen... but that's illegal according to DC's readme.txt...

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Thats classes.
Not changed names of teams and characters.

yes , possible with resource editor
edited 1×, last 07.07.09 07:24:27 pm

old Re: Lua Scripts/Questions/Help

NEMESIS_P
User Off Offline

Quote
TheKilledDeath has written
1
2
3
4
5
6
7
8
9
addhook("say", "makeTeam")
function makeTeam(id, txt)
if (txt == "!makemect") then	
	parse("makect "..id)
end
if (txt == "!makemet") then
	parse("maket "..id)
end
end


THX!

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
mortyr22 has written
dont work.
if m3 have 7\8 ammo the weapon automatici reload


1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("attack", "reload")
m3reload = {}

function reload(p)
	weapon = player(p, "weapontype")
     if not m3reload[p] then m3reload[p] = 0 end
     if weapon == 10 then
          m3reload[p] = m3reload[p] + 1
          if m3reload[p] >= 2 then
               m3reload[p] = nil
               parse("equip "..p.." ".. 10)
          end
     end
end

Try actually do some work yourself, I'm a thousand miles away from civilization and nothing to run cs2d on, please, if you're going to ask for help, at least state how much you've worked on the problem and why you think the problem is occurring. I hate to be wasting my time and effort on someone who either refuses to learn on their own or expects others to do all the hard work for them

@TKD:
an alternative version is also available

1
2
3
4
function maketeam(p, t)
	if t:sub(1, 5) ~= "!make" then return end
	parse(t:sub(2,6).." "..p)
end

old Re: Lua Scripts/Questions/Help

LaG
User Off Offline

Quote
Im really confused with this lua help me Add "VIP" privlidges (they can only do @say like admins. Im not good @ this... help me.

old Re: Lua Scripts/Questions/Help

BoosterxD
User Off Offline

Quote
bertykiller has written
1
2
3
4
5
6
addhook("use","mn")
function mn(id, event, data, x, y)
if x==4 and y==4 then
parse("setmoney "..id.." "..player(id,"money")+100)
end
end
Now this code is perfect thanks leegao

Another problem, i would know if it's possible to can move an func_dynwall(x and y)? If yes can you explain me?

I create a LUA script. Is it good?

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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
----------------------------------------------------------------------------------------------------
-- Survivors/Zombies Classes Script by Bertykiller --
-- 20.04.2009 - Go to my server !!! --
-- Adds Survivors/Zombies Classes to your server --
----------------------------------------------------------------------------------------------------

if sdz==nil then sdz={} end
sdz.classes={} 

----------------------------------------------------------------------------------------------------

function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end
sdz.classes.classt=initArray(32)
sdz.classes.classct=initArray(32)
function sdz.classes.classmenut(id)
	menu(id,"Select your Zombie,Living-Dead,Slow-Hulk,Banshee,Pyro-Driffter")
end

function sdz.classes.classmenuct(id)
	menu(id,"Select your Survivor,Rebel,Heavy-Soldier,Light-Fighter,Arsonist")	
end

----------------------------------------------------------------------------------------------------

addhook("team","sdz.classes.team")
function sdz.classes.team(id,team)
	if (team==1) then
		sdz.classes.classmenut(id)
	elseif (team==2) then
		sdz.classes.classmenuct(id)
	end
end

----------------------------------------------------------------------------------------------------	

addhook("menu","sdz.classes.menu")
function sdz.classes.menu(id,menu,sel)
	if (menu=="Select your Zombie") then
		if (sel>=0 and sel<=4) then
			sdz.classes.classt[id]=sel
			if (player(id,"health")>0) then
				parse("killplayer "..id)
			end
		end
	elseif (menu=="Select your Survivor") then
		if (sel>=0 and sel<=4) then
			sdz.classes.classct[id]=sel
			if (player(id,"health")>0) then
				parse("killplayer "..id)
			end
		end
	end
end

----------------------------------------------------------------------------------------------------

addhook("spawn","sdz.classes.spawn")
function sdz.classes.spawn(id)
		
		-- LIVING-DEAD	
		if (sdz.classes.classt[id]==1) then
			parse ("setmaxhealth "..id.." 150")
			return "";
		end
		-- SLOW HULK
		if (sdz.classes.classt[id]==2) then
			parse ("setmaxhealth "..id.." 250")
			parse ("speedmod "..id.." -4")
			return "69";
		end
		-- BANSHEE
		if (sdz.classes.classt[id]==3) then
			parse ("setmaxhealth "..id.." 55")
			parse ("speedmod "..id.." 8")
			return "x";
		end
		-- PYRO-DRIFFTER
		if (sdz.classes.classt[id]==4) then
			parse ("setmaxhealth "..id.." 125")
			parse ("speedmod "..id.." -2")
			return "73";
		end

		-- REBEL
		if (sdz.classes.classct[id]==1) then
			parse ("setmaxhealth "..id.." 80")
			parse ("setarmor "..id.." 45")
			parse ("speedmod "..id.." 2")
			return "38,23,4,72";
		end
		-- HEAVY-SOLDIER
		if (sdz.classes.classct[id]==2) then
			parse ("setmaxhealth "..id.." 150")
			parse ("setarmor "..id.." 75")
			parse ("speedmod "..id.." -4")
			return "10,31,3,51";
		end
		-- LIGHT-FIGHTER
		if (sdz.classes.classct[id]==3) then
			parse ("setmaxhealth "..id.." 70")
			parse ("setarmor "..id.." 20")
			parse ("speedmod "..id.." 4")
			return "5,6,51,52,53,59";
		end
		-- ARSONIST
		if (sdz.classes.classct[id]==4) then
			parse ("setmaxhealth "..id.." 105")
			parse ("setarmor "..id.." 25")
			parse ("speedmod "..id.." -2")
			return "46,6,72,73,53";
		end
end

----------------------------------------------------------------------------------------------------

addhook("buy","sdz.classes.buy")
function sdz.classes.buy()
	return 1
end

----------------------------------------------------------------------------------------------------

addhook("drop","sdz.classes.drop")
function sdz.classes.drop()
	return 1
end

----------------------------------------------------------------------------------------------------

addhook("die","sdz.classes.die")
function sdz.classes.die()
	return 1
end

----------------------------------------------------------------------------------------------------


lol..this LUA have BUGS

old Admin Script

fame
User Off Offline

Quote
Hello friends, I need that they help me to create new functions:

!Restart to restarts the round √
!Poison [ID] √
!Slap [ID] √
!kill [ID] √
edited 1×, last 08.07.09 04:47:34 pm
To the start Previous 1 225 26 27338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview