Forum

> > CS2D > Scripts > joinhook not working
Forums overviewCS2D overview Scripts overviewLog in to reply

English joinhook not working

16 replies
To the start Previous 1 Next To the start

old joinhook not working

KagamineLen
User Off Offline

Quote
i found the error and it was fixed now i edited the post with the new codes with a bug and i need help finding that bug there is no error code, the server name and privilege hud was not showing on dedicated server maybe the join hook is not working, and the chat also is not working pressing z and typing something shows nothing, i really need help

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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
function InitArray(m,val)
array={}
     for i=1,m do
     array[i]=val
     end
return array
end

if(ppl==nil) then ppl={} end
if(ppl.muted) then ppl.muted={} end

addhook("serveraction","help_button")
addhook("join","show")
addhook('say', 'command')
addhook("minute","mtime")

admins = {70919}
moderators = {}
members = {}
vip = {64674,97024,93145}

site = "www.PBS-Servers.servehttp.com"

--------------------------------------
-- ServerAction                     --
--------------------------------------

function help_button(id,action)
	if action == 3 then
		for _, u in ipairs(admins) do
			if player(id, 'usgn') == u then
				AdminHelp(id)
			end
		end
		
		for _, u in ipairs(moderators) do
			if player(id, 'usgn') == u then
				ModeratorHelp(id)
			end
		end

		for _, u in ipairs(vip) do
			if player(id, 'usgn') == u then
				VIPHelp(id)
			end
		end
	end
end

--------------------------------------
-- Show                             --
--------------------------------------

function show(id)
	PlayerJoin(id)
	Privileges(id)
	ServerName()
	realtime()
end

function mtime(id)
	realtime()
	advertisment()
end
--------------------------------------
-- Privileges                       --
--------------------------------------

function Privileges(id)

usgn_id = player(id,"usgn")
privi = "Player"

	for _, u in ipairs(admins) do
	 if player(id,"usgn") == u then
			usgn_id = player(id,"usgn")
			privi = "Administrators"
			end
		end

	for _, u in ipairs(moderators) do
	 if player(id,"usgn") == u then
			usgn_id = player(id,"usgn")
			privi = "Moderators"
			end
		end

	for _, u in ipairs(members) do
	 if player(id,"usgn") == u then
			usgn_id = player(id,"usgn")
			privi = "Members"
			end
		end

	for _, u in ipairs(vip) do
	 if player(id,"usgn") == u then
			usgn_id = player(id,"usgn")
			privi = "V.i.p"

			end
		end
			parse('hudtxt2 '..id..' 10 "©000255000Your Usgn is: '..usgn_id..' Privilege: '..privi..'" 220 450')
	end

--------------------------------------
-- ServerName                       --
--------------------------------------

function ServerName()
	parse('hudtxt 12 "©255255255'..game("sv_name")..'" 255 20')
	parse('hudtxt 13 "©255255255'..site..'" 245 35')
end

--------------------------------------
-- Time                             --
--------------------------------------

function realtime()
txt = os.date("©000255000Time: %I:%M %p")
txt2 = os.date("©000255000Date: %A, %d %b %Y")
txt3 = "©000255000(GMT+8:00 Philippines)"
parse('hudtxt 14 "'..txt3..'" 15 110')
parse('hudtxt 15 "'..txt..'" 15 125')
parse('hudtxt 16 "'..txt2..'" 15 140')
end

--------------------------------------
-- Join                             --
--------------------------------------

function PlayerJoin(p)
	msg2(p,"©005116250Welcome To "..game("sv_name")..", "..player(p,"name").."!")
end

--------------------------------------
-- Ads                             --
--------------------------------------

function advertisment()
msg("©255100000This is "..game("sv_name").." Server")
msg("©255100000A Philippine Server Powered By: PBS Inc.")
msg("©255100000Were Proud to be Pilipino!")
msg("©255100000"..site)
end

--------------------------------------
-- CommandHook                      --
--------------------------------------

function command(id,txt)
	if txt:sub(0,1) == '!' then
		cmd=txt:sub(2)
		print('©255255255'..cmd..' executed by '..player(id,'name')..' IP: '..player(id,'ip'))

--------------------------------------
-- AdminCommands                    --
--------------------------------------

		for _, u in ipairs(admins) do
			if player(id, 'usgn') == u then
			
				if cmd:sub(0,8) == 'teleport' then
				teleport(id,cmd:sub(10,13),cmd:sub(15,18))
				return 1
				end

				if cmd:sub(0,6) == 'encage' then
					encage()
					return 1
				end

				if cmd:sub(0,8) == 'giveaway' then
					giveaway(cmd:sub(10,11),cmd:sub(13))
					return 1
				end
				
				if cmd:sub(0,5) == 'speed' then
					speed(id,cmd:sub(7))
					return 1
				end

				if cmd:sub(0,5) == 'equip' then
					equip(id,cmd:sub(7))
					return 1
				end
				
				if cmd:sub(0,8) == 'allequip' then
					allequip(id)
					return 1
				end
				
				if cmd:sub(0,5) == 'armor' then
					armor(id)
					return 1
				end
				
				if cmd:sub(0,4) == 'slap' then
					slap(cmd:sub(6))
					return 1
				end
				
				if cmd:sub(0,3) == 'ban' then
					ban(cmd:sub(5))
					return 1
				end
				
				if cmd:sub(1,4) == 'kick' then
					kick(cmd:sub(6))
					return 1
				end

				if cmd:sub(0,6) == 'hplist' then
					healthlist(id)
					return 1
				end

				if cmd:sub(0,4) == 'goto' then
					goto(id,cmd:sub(6))
					return 1
				end

				if cmd:sub(0,5) == 'bring' then
					bring(id,cmd:sub(7))
					return 1
				end

				if cmd:sub(0,7) == 'explode' then
					explode(id,cmd:sub(9))
					return 1
				end

				if cmd:sub(0,5) == 'quake' then
					quake(id,cmd:sub(7))
					return 1
				end
			end
		end
		
--------------------------------------
-- ModeratorCommands                --
--------------------------------------

		for _, u in ipairs(moderators) do
			if player(id, 'usgn') == u then
			
				if cmd:sub(0,8) == 'teleport' then
				teleport(id,cmd:sub(10,13),cmd:sub(15,18))
				return 1
				end
				
				if cmd:sub(0,5) == 'speed' then
					speed(id,cmd:sub(7))
					return 1
				end
				
				if cmd:sub(0,5) == 'equip' then
					equip(id,cmd:sub(7))
					return 1
				end
				
				if cmd:sub(1,4) == 'kick' then
					kick(cmd:sub(6))
					return 1
				end
			end
		end

--------------------------------------
-- V.I.P Commands                   --
--------------------------------------

		for _, u in ipairs(vip) do
			if player(id, 'usgn') == u then
				if cmd:sub(0,5) == 'equip' then
					equip(id,cmd:sub(7))
					return 1
				end
			end
		end
	end
	return 1
end

--------------------------------------
-- Commands                         --
--------------------------------------
function AdminHelp(id)
	msg2(id,"©255255051!giveaway [ITEM] [MSG] -- Gives free items to all players")
	msg2(id,"©255255051!hplist -- Gives you the Health List of the players AOTS")
	msg2(id,"©255255051!speed [Value] -- Gives You a Speed with Value-XX")
	msg2(id,"©255255051!allequip -- Equip all possible weapons to you")
	msg2(id,"©255255051!bringme [ID] -- Bring yourself to Player[ID]")
	msg2(id,"©255255051!quake [LENGTH] -- Make an Haiti earthquake!")
	msg2(id,"©255255051!encage -- Kill all Players inside the cage")
	msg2(id,"©255255051!bring [ID] -- Bring Player[ID] to you")
	msg2(id,"©255255051!explode [DMG] -- Spawn explosion")
	msg2(id,"©255255051!armor -- Equip a Heavy Armor")
	msg2(id,"©255255051!equip [ID] -- Equip a Weapon")
	msg2(id,"©255255051!slap [ID] -- Slap a Player")
	msg2(id,"©255255051!kick [ID] -- Kick a Player")
	msg2(id,"©255255051!ban [ID] -- Ban a Player")
end

function ModeratorHelp(id)
	msg2(id,"©255255051!teleport [X] [Y] -- Teleports You To ..x.. ..y.. On The Map")
	msg2(id,"©255255051!speed [Value] -- Gives You a Speed with Value-XX")
	msg2(id,"©255255051!equip [ID] -- Equip a Weapon")
	msg2(id,"©255255051!kick [ID] -- Kick a Player")
end

function VIPHelp(id)
	msg2(id,"©255255051!speed [Value] -- Gives You a Speed with Value-XX")
end

function teleport(id,loc1,loc2)
	parse('setpos '..id..' '..loc1..' '..loc2)
end

function speed(id,speed)
	parse('speedmod '..id..' '..speed)
end

function equip(id,wepid)
	parse('equip '..id..' '..wepid)
end
	
function allequip(id)
	weapons = {1, 2, 3, 4, 5, 6, 10, 11, 20, 21, 22, 23, 24, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 45, 46, 47, 48, 49, 51, 52, 53, 54, 69, 72, 73, 74, 75, 76, 77, 78, 83, 85, 86, 87, 88}
	for _, wepid in ipairs(weapons) do		
		parse('equip '..id..' '..wepid)
	end
end
	
function armor(id)
	parse('equip '..id..' 81')
end

function slap(id)
	if player(id,"exists") then
	parse('slap '..id)
	end
end
	
function ban(id)
	if player(id,"exists") then
	parse('banip '..player(id,'ip')..' 10')
	end
end

function kick(id)
	if player(id,"exists") then
	parse('kick '..id)
	end
end

function goto(id,target)
	parse('setpos '..id..' '..player(target,"x")..' '..player(target,"y"))
	parse('effect "colorsmoke" '..player(target,"x")..' '..player(target,"y")..' 0 0 000 255 000')
end

function bring(id,target)	
	parse('setpos '..target..' '..player(id,"x")..' '..player(id,"y"))
	parse('effect "colorsmoke" '..player(id,"x")..' '..player(id,"y")..' 0 0 000 255 000')
end

function explode(id,dmg)
	parse('explosion '..player(id,'x')..' '..player(id,'y')..' '..dmg..' '..dmg..' '..id)
end

function quake(id,length)
		if length then
			length = math.min(length*50,250)
			for _, id in ipairs(player(0,'table')) do
				parse('shake '..id..' '..length)
			end
		for i = 1, 6 do
			if math.random(0,1) == 1 then
				parse('sv_sound weapons/explode'..i..'.wav')
			end
		end
	end
end

function healthlist(id)
	for i=1,32 do
		if (player(i,"exists")) then
			hp=player(i,"health")
			if (hp>90) then
				msg2(id,"©000255000"..player(i,"name").." -> HP: "..hp)
			elseif (hp>60) then
				msg2(id,"©255255000"..player(i,"name").." -> HP: "..hp)
			elseif (hp>30) then
				msg2(id,"©255128000"..player(i,"name").." -> HP: "..hp)
			else
				msg2(id,"©255000000"..player(i,"name").." -> HP: "..hp)
			end
		end
	end
	return 2
end

function encage()
	parse("sv_msg ©255000000ENCAGING ALL PLAYERS!!!@C")
	a=player(0,"table")
	for i=1,#a do
		if (player(a[i],"team")>0) then
			if (player(a[i],"health")>0) then
				x=player(a[i],"tilex")
				y=player(a[i],"tiley")
				parse ("spawnobject 3 "..(x-1).." "..(y-1))
				parse ("spawnobject 3 "..(x).." "..(y-1))
				parse ("spawnobject 3 "..(x+1).." "..(y-1))
				parse ("spawnobject 8 "..(x-1).." "..(y))
				parse ("spawnobject 8 "..(x+1).." "..(y))
				parse ("spawnobject 3 "..(x-1).." "..(y+1))
				parse ("spawnobject 3 "..(x).." "..(y+1))
				parse ("spawnobject 3 "..(x+1).." "..(y+1))
			end
		end
	end
	return 2
end
	
function giveaway(item,msg)
	parse("sv_msg ©255000000FREE "..msg.." !!!@C")
	a=player(0,"table")
	for i=1,#a do
		if (player(a[i],"team")>0) then
			if (player(a[i],"health")>0) then
				x=player(a[i],"tilex")
				y=player(a[i],"tiley")
				parse ("spawnitem "..item.." "..(x-1).." "..(y))
			end
		end
	end
	return 2
end
edited 2×, last 25.02.13 06:13:51 pm

old Re: joinhook not working

DC
Admin Off Offline

Quote
... sure, simply say that you get an error and post a 400+ lines Lua script. That's how it is done. NOT!

Please always provide the exact Lua error you get. It probably even tells you the line so it makes finding the error quite simple.

old Re: joinhook not working

KagamineLen
User Off Offline

Quote
i found the reason of the error, then i finished it and got another but i doesnt have error just a bug so ineed help about the problem in the script then i edited the thread because i need another help

old Re: joinhook not working

ohaz
User Off Offline

Quote
Did you even read what user DC said? WE NEED THE FUCKING ERROR YOU GOT. The whole text. Not just "I got an error". That will never help us find it.

old Re: joinhook not working

KagamineLen
User Off Offline

Quote
i said i found the error and it was fixed now i edited the post with the new codes with a bug and i need help finding that bug there is no error code, the server name and previlege hud was not showing on dedicated server maybe the join hook is not working, and the chat also is not working pressing z and typing something shows nothing, i really need help

old Re: joinhook not working

Yates
Reviewer Off Offline

Quote
I can't even find the join hook. It's probably too small.

Edit: What the fuck. You are trying to give people on server start a hudtxt by checking in what table they are. Ever thought about NO PLAYERS BEING THERE ON START?

Of course the fucking hudtxt will not show. Also the function show(id) is not even triggered on start, how can the server name hudtxt be shown if it's in a stupid function that's NEVER TRIGGERED?

Fix your script yourself. It's way too obvious what your mistakes are and you are just too fucking lazy to sit and read your code instead whine about two errors while being so lazy not even giving the first error!

old Re: joinhook not working

VADemon
User Off Offline

Quote
user Yates has written
I can't even find the join hook. It's probably too small.

Edit: What the fuck. You are trying to give people on server start a hudtxt by checking in what table they are. Ever thought about NO PLAYERS BEING THERE ON START?

Of course the fucking hudtxt will not show. Also the function show(id) is not even triggered on start, how can the server name hudtxt be shown if it's in a stupid function that's NEVER TRIGGERED?

Fix your script yourself. It's way too obvious what your mistakes are and you are just too fucking lazy to sit and read your code instead whine about two errors while being so lazy not even giving the first error!


That's his implementation:
More >

It's all inside the command() function.
Pretty big though.
edited 2×, last 25.02.13 07:30:49 pm

old Re: joinhook not working

KagamineLen
User Off Offline

Quote
it has no error codes but the join hook is not working on dedicated server here's the join code, what should i do to trigger show function?

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
addhook("join","show")
addhook('say', 'command')
addhook("minute","mtime")

admins = {70919}
moderators = {}
members = {}
vip = {64674,97024,93145}

site = "www.PBS-Servers.servehttp.com"

--------------------------------------
-- ServerAction                     --
--------------------------------------

function help_button(id,action)
     if action == 3 then
          for _, u in ipairs(admins) do
               if player(id, 'usgn') == u then
                    AdminHelp(id)
               end
          end
          
          for _, u in ipairs(moderators) do
               if player(id, 'usgn') == u then
                    ModeratorHelp(id)
               end
          end

          for _, u in ipairs(vip) do
               if player(id, 'usgn') == u then
                    VIPHelp(id)
               end
          end
     end
end

--------------------------------------
-- Show                             --
--------------------------------------

function show(id)
     PlayerJoin(id)
     Privileges(id)
     ServerName()
     realtime()
end

function mtime(id)
     realtime()
     advertisment()
end

IMG:https://img845.imageshack.us/img845/2159/46687632.png
edited 4×, last 25.02.13 11:57:08 pm

old Re: joinhook not working

VADemon
User Off Offline

Quote
Here you go:
1
2
3
4
5
6
7
function show(id)
     PlayerJoin(id)
     Privileges(id)
     ServerName()
     realtime()
print("©255200200Join hook executed!")
end
ProTip: When something's not working: debug it. Debug until you find out the problem.

old Re: joinhook not working

MikuAuahDark
User Off Offline

Quote
of course it not executed while using dedicated. cs2d lua hook join is called when someone join not when dedicated start. so basically when you use the "New Game"(listen server), when you start the server, you're joining the server and triggering the join hook. Same also affect to cs2d lua hook leave when using listen server, when you disconnect the server, your client are leave the server, triggering the cs2d lua hook leave hook, and shutting the server down

old Re: joinhook not working

EngiN33R
Moderator Off Offline

Quote
If you want to trigger something when the server starts, you need to call the function from the script body. For example, consider this script:

1
2
3
4
5
6
7
8
9
10
function startfunc1()
	print("Start function 1")
end

function startfunc2()
	print("Start function 2")
end

addhook("join","startfunc1") -- add a hook to the first function
startfunc2() -- call the function from the script body

With this script in place, when you start the server you will see "Start function 2" in console. You will only see "Start function 1" when a player joins it. I hope I made it clear.

old Re: joinhook not working

KagamineLen
User Off Offline

Quote
like this i think i already done that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("join","show")

--------------------------------------
-- Show                             --
--------------------------------------

function show(id) -- function 1

     PlayerJoin(id) -- function 2
     Privileges(id) -- function 2
     ServerName() -- function 2
     realtime() -- function 2

end

old Re: joinhook not working

EngiN33R
Moderator Off Offline

Quote
That function will get called when a player joins. It will not however get called when the server starts - although I can't see why you'd need that with this function.

old Re: joinhook not working

KagamineLen
User Off Offline

Quote
so when the player joins it will search for his previlege if he is admin or vip and also time and also servername
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview