Forum

> > CS2D > General > Football lua !
Forums overviewCS2D overviewGeneral overviewLog in to reply

English Football lua !

31 replies
Page
To the start Previous 1 2 Next To the start

old Re: Football lua !

Zune5
COMMUNITY BANNED Off Offline

Quote
Why did you put it in Spanish?
You noticed that everyone in the English forum speaks English right?

old Re: Football lua !

Flacko
User Off Offline

Quote
Alright.
I didn't do this for the forum ok? That's why I said "My football mod" I made this for my server, and posted it here because it may help someone making another mod.
If you've got a problem with that you can make your own football mod fully in english and post it here (or translate mine)

old Re: Football lua !

KimKat
GAME BANNED Off Offline

Quote
Flacko I translated your Script and uhm tried it, but Google translator made the script messy it added spaces to break scripting/coding and such.

So now when I fixed it, it says "concanate y coordinates" or something. It gives me "nil value" also. I don't even know what the problem with the script is...

And when you score the scores don't change. They're just 0 all the time, and scoreboard disappears when you grab a snowball sometimes. Perhaps it's just my connection...

old Re: Football lua !

Flacko
User Off Offline

Quote
WTH kimkat lol, you just have to translate the strings.

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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
if not flacko then flacko={} end
flacko.sjam={}

ball = 75
knife = 50

function hudtext2(id,tid,color,txt,x,y)
	local toprint = ("©"..color.." "..txt)
	parse('hudtxt2 '..id..' '..tid..' "'..toprint..'" '..x.." "..y)
end

addhook("spawn","flacko.sjam.spawn")
function flacko.sjam.spawn(id)
	flacko.sjam.updatehud(id)
	return "x"
end

function flacko.sjam.updatehud(id)
	if(player(id,"exists")) then
		hudtext2(id,1,"255000000",flacko.sjam.tscore,13,179)
		hudtext2(id,2,"000128255",flacko.sjam.ctscore,13,194)
		hudtext2(id,3,"255255000","-",320,20)
		if(flacko.sjam.playerwball>0 and flacko.sjam.ballinair==false) then
			if(player(flacko.sjam.playerwball,"exists"))then
				hudtext2(id,4,"255255000",player(flacko.sjam.playerwball,"name"),13,209)
			else
				hudtext2(id,4,"255255000","",13,209)
			end
		else
			hudtext2(id,4,"255000000","No one's got the ball...",13,209)
		end
	end
end

addhook("die","flacko.sjam.die")
function flacko.sjam.die(victim,killer,weapon,x,y)
	if(flacko.sjam.playerwball == victim) then
		parse("spawnitem "..ball.." "..pixtotile(x).." "..pixtotile(y))
		flacko.sjam.playerwball = 0
	end
	return 1
end

addhook("leave","flacko.sjam.leave")
function flacko.sjam.leave(id)
	local xplayer = player(id,"xtile")
	local yplayer = player(id,"ytile")
	if(flacko.sjam.playerwball==id) then
		parse("spawnitem "..ball.." "..xplayer.." "..yplayer)
		flacko.sjam.playerwball = 0
	end
end

addhook("buy","flacko.sjam.buy")
function flacko.sjam.buy()
	return 1
end

addhook("drop","flacko.sjam.drop")
function flacko.sjam.drop(id)
	if(flacko.sjam.ballinair==false) then
		flacko.sjam.playerwball = 0
		flacko.sjam.ballinair = false
	else
		return 1
	end
end

addhook("startround","flacko.sjam.startround")
function flacko.sjam.startround()
	flacko.sjam.playerwball = 0
	parse("spawnitem "..ball.." 19 12")
end

addhook("minute","flacko.sjam.minute")
function flacko.sjam.minute()
	if(flacko.sjam.playerwball==0) then
		tab = item(0,"table")
		if(#tab==0) then
			parse("spawnitem "..ball.." 19 12")
		end
	end
end

function pixtotile(pix)
	ret = math.floor(pix/32)
	return ret
end
function tiletopix(til)
	ret = til*32
	return ret
end

function flacko.sjam.checkwep(id,wep) --Returns 0 if finds weapon, otherwise it returns 1
	local weapons = playerweapons(id)
	for i = 1, #weapons do
		if weapons[i] == wep then
			return 0
		end
	end
	return 1
end

flacko.sjam.ctscore = 0
flacko.sjam.tscore = 0
flacko.sjam.playerwball = 0
flacko.sjam.ballinair = false

addhook("collect","flacko.sjam.collect")
function flacko.sjam.collect(id,iid,typ)
	if(typ==ball and flacko.sjam.playerwball == 0) then
		giveball(id)
	else
		return 1
	end
end

addhook("walkover","flacko.sjam.walkover")
function flacko.sjam.walkover(id,iid,typ)
	if(typ~=ball or flacko.sjam.playerwball~=0)then
		return 1
	end
end

function giveball(id)
	parse("equip "..id.." "..ball)
	parse("setweapon "..id.." "..ball)
	parse("strip "..id.." "..knife)
	flacko.sjam.playerwball = id
	for i=1,32 do
 		if(player(i,"exists")) then
			flacko.sjam.updatehud(i)
		end
	end
	flacko.sjam.ballinair = false
end

function stripball(id)
	parse("equip "..id.." "..knife)
	parse("strip "..id.." "..ball)
	flacko.sjam.playerwball = 0
end

addhook("hit","flacko.sjam.hit")
function flacko.sjam.hit(id,src,wep)
	if(wep==knife) then
		if(flacko.sjam.playerwball==id) then
			if(flacko.sjam.ballinair==false) then
				stripball(id)
				giveball(src)
			end
		end
	elseif(wep==ball) then
		if(flacko.sjam.playerwball==src) then
			if(flacko.sjam.ballinair==false) then
				stripball(src)
				giveball(id)
			end
		end
	end
	return 1
end


function check_boundbox(id,x,tx,y,ty,ptx,pty)
	if(ptx<player(id,"x")) then --If moves to left
		if(ptx<tx) then --If enters bounding box
			parse("setpos "..id.." "..(player(id,"x")+3.6).." "..(player(id,"y"))+3.6)
		end
	end
end

addhook("attack","flacko.sjam.attack")
function flacko.sjam.attack(id)
	if(flacko.sjam.playerwball==id) then
		if(player(id,"weapontype")==ball) then
			flacko.sjam.ballinair = true
		end
	end
end

addhook("projectile","flacko.sjam.projectile")
function flacko.sjam.projectile(id,wep,x,y)
	if(flacko.sjam.playerwball==id) then
		if(wep==ball) then
			local xplayer = player(id,"x")
			local yplayer = player(id,"y")
			if(xplayer<x) then x=x-1 elseif (xplayer>x) then x=x+1 end
			if(yplayer<y) then y=y-1 elseif (yplayer>y) then y=y+1 end
			x = pixtotile(x)
			y = pixtotile(y)
			if(y>=11 and y<=13) then
				if(x==4) then
					flacko.sjam.ctscore = flacko.sjam.ctscore + 1
					parse("msg ©000128255"..player(id,"name").." Scores for CT!@C")
					if(player(id,"team")==2) then parse("setscore "..id.." "..(player(id,"score")+1))
					elseif(player(id,"team")==1) then parse("setscore "..id.." "..(player(id,"score")-3)) end
				elseif(x==34) then
					flacko.sjam.tscore = flacko.sjam.tscore + 1
					parse("msg ©255000000"..player(id,"name").." Scores for T!@C")
					if(player(id,"team")==2) then parse("setscore "..id.." "..(player(id,"score")-3))
					elseif(player(id,"team")==1) then parse("setscore "..id.." "..(player(id,"score")+1)) end
				end
			end
		parse("spawnitem "..ball.." "..x.." "..y)
		stripball(id)
		flacko.sjam.ballinair = false
		for i=1,32 do flacko.sjam.updatehud(i) end
		end
	end
end

Here I translated it, however, you still have to make the goal checking to fit into your map (i didn't comment it in this script bcause im lazy).
Scores should be working fine, last time I tested them they were working

old Re: Football lua !

KimKat
GAME BANNED Off Offline

Quote
Ok it's working... although it's quite difficult to configure where the goal is... at the moment I can only score in one tile but it doesn't count as a goal... lol. So confusing...

This is the part I don't understand...
1
2
3
4
if(y>=11 and y<=13) then
                    if(x==4) then 

elseif(x==34) then
Is that supposed to be a way to create the actual goal?

###
###
###
###


Cause at the moment it's just like this...
1
2
3
4
if(y>=6 and y<=10) then
                    if(x==2) then

elseif(x==32) then
###
###
###
###

I don't understand the "elseif(x==32)" is that to duplicate the goal for the other team?

old Re: Football lua !

KimKat
GAME BANNED Off Offline

Quote
Flacko has written
Here I explained (i tried to explain) it with a cute drawing in paint

http://i29.tinypic.com/2mdlx7t.jpg

You may also want to google about bounding boxes

Edit: Plz appreciate my effort with paint
That actually explained alot, although the "x==4" and "x==34" is quite strange but I assume that is the distance between the two goals so it makes sense. I'll work on the bounding boxes part.

[EDIT: I've configured the bounding box and it works properly, great script imho. It seems you've found a way to strip a Player when the snowball is thrown and/or is in the air.]

Flacko you're pretty good at this, how much time have you spent learning LUA scripting?
edited 1×, last 08.08.09 08:41:15 pm

old closed Lua Script??

mattiedee
User Off Offline

Quote
WHERE DOWNLOAD THE LUA?
edited 1×, last 24.10.09 06:39:07 pm
To the start Previous 1 2 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview