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 2103 104 105338 339 Next To the start

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
-WiLSoN- has written
add the bold text:
Spoiler >

you would have to do an experience and level gaining function.
i'm too busy to think of somehting like that but it's not really hard.
EDIT:
is it possible to free images liek radars and that kind of things ??

any script i could download and copy-pasta the function?

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
yeah may be,but you wont learn it.
also if you want to do such things you should ask the script owner before doing it.

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Vectar666 has written
How can I put string parameter into function?


Lua isn't like C or other languages that require you to pass all the parameters to the function and match them in type (int, char, etc.).
In lua you can create a function like
1
2
3
4
5
6
function myfunction(a,b,c)
	if not a then a = 1 end
	if not b then b = 2 end
	if not c then c = 3 end
	return a+b+c
end

That way you can even call the function without parameters and you can even pass strings to it (however, it won't work).

It would work if you concatenate them (not arithmetic ops.)
1
2
3
4
5
function myfunction(a,b,c)
	if not a then a = "Lua "
	if not b then b = "a scripting "
	if not c then c = "language"
	return a..b..c

ok, i G2g now.

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
jackisokay2 has written
very true, very true. any websites i can learn it off of then?

uhm you should think it.
as i said it isn't really hard. use IF's on a kill or hit hook to gain experience
level gaining should be different though

old Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Quote
With the image function would it be possible to create a "cheat" to allow a player that is a terrorist to look like a counter-terrorist I am not looking for someone to hand out a script just wanted to know if it would be possible.

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
parse("hudtxt2 "..player.." "..tid.." '"..txt.."' "..x.." "..y.." "..align)
player = player id
tid = text id
txt = text
x = pixel X position
y = pixel Y position
align = ( 0 = left, 1 = center, -1 = right)
on text should be :
Level : "..sample.zombie.level.."
Exp : "..sample.zombie.exp.."
EDIT:
Is it possible to free images that are included already ??.
like radars and that kind of things ??

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
-WiLSoN- has written
parse("hudtxt2 "..player.." "..tid.." '"..txt.."' "..x.." "..y.." "..align)
player = player id
tid = text id
txt = text
x = pixel X position
y = pixel Y position
align = ( 0 = left, 1 = center, -1 = right)
on text should be :
Level : "..sample.zombie.level.."
Exp : "..sample.zombie.exp.."
EDIT:
Is it possible to free images that are included already ??.
like radars and that kind of things ??


ok.... so where do i put this? :p

Spoiler >

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
-WiLSoN- has written
EDIT:
Is it possible to free images that are included already ??.
like radars and that kind of things ??

For Lua image objects only.

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
@Blazzingxx
so it wont work ?

@jackisokay2
it depends.
i would put it on team function.
like
1
2
3
4
5
6
7
addhook("team","sample.zombie.team")
function sample.zombie.team(id,team)
	if (team == 1) then
		zombiemenu(id)
		parse("hudtxt2 ...") -- the hudtxt2 thing
	end
end
and if you will add lvls for both teams (ct,t)
this:
1
2
3
4
5
6
7
addhook("team","sample.zombie.team")
function sample.zombie.team(id,team)
	parse("hudtxt2 ...") -- the hudtxt2 thing
	if (team == 1) then
		zombiemenu(id)
	end
end
PS:
jack tab your scripts ! :S

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
-WiLSoN- has written
@Blazzingxx
so it wont work ?

@jackisokay2
it depends.
i would put it on team function.
like
1
2
3
4
5
6
7
addhook("team","sample.zombie.team")
function sample.zombie.team(id,team)
	if (team == 1) then
		zombiemenu(id)
		parse("hudtxt2 ...") -- the hudtxt2 thing
	end
end



and if you will add lvls for both teams (ct,t)
this:
1
2
3
4
5
6
7
addhook("team","sample.zombie.team")
function sample.zombie.team(id,team)
	parse("hudtxt2 ...") -- the hudtxt2 thing
	if (team == 1) then
		zombiemenu(id)
	end
end
PS:
jack tab your scripts ! :S


sorry! i keep forgetting to tab them!


EDIT:

where do i put this?

1
2
Level: "..sample.zombie.level.."
Exp : "..sample.zombie.exp.."
edited 2×, last 26.11.09 11:08:03 pm

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
so... not like this? lol

1
2
3
4
5
6
7
8
parse("hudtxt2 "..player.." "..tid.." '"..txt.."' "..x.." "..y.." "..align)
player = player id
tid = text id
txt = Level: "..sample.zombie.level.."
Exp : "..sample.zombie.exp.." 
x = pixel X position
y = pixel Y position
align = ( 0 = left, 1 = center, -1 = right)

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
uhm no,
that things i wrote under the parse were the meanings of each parameter...
hudtxt2 e.g
1
parse("hudtxt2 1 1 '©255000000Hi ' 210 415 0")
1st "1" means this will be displayed just for player 1
2nd "1" means this is the first hudtxt you use
"©255000000" is the color (red)
"Hi" Is the text
"210" is the X position
"415" is the Y position
"0" means it will be left aligned.
If you don't use a color for this the text will be yellow.

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
-WiLSoN- has written
uhm no,
that things i wrote under the parse were the meanings of each parameter...
hudtxt2 e.g
1
parse("hudtxt2 1 1 '©255000000Hi ' 210 415 0")
1st "1" means this will be displayed just for player 1
2nd "1" means this is the first hudtxt you use
"©255000000" is the color (red)
"Hi" Is the text
"210" is the X position
"415" is the Y position
"0" means it will be left aligned.
If you don't use a color for this the text will be yellow.


oh! lol i feel stupid! hah thanks! when im done with the script ima put your name in the credits! you have helped me a lot!

so, like this
1
2
3
4
5
addhook("team","sample.zombie.team")
function sample.zombie.team(id,team)
     parse("hudtxt2" "1" "1" "©255000000Hi" "210" "415" "0") 
     if (team == 1) then
          zombiemenu(id)
edited 1×, last 27.11.09 12:27:14 am

old Re: Lua Scripts/Questions/Help

Trotskygrad
User Off Offline

Quote
Flacko has written
Trotskygrad has written
So I'm trying to implement a ranking system, that draws colored bars (on the shoulders) of a player depending on how many kills the player has. I can't get the image functions working though, Can anyone help?


I hope we can help you.
Show us your script so we can fix it


Prepare for a half copypasta/half handcoded script
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
dofile("sys/lua/wrapper.lua")

if script==nil then script={} end
script.jail={}

function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end

script.jail.prisonerstat=initArray(32)
script.jail.lkills=initArray(32)
script.jail.rank=initArray(32)
script.jail.guardstat=initArray(32)
script.jail.headguard=initArray(32)

parse("mp_unbuildable turret")

addhook("collect","script.jail.collect")
function script.jail.collect(id,type)
	if type==3 then
		msg2(id, "You have picked up a medgun, shots will heal enemies")
	end
end

addhook("spawn","script.jail.spawn")
function script.jail.spawn(id)
	if script.rp.headguard(id)==1 then
		return 32,4,59,80
	end
	if player(id,"team")==2 then	
		if script.jail.rank[id]=1 then
			image("gfx/Snowy Prison/private.bmp",0,0,200+id)	-- Create image @ Player
			imagecolor(id,0,0,0)						-- Make stripe black
			imageblend(id,1)								-- Make image glow
			imagealpha(id,0.5)	
		end
		if script.jail.rank[id]=2 then
		--Image Code goes here
		end
		if script.jail.rank[id]=3 then
		--Image Code goes here
		end
		if script.jail.rank[id]=4 then
		--Image Code goes here
		end
		if script.jail.rank[id]=5 then
		--Image Code goes here
		end
	end
end

addhook("kill","script.jail.frag")
function script.jail.frag(killer,victim,type)
	if player(killer, "team")==2 and player(victim, "team")==1 then
		if script.jail.prisonerstat[victim]==0 then
			msg2(killer,"O.o    A bit trigger happy, no?")
		end
		if script.jail.prisonerstat[victim]==1 then
			msg2(killer,"Good Job!")
			script.jail.lkills[killer]=script.jail.lkills[killer]+1
			if script.jail.lkills[killer]<=3 then
				
		end
	end
	if player(killer, "team")==1 and player(victim, "team")==2 then
		script.jail.prisonerstat[killer]=1
		msg2(killer, "Quick, escape... they'll hunt you now")
	end
end
	
addhook("hit","script.jail.hit")
function script.jail.hit(id,source,weapon,hpdmg,apdmg)
	if player(id, "team")==1 and player(source, "team")==2 and script.jail.prisonerstat[id]==0 then
		script.jail.guardstat[source]=1
	end
	if player(source, "team")==1 and player(id, "team")==2 then
		script.jail.prisonerstat[source]==1
	end
	if weapon==3 then
		--Deagle medgun
		hithp=player(id, "health")
		--heals for 30 HP
		sethealth(id,hithp+30)
		return 1
	end
	if weapon==50 and player(id, "team")==2 and player (source, "team")==2 then
	--CTs can knife each other to heal
		hithp=player(id, "health")
		sethealth(id,hithp+10)
		return 1
	end
end

addhook("join","script.jail.join")
function script.jail.join(p)
	msg2(p,"Welcome to the [CC] RP Server, "..player(p,"name").."!")
	msg2(p,"Please send any feedback to trotskygrad@gmail.com")
	script.jail.rank[p]=1
end

addhook("say","script.jail.say")
function script.jail.say(p,txt)

	-- Time e.g.: 04:36 pm
	if (txt=="time") then msg(os.date("Time: %I:%M %p")); end

	-- Date e.g.: Wednesday, 25 Feb 2009
	if (txt=="date") then msg(os.date("Date: %A, %d %b %Y")); end

	-- Slap me
	if (txt=="slap me") then parse("slap "..p); end

	-- Show idlers (idle for 10 secs or longer)
	if (txt=="idlers") then
		idlers=0
		for i=1,32 do
			if (player(i,"exists")) then
				if (player(i,"idle")>9) then
					idlers=idlers+1
					msg(player(i,"name").." is idle for "..player(i,"idle").." secs!")
				end
			end
		end
		if (idlers==0) then msg("Nobody idles!") end
	end
	
	-- SOUND: That's the way I like it
	if (txt=="the way") then parse("sv_sound \"fun/thats_the_way.wav\""); end

	-- SOUND: Okay let's go
	if (txt=="lets go") then parse("sv_sound \"hostage/hos2.wav\""); end

	-- SOUND: Buaraarahahrahrrrr harr!
	if (txt=="zombies!") then parse("sv_sound \"player/zm_spray.wav\""); end

	-- SOUND: Mystery
	if (txt=="mystery") then parse("sv_sound \"env/mystery.wav\""); end
	
	--Headguard enabler
	if (txt=="!headguard") then 
		if player(p, "team")==2 then
			headguard=0
			for i=1,32 do
				if (player(i,"exists")) then
					if script.jail.headguard[i]==1 then
						headguard=1
					end
				end
			end
			if headguard==0 then
				script.jail.headguard[p]=1
				msg2(p,"You are now the Head Guard! Give orders to the guards to properly manage the prisoners")
			end
		end
	end
	--Rules
	if (txt=="!rules") then 
		msg2(p,"Rules: 1. Do not freekill. Freekilling is defined as killing a prisoner who has not attacked a guard. Disobeying orders is a reason to kill a prisoner, but do not kill prisoners after thay disobey once.")
	end
end

--Armor stripper
addhook("startround","rstart")
function rstart()
     for i = 1,32 do
          if (player(i,"exists")) then
               parse("strip "..i.." 0")
          end
     end
end

--reset parameters on leave
addhook("leave","script.jail.leave")
function script.jail.leave(id, reason)	
	script.jail.headguard[id]=0
	script.jail.lkills[id]=0
	script.jail.rank[id]=0
end

old Re: Lua Scripts/Questions/Help

NozliW
User Off Offline

Quote
jackisokay2 has written
so, like this
1
2
3
4
5
addhook("team","sample.zombie.team")
function sample.zombie.team(id,team)
     parse("hudtxt2" "1" "1" "©255000000Hi" "210" "415" "0") 
     if (team == 1) then
          zombiemenu(id)

Yeah

old Re: Lua Scripts/Questions/Help

jackisokay2
User Off Offline

Quote
-WiLSoN- has written
jackisokay2 has written
so, like this
1
2
3
4
5
addhook("team","sample.zombie.team")
function sample.zombie.team(id,team)
     parse("hudtxt2" "1" "1" "©255000000Hi" "210" "415" "0") 
     if (team == 1) then
          zombiemenu(id)

Yeah


sweet, i learned something
To the start Previous 1 2103 104 105338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview