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 2207 208 209338 339 Next To the start

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
Quote
You didn't get my point. I just copied the part where I found the mistake.
He didn't tab the second parse.


A tab is not error Lua is not like Python (Python's Syntax uses tabs) it would still execute correctly.

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Khaleed has written
blazzing on that ball script how i make the goal ?

Basically something like...
1
2
3
4
if Ball.X > Goal.X and Ball.X < Goal.X + Goal.W and Ball.Y > Goal.Y and Ball.Y < Goal.Y + Goal.H then
	goal score
	parse sv_restart
end

If someone needs, I could improve that script.

old Re: Lua Scripts/Questions/Help

siuL
User Off Offline

Quote
Blazzingxx has written
Khaleed has written
blazzing on that ball script how i make the goal ?

Basically something like...
1
2
3
4
if Ball.X > Goal.X and Ball.X < Goal.X + Goal.W and Ball.Y > Goal.Y and Ball.Y < Goal.Y + Goal.H then
	goal score
	parse sv_restart
end

If someone needs, I could improve that script.

so i need to put
goal.x = {4,4}
goal.y = {7,7} just a example
???
i didnt understand what you did o.O
you could make it full please ( lol i didnt understand the goal part sorry . )
edit:you could make like a " football script "
edited 2×, last 11.06.10 05:08:45 pm

old Re: Lua Scripts/Questions/Help

EngiN33R
Moderator Off Offline

Quote
hello, it's me again, what's wrong with this script? it does substract money, but it doesn't add them.
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
if engi==nil then engi={} end
engi.credits={}

function initArray(f,v)
	local cmd = {}
	for c = 1, f do
		cmd[c] = v
	end
	return cmd
end

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

function engi.credits.updatehud(id)
	engi.credits.hud(id,1,"000255000","Money: "..engi.credits.money[id],200,200)
end

addhook("spawn","engi.credits.spawnhud")
function engi.credits.spawnhud(id)
	engi.credits.updatehud(id)
end

addhook("collect","engi.credits.add")
function engi.credits.add(id,iid)
	if (iid==66) then
		engi.credits.money[id]=engi.credits.money[id]+100
		engi.credits.updatehud(id)
	end
	if (iid==67) then
		engi.credits.money[id]=engi.credits.money[id]+1000
		engi.credits.updatehud(id)
	end
	if (iid==68) then
		engi.credits.money[id]=engi.credits.money[id]+10000
		engi.credits.updatehud(id)
	end
	if (iid==56) then
		engi.credits.money[id]=engi.credits.money[id]+100000
		engi.credits.updatehud(id)
	end
end

addhook("say","engi.credits.drop")
function engi.credits.drop(p,t)
	if (t=="dropmoney") then
		menu(p,"Ammount to drop,100,1000,10000,100000")
		return 1
	end
end

addhook("menu","engi.credits.dropmenu")
function engi.credits.dropmenu(id,menu,sel)
	if (menu=="Ammount to drop") and (sel==1) then
		parse ("spawnitem 66 "..(player(id,"tilex")).." "..(player(id,"tiley")))
		parse ("setmoney "..id.." "..(player(id,"money"))-100)
		engi.credits.money[id]=engi.credits.money[id]-100
		engi.credits.updatehud(id)
	end
	if (menu=="Ammount to drop") and (sel==2) then
		parse ("spawnitem 67 "..(player(id,"tilex")).." "..(player(id,"tiley")))
		parse ("setmoney "..id.." "..(player(id,"money"))-1000)
		engi.credits.money[id]=engi.credits.money[id]-1000
		engi.credits.updatehud(id)
	end
	if (menu=="Ammount to drop") and (sel==3) then
		parse ("spawnitem 68 "..(player(id,"tilex")).." "..(player(id,"tiley")))
		parse ("setmoney "..id.." "..(player(id,"money"))-10000)
		engi.credits.money[id]=engi.credits.money[id]-10000
		engi.credits.updatehud(id)
	end
	if (menu=="Ammount to drop") and (sel==4) then
		parse ("spawnitem 56 "..(player(id,"tilex")).." "..(player(id,"tiley")))
		parse ("setmoney "..id.." "..(player(id,"money"))-100000)
		engi.credits.money[id]=engi.credits.money[id]-100000
		engi.credits.updatehud(id)
	end
end

engi.credits.money=initArray(32,2500)

old Re: Lua Scripts/Questions/Help

Refresh
User Off Offline

Quote
Hi guys I have an other problem... I modded a LUA and I want to know how can I make a menu with "next" and "previous" buttons.

old Re: Lua Scripts/Questions/Help

archmage
User Off Offline

Quote
@Levic
More >

old Re: Lua Scripts/Questions/Help

stealth_killer
User Off Offline

Quote
hello i need healp in cs2D where can i get license in my editor and where can i go to throw money (i want to make a rp server) pls tell i have looking for this 20 days

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
I don't think you can force players to say sth.

You can simulate a 'drop' by stripping the gun from the player and then spawning a new one of the same type on the floor, however, this gun will have full ammo, even if the original one is empty.

old Re: Lua Scripts/Questions/Help

mhd111
User Off Offline

Quote
can someone help me im trying to make the following
-a rpc which sells weapons
-a rpc which sells armors
-a rpc which sells guns and grenades
-a rpc which by talking to him you can enter a room and rest
-a rpc which allows you to enter the mine if you bought a chainsaw
-after 60seconds all players posts get to one place(teleport)
-then after 10seconds of fighting they get back to the city(teleport)
-when wave is finished all zombies get leveled up like.
-hp110
-speed 10
-armor 50

old Simple Ball Physics + Gates

SQ
Moderator Off Offline

Quote
Here you are... I had PM's about football gates, so I did it.
Script is very easy, so do what you want with it, I don't care.

IMG:https://img153.imageshack.us/img153/3362/80036212.th.png


You should use this map for first test.
http://www.4shared.com/file/7G5OyPHr/dm_Foot.html

Gate.png
IMG:https://img696.imageshack.us/img696/8274/gatef.png


Ball.png
IMG:https://img809.imageshack.us/img809/1029/balla.png


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
function InTable(n,v)
	local Table = {}
	for i = 0, n, 1 do Table[i] = v end
	return(Table)
end

BallImagePath = "gfx/lua/ball.png"	-- Image = 32*32 (Circle)
GateImagePath = "gfx/lua/gate.png"	-- Image = 64*96 (Rectangle)

WeaponsPush = true	-- Weapons Effect Ball

Ball = { X , Y, XS, YS, Cur }
Pl = { Kick = InTable(32,0) }
CT_Goal = { X, Y}
T_Goal = { X, Y}
ImagesList = {}

addhook("startround","FootBallStart")
addhook("always","FootBallUpdate")
addhook("use","FootBallKick")
addhook("attack","FootBallPush")

function FootBallStart()
	RemoveFromList()
	LoadBall(9,9)
	LoadGates()
end

function SetArea(X,Y,W,H) Area = { X = X * 32 + 16, Y = Y * 32 + 16, W = W * 32 + 16, H = H * 32 + 16 } end

function SetGoal(TEAM,X,Y)
	_G[TEAM.."_Goal"] = { X = X * 32, Y = Y * 32}
end

function ImageToList(Path,X,Y,MODE)
	local ID = image(Path,X,Y,MODE)
	table.insert(ImagesList,ID)
	return(ID)	
end

function RemoveFromList()
	for k, v in pairs(ImagesList) do freeimage(v) end
	ImagesList = {}
end

function LoadBall(X,Y)
	Ball.X, Ball.Y = X * 32 + 16, Y * 32 + 16
	Ball.XS, Ball.YS = 0, 0
	local ID = ImageToList(BallImagePath,Ball.X,Ball.Y,1)
	Ball.Cur = ID
end

function FootBallUpdate()
	local X, Y
	for k, v in pairs(player(0,"table")) do
		X, Y = player(v,"x"), player(v,"y")
		if (Dist(X,Y,Ball.X,Ball.Y) < 32) then
			local RAD = math.atan2(Y - Ball.Y,X - Ball.X)
			local Power = 2
			if (Pl.Kick[v] > 0) then
				Power, Pl.Kick[v] = 12, 0
				msg2(v,"KICK!@C")
				msg2(v,"Kick: OFF")
			end
			Ball.XS = Ball.XS - math.cos(RAD) * Power
			Ball.YS = Ball.YS - math.sin(RAD) * Power
			Ball.X = X - math.cos(RAD) * 33
			Ball.Y = Y - math.sin(RAD) * 33
		 end
	end
	if (Ball.X > Area.W or Ball.X < Area.X) then Ball.XS = -Ball.XS end
	if (Ball.Y > Area.H or Ball.Y < Area.Y) then Ball.YS = -Ball.YS end
	if (Ball.X > Area.W) then Ball.X = Area.W end
	if (Ball.Y > Area.H) then Ball.Y = Area.H end
	if (Ball.X < Area.X) then Ball.X = Area.X end
	if (Ball.Y < Area.Y) then Ball.Y = Area.Y end
	if (Ball.XS > 12) then Ball.XS = 12 elseif (Ball.XS < -12) then Ball.XS = -12 end
	if (Ball.YS > 12) then Ball.YS = 12 elseif (Ball.YS < -12) then Ball.YS = -12 end 
	Ball.X, Ball.Y = Ball.X + Ball.XS, Ball.Y + Ball.YS
	imagepos(Ball.Cur,Ball.X,Ball.Y,0)
	Ball.XS, Ball.YS = Ball.XS / 1.05, Ball.YS / 1.05
	if InArea(Ball,CT_Goal.X - 32,CT_Goal.Y - 48,CT_Goal.X + 32,CT_Goal.Y + 48) then parse("restart") msg("T SCORE!") end
	if InArea(Ball,T_Goal.X - 32,T_Goal.Y - 48,T_Goal.X + 32,T_Goal.Y + 48) then parse("restart") msg("CT SCORE!") end
end

function Dist(X1,Y1,X2,Y2)
	return( ((X1 - X2) ^ 2 + (Y1 - Y2) ^ 2) ^ .5 )
end

function FootBallKick(ID)
	local Switch = {"Off","On"}
	if (Pl.Kick[ID] > 0) then Pl.Kick[ID] = 0 else Pl.Kick[ID] = 1 end
	msg2(ID,"Kick: "..Switch[Pl.Kick[ID] + 1])
end

function FootBallPush(ID)
	local WPN = player(ID,"weapontype")
	if (WPN > 0 and WPN < 10 or WPN > 19 and WPN < 41) and WeaponsPush then
		local X = player(ID,"x")
		local Y = player(ID,"y")
		local ROT = player(ID,"rot") - 90
		local FLY = true
		while FLY do
			X, Y = X + math.cos(math.rad(ROT)) * 5, Y + math.sin(math.rad(ROT)) * 5
			if Dist(X,Y,Ball.X,Ball.Y) < 16 then
				local DMG = itemtype(WPN,"dmg") / 4
				Ball.XS, Ball.YS = Ball.XS + math.cos(math.rad(ROT)) * DMG, Ball.YS + math.sin(math.rad(ROT)) * DMG
				break
			else
				if tile(math.ceil(X/32) - 1,math.ceil(Y/32) - 1,"wall") then FLY = false end
			end
		end

	end
end

function InArea(XY,X1,Y1,X2,Y2)
	return( XY.X > X1 and XY.X < X2 and XY.Y > Y1 and XY.Y < Y2 )
end

function LoadGates()
	imagecolor(ImageToList(GateImagePath,CT_Goal.X,CT_Goal.Y,1),0,0,255)
	imagecolor(ImageToList(GateImagePath,T_Goal.X,T_Goal.Y,1),255,0,0)
end

SetArea(2,2,18,18)
SetGoal("CT",18,11)
SetGoal("T",3,11)
FootBallStart()

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
Thanks for that maybe I will change of it for any improves or changes, but you're the main scripter so you will on credits.

EDIT:
Is there any possible script that enable automatic kick player with no usgn login when the server full? I want to make this because I hate no login users came to my server and flood/spamming/hacking.

thanks
edited 1×, last 15.06.10 04:47:46 am

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
Alright, I've seen a lot of scripts with colons in their functions, is that just a way of naming it, or does it have some meaning to it?
To the start Previous 1 2207 208 209338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview