Forum

> > CS2D > Scripts > a menu with scripts ...
Forums overviewCS2D overview Scripts overviewLog in to reply

English a menu with scripts ...

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

old a menu with scripts ...

hunter139
User Off Offline

Quote
P.S.: i dont have the script of reset score, badwords, show damage, etc... you need to add it to the script please, as what every menu does
hi there
i am in trouble
i need this for my server
a script controller through a menu
i need this

1
2
3
4
5
6
7
8
9
reset_score = 0
badwords = 0
show_damage = 0
unlimited_build = 0
fast_build = 0
no_reload = 0
wallhack = 0
godmode = 0
explosive_snowballs = 0

The menu

1
menu ("Activate A Script,Reset Score|"..reset_score..",Fast Build|"..fast_build..",Unlimited Build|"..unlimited_build..",No Reload|"..no_reload..",Badwords|"..badwords..",Show Damage|"..show_damage..",Wallhack|"..wallhack..",Explosive Snowballs|"..explosive_snowballs..",God Mode|"..godmode.."")

Of Course only for admins


for example, if you click on Reset Score, reset score will be activated

1
2
if reset_score == 0 then
	reset_score = 1

and if you click on it again, reset score will be disactivated

PLEASE CAN YOU DO IT ?
I need it in 1 lua file
Please i am noob at scripting
you will be really credited

Last Thing >
edited 4×, last 26.08.13 06:05:28 am

old Re: a menu with scripts ...

Dovahkin
User Off Offline

Quote
It doesn't need this. resetscore = xx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
addhook("serveraction","hey")
function hey(id,s)
if s==1 then
menu(id,"Resetscore,Reset?")
end
end

addhook("menu","menus")
menus(id,title,button)
if (title=="Resetscore") then
if button==1 then
parse("setscore "..id.." 0")
parse("setdeath "..id.." 0")
msg2(id,You have successfully reseted your score!@C")
end
end
end
Untested! and I don't know if it's death or deaths. But you'll get the point.

EDIT! : I didn't indent or tab the code because I'm using my tablet.

old Re: a menu with scripts ...

MikuAuahDark
User 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
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
Admins={
	--[[ Add admins here. Example:
	53360,
	98519
	Separate by comma.
	]]
	123734
}
DefaultBuildingLimit={
	barricade=1000,
	["barbed wire"]=1000,
	["wall i"]=1000,
	["wall ii"]=1000,
	["wall iii"]=1000,
	["gate field"]=5,
	dispenser=1,
	turret=1,
	supply=1,
	["teleporter entrance"]=1,
	["teleporter exit"]=1
}
BuildingPrice={
	300,
	500,
	1000,
	2000,
	3000,
	1500,
	5000,
	5000,
	5000,
	0,
	0,
	0,
	3000,
	3000
}
	
setmetatable(DefaultBuildingLimit,{
	__call=function(_,t)
		for n,v in pairs(_) do
			if t then
				parse("mp_building_limit \""..n.."\" "..v)
			else
				parse("mp_building_limit \""..n.."\" 2147483647")	-- Max value. building limit is using signed 4byte(max 2147483647)
			end
		end
	end,
})
CMD={}
COMMAND=CMD
BadWordList={}
reset_score = 0
badwords = 0
show_damage = 0
unlimited_build = 0
fast_build = 0
no_reload = 0
wallhack = 0
godmode = 0
explosive_snowballs = 0
HitList={}
god={}

for i=1,32 do HitList[i]=0 god[i]=false end

function ValAval(t,v)
	for a,u in pairs(t) do
		if u==v then
			return a
		end
	end
end

function ToBool(v)
	if v==0 then return false end
	return not not v
end

function OnOff(v)
	local boolean=ToBool(v)
	if boolean==false then return "Off"
	else return "On" end
end

function AuahDark_projectile(id,w,x,y)
	if w==75 then
		parse("explosion "..x.." "..y.." 75 60 "..id)
	end
end

function AuahDark_attack(id)
	parse("equip "..id.." "..player(id,"weapontype"))
end

function AuahDark_buildattempt(id,type,x,y,mode)
	if player(id,"money")>=BuildingPrice[type] then
		parse("spawnobject "..type.." "..x.." "..y.." "..player(id,"rot").." "..mode.." "..player(id,"team").." "..id.."; setmoney "..id.." "..player(id,"money")-BuildingPrice)
		return 1
	end
end

function CMD.resetscore(id)
	if _G.resetscore==1 then
		parse("setscore "..id.." 0")
		parse("setdeaths "..id.." 0")
		msg("\169000255000"..player(id,"name").." used resetscore")
	end
end

function CMD.god(id)
	if godmode==1 then
		if god[id]==false then
			god[id]=true
			msg("\169000255000Godmode enabled")
		else
			god[id]=false
			msg("\169255000000Godmode disabled")
		end
	end
end

addhook("join","AuahDark_join")
function AuahDark_join(id)
	HitList[id]=0
	god[id]=false
end

addhook("hit","AuahDark_hit")
function AuahDark_hit(id,pl,w,hp)
	if god[id] then return 1 end
	if w==75 and explosive_snowballs==1 then
		return 1
	end
	if show_damage==1 then
		if HitList[pl]>0 then
			freetimerEx(HitList[pl])
		end
		HitList[pl]=timerEx(500,loadstring("parse(\"hudtxt2 "..pl.." 49\") HitList["..pl.."]=0"),1)
		parse("hudtxt2 "..pl.." 49 \"\169255255255-"..hp.." HP\" 320 230 1")
	end
end

addhook("say","Auahark_say")
function Auahark_say(id,txt)
	if badwords==1 then
		for n,v in pairs(BadWordList) do
			if txt:find(v) then
				parse("kick "..id)
				return 1
			end
		end
	end
	if txt:sub(1,1)=="!" then
		local Params={}
		for w in string.gmatch(txt,"%S+") do
			table.insert(Params,tonumber(w) or w)
		end
		for n,v in pairs(CMD) do
			if n==Params[1]:sub(2) then
				table.remove(Params,1)
				v(id,unpack(Params))
				return 1
			end
		end
	end
end

addhook("serveraction","AuahDark_serveraction")
function AuahDark_serveraction(id,a)
	if a==1 then
		if ValAval(Admins,player(id,"usgn")) then
			menu(id,"Activate A Script,Reset Score|"..OnOff(reset_score)..",Fast Build|"..OnOff(fast_build)..",Unlimited Build|"..OnOff(unlimited_build)..",No Reload|"..OnOff(no_reload)..",Badwords|"..OnOff(badwords)..",Show Damage|"..OnOff(show_damage)..",Wallhack|"..OnOff(wallhack)..",Explosive Snowballs|"..OnOff(explosive_snowballs)..",God Mode|"..OnOff(godmode))
		end
	elseif a==3 and wallhack==1 then
		local rot = player(id,"rot")
		if rot<(-90) then rot=rot+360 end
		local angle = math.rad(math.abs(rot+90)) - math.pi
		local x = player(id,"x") + math.cos(angle) * --[[Speed:]]10
		local y = player(id,"y") + math.sin(angle) * --[[Speed:]]10
		if x>0 and y>0 and x<map("xsize")*32 and y<map("ysize")*32 then
			parse("setpos "..id.." "..math.floor(x).." "..math.floor(y))
		end
	end
end

addhook("menu","AuahDark_menu")
function AuahDark_menu(id,men,sel)
	if men=="Activate A Script" then
		if sel>0 then
			if sel==1 then
				if reset_score==0 then
					reset_score=1
					msg("\169000255000Resetscore enabled by "..player(id,"name"))
				else
					reset_score=0
					msg("\169255000000Resetscore disabled by "..player(id,"name"))
				end
			elseif sel==2 then
				if fast_build==0 then
					fast_build=1
					unlimited_build=1
					DefaultBuildingLimit(false)
					addhook("buildattempt","AuahDark_buildattempt")
					msg("\169000255000Fast build and unlimted build enabled by "..player(id,"name"))
				else
					fast_build=0
					unlimited_build=0
					DefaultBuildingLimit(true)
					freehook("buildattempt","AuahDark_buildattempt")
					msg("\169255000000Fast build and unlimted build disabled by "..player(id,"name"))
				end
			elseif sel==3 then
				if unlimited_build==0 then
					unlimited_build=1
					DefaultBuildingLimit(false)
					msg("\169000255000Unlimted build enabled by "..player(id,"name"))
				else
					unlimited_build=0
					fast_build=0
					DefaultBuildingLimit(true)
					freehook("buildattempt","AuahDark_buildattempt")
					msg("\169255000000Fast build and unlimited build disabled by "..player(id,"name"))
				end
			elseif sel==4 then
				if no_reload==0 then
					no_reload=1
					addhook("attack","AuahDark_attack")
					msg("\169000255000No reload and unlimited ammo enabled by "..player(id,"name"))
				else
					no_reload=0
					freehook("attack","AuahDark_attack")
					msg("\169255000000No reload and unlimited ammo disabled by "..player(id,"name"))
				end
			elseif sel==5 then
				if badwords==0 then
					badwords=1
					msg("\169000255000Anti-badwords enabled by "..player(id,"name"))
				else
					badwords=0
					msg("\169255000000Anti-badwords disabled by "..player(id,"name"))
				end
			elseif sel==6 then
				if show_damage==0 then
					show_damage=1
					msg("\169000255000Show damage enabled by "..player(id,"name"))
				else
					show_damage=0
					msg("\169255000000Show damage disabled by "..player(id,"name"))
				end
			elseif sel==7 then
				if wallhack==0 then
					wallhack=1
					msg("\169000255000Wallhack enabled by "..player(id,"name"))
				else
					wallhack=0
					msg("\169255000000Wallhack disabled by "..player(id,"name"))
				end
			elseif sel==8 then
				if explosive_snowballs==0 then
					explosive_snowballs=1
					addhook("projectile","AuahDark_projectile")
					msg("\169000255000Explosive snowballs enabled by "..player(id,"name"))
				else
					explosive_snowballs=0
					freehook("projectile","AuahDark_projectile")
					msg("\169255000000Explosive snowballs disabled by "..player(id,"name"))
				end
			elseif sel==9 then
				if godmode==0 then
					godmode=1
					msg("\169000255000God mode enabled by "..player(id,"name"))
				else
					godmode=0
					msg("\169255000000God mode disabled by "..player(id,"name"))
				end
			end
			menu(id,"Activate A Script,Reset Score|"..OnOff(reset_score)..",Fast Build|"..OnOff(fast_build)..",Unlimited Build|"..OnOff(unlimited_build)..",No Reload|"..OnOff(no_reload)..",Badwords|"..OnOff(badwords)..",Show Damage|"..OnOff(show_damage)..",Wallhack|"..OnOff(wallhack)..",Explosive Snowballs|"..OnOff(explosive_snowballs)..",God Mode|"..OnOff(godmode))
		end
	end
end
Required file cs2d Timer Extra function(timerEx) v4.0
Godmode needs to enabled with command !god
It does not disable player godmodes when godmode is disabled in menu. only prevent player from using it
Resetscore is use-able with command

old Re: a menu with scripts ...

hunter139
User Off Offline

Quote
hey, thank you very much i will test later
about reset and !god ...
i want to activate them in the menu, then if i say !rs, then score reseted, if reset score, disabled then, when a player say !rs, his score does not reset


How can i use this file cs2d Timer Extra function(timerEx) v4.0

also, need godmod and wallhack for admin only, others for all players (sorry for tell now ...)
edited 1×, last 26.08.13 02:20:03 pm

old Re: a menu with scripts ...

MikuAuahDark
User Off Offline

Quote
user hunter139 has written
i want to activate them in the menu, then if i say !rs, then score reseted, if reset score, disabled then, when a player say !rs, his score does not reset


How can i use this file cs2d Timer Extra function(timerEx) v4.0

also, need godmod and wallhack for admin only, others for all players (sorry for tell now ...
Yes, it doing it like that.
bdw the command is !resetscore. but you can add this in end of code to add !rs:
1
CMD.rs=CMD.resetscore

just dofile("sys/lua/timerex.txt")(make sure that you already download the timerEx)

Ow, then add some filtering code
1
if ValAval(Admins,player(id,"usgn")) then
edited 1×, last 26.08.13 02:23:06 pm

old Re: a menu with scripts ...

MikuAuahDark
User Off Offline

Quote
that's because you didn't install the file cs2d Timer Extra function(timerEx) v4.0 yet.

EDIT: Resetscore fix(just replace CMD.resetscore with this one):
1
2
3
4
5
6
7
function CMD.resetscore(id)
     if _G.reset_score==1 then
          parse("setscore "..id.." 0")
          parse("setdeaths "..id.." 0")
          msg("\169000255000"..player(id,"name").." used resetscore")
     end
end

Fast build is working. i already test it.

old Re: a menu with scripts ...

hunter139
User Off Offline

Quote




fast build dont work
and show damage too
others are perfect


please can you seperate fast build and unlimited build
i mean, when click on fast build, the build is fast but not unlimited, when you click on unlimited build, build is unlimited but not fast



**********EDIT**********

can you please add :
> position, in tiles and pixels ( a hud)
> time with seconds (a hud) [example ] Server Time : 16:17:23     Server Date : 26/08/2013

of course, please add next and back buttons

[by the way, i will stick this to another script so i need this menu format

(Page 1)
button 1
button 2
button 3
button 4
button 5
button 6
button 7
Next Page
Back

(Page 2)
button 1
button 2
button 3
button 4
button 5
button 6
button 7
button 8
Previous Page
edited 4×, last 27.08.13 03:13:52 am

old Re: a menu with scripts ...

MikuAuahDark
User Off Offline

Quote
Fastbuild Fix:
1
2
3
4
5
6
function AuahDark_buildattempt(id,type,x,y,mode)
     if player(id,"money")>=BuildingPrice[type] then
          parse("spawnobject "..type.." "..x.." "..y.." "..player(id,"rot").." "..mode.." "..player(id,"team").." "..id.."; setmoney "..id.." "..player(id,"money")-BuildingPrice[type],0)
          return 1
     end
end
it now decrease player money.

About show damage, are you already install file cs2d Timer Extra function(timerEx) v4.0 yet? show damage require a function named timerEx.

old Re: a menu with scripts ...

hunter139
User Off Offline

Quote
IMG:https://i70.servimg.com/u/f70/18/27/02/80/screen18.png


@user MikuAuahDark i think i caused much touble to you ...
but you are the best helper, you and @user Infinite Rain

other adds request (if refused, no problem) >
edited 3×, last 27.08.13 03:48:05 am

old Re: a menu with scripts ...

MikuAuahDark
User Off Offline

Quote
*.txt cannot be used on autorun folder. dofile it at server.lua
1
dofile("sys/lua/autorun/timerEx.txt")
also you don't need timerEx_desc.txt just only timerEx.txt

Also about fast build and unlimted build: it cannot be separated. it's possible but it can make your server laggy when there is too many objects because it using loop to check player building and type.

old Re: a menu with scripts ...

hunter139
User Off Offline

Quote
can you these script :

position (tiles and pixels (a hud))
level (with save and load)
time (with seconds/minutes/hours)
date (day/month/year)
free build (no money)
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview