Forum

> > Trash > The Rank Join Script Show [SCR]
Forums overviewTrash overviewLog in to reply

English The Rank Join Script Show [SCR]

3 replies
To the start Previous 1 Next To the start

Poll Poll

Are this script good ?

Only registered users are allowed to vote
Medium
8.33% (1)
Good
8.33% (1)
Very Good
16.67% (2)
Bad
0.00% (0)
Very Bad
66.67% (8)
12 votes cast

closed moved Poll The Rank Join Script Show [SCR]

Slooper 1
BANNED Off Offline

Quote
There codes ! :
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
addhook("join", "examples_lua__join")
function examples_lua__join(id)
	local countryname = geoip_lookup(player(id, "ip"))
	local rank = rank_get(player(id, "usgn"), 30)
	if rank > 30 then
		msg(string.format("%s joins from %s", player(id, "name"), countryname))
	else
		msg(string.format("©165255127| Rank: %d |  %s joins from %s", rank, player(id, "name"), countryname))
	end
	if rank == 1 then 
		msg(string.format("©165255127| Rank: %d |  %s joins from %s@C", rank, player(id, "name"), countryname))
	end
	
end

so vote in poll



CS2D_ROOT = "./"


function errortoconsole(str)
	print("ERROR: " .. str)
end

function splitline(str, sep)
	local a = {}
	local function f(s) table.insert(a, s) return "" end
	f((str:gsub("(.-)" .. sep, f)))
	return a
end

function _tonumber(val)
	local ret = tonumber(val)
	if ret == nil then ret = 0 end
	return ret
end

function player_safe(id, param)
	local ret = player(id, param)
	return ret ~= false and ret or 0
end



local _timer_funcs = {}
local _timer_args = {}
local _timer_idcounter = 0

function settimeout(ms, func, arg)
	_timer_idcounter = _timer_idcounter + 1
	
	timerid = tostring(_timer_idcounter)
	_timer_funcs[timerid] = func
	_timer_args[timerid] = arg
	
	timer(ms, "_timer_ontimer", timerid)
end

function _timer_ontimer(timerid)
	_timer_funcs[timerid](_timer_args[timerid])
	_timer_funcs[_timer_idcounter] = nil
	_timer_args[_timer_idcounter] = nil
end



local _consolecommands = {}

function cmd(name, func)
	_consolecommands[name] = func
end

function execcmd(name, args)
	_consolecommands[name](args)
end

addhook("parse","utils_lua__parse")
function utils_lua__parse(str)
	local ret = 0

	local cmds = splitline(str, ";")
	for _,cmd in pairs(cmds) do
		local cmdname = cmd:match("%s*([_%w]+)")
		if _consolecommands[cmdname] ~= nil then
			local args = splitline(cmd, "%s+")
			table.remove(args, 1)
			_consolecommands[cmdname](args) 
			ret = 1
		end
	end
	
	return ret
end


function createimage(filename, x, y, mode, scale, blend, rot, alpha)
		local im = image(filename, x, y, mode)
		
		if alpha ~= nil then imagealpha(im, alpha) end
		if blend ~= nil then imageblend(im, blend) end
		if scale ~= nil then imagescale(im, scale, scale) end
		if rot ~= nil then imagepos(im, x, y, rot) end
		
		return im
end


if GEOIP_LUA ~= nil then return end
GEOIP_LUA = 1

local geoip_ranges = {}

function geoip_lookup(ipstr)
	if geoip_ranges == nil then return "<ERROR>", "<ERROR>" end
	
	local a,b,c,d = ipstr:match("^(%d+)%.(%d+)%.(%d+)%.(%d+)$")
	local ip = a*16777216 + b*65536 + c*256 + d
	
	local s = 1
	local e = #geoip_ranges
	local i = 0
	while s <= e do
		i = math.floor((s+e)/2)
		local range = geoip_ranges[i]
		if range[1] <= ip and range[2] >= ip then
			return range[4], range[3]
		elseif range[1] > ip then
			e = i - 1
		else
			s = i + 1
		end
	end
	return "<UNKNOWN>", "<UNKNOWN>"
end

function geoip_loaddb()
	local f = io.open("geoipdb", "r")
	if f == nil then
		if _geoip_csv2lua() then 
			f = io.open("geoipdb", "r") 
		else
			return
		end
	end
	
	print("started loading geoip database")
	local tm = os.clock()
	
	local f1, f2, f3, f4
	for line in io.input(f):lines() do
		f1, f2, f3, f4 = line:match("(.-)|(.-)|(.-)|(.-)$")
		table.insert(geoip_ranges, {tonumber(f1), tonumber(f2), f3, f4})
	end
	
	print("geoip database loaded in " .. os.clock() - tm .. " seconds")
	
	f:close()
end

function _geoip_csv2lua()
	local f = io.open("sys/lua/GeoIPCountryWhois.csv", "r")
	if f == nil then
		print("\r")
		print("GeoIPCountryWhois.csv not found")
		print("Download GeoLite Country database from www.maxmind.com")
		print("http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip")
		print("\r")
		return false
	end
	
	print("generating geoipdb file...")
	io.output("geoipdb")
	local tm = os.clock()
	for line in io.input(f):lines() do
		loadstring("geoip_ln={" .. line .. "}")()
		io.write(geoip_ln[3] .. "|" .. geoip_ln[4] .. "|".. geoip_ln[5]:upper() .. "|" .. geoip_ln[6]:upper() .. "\n")
	end
	print("geoipdb generated in " .. os.clock() - tm .. " seconds")
	io.close()
	f:close()
	
	return true
end

geoip_loaddb()


if POWERS_LUA ~= nil then return end
POWERS_LUA = 1

POWER_INVINCIBILITY = 1
POWER_ONESHOTKILL = 2
POWER_FORCEFIELD = 3
POWER_SPEED = 4
POWER_MONEY = 5

local power_enabled = false
local power_flags = {}
local power_forcefieldimgs = {}


function power_enable(enable)
	if enable ~= nil then
		if enable then
			addhook("hit", "powers_lua__hit")
			addhook("join", "powers_lua__join")
			addhook("spawn", "powers_lua__spawn")
			addhook("objectdamage", "powers_lua__objectdamage")
			for _,id in ipairs(player(0,"table")) do
				power_flags[id] = {}
			end
		else
			freehook("hit", "powers_lua__hit")
			freehook("join", "powers_lua__join")
			freehook("spawn", "powers_lua__spawn")
			freehook("objectdamage", "powers_lua__objectdamage")
			for id in pairs(power_forcefieldimgs) do
				power_destroyforcefield(id)
			end
		end
		power_enabled = enable
	end
	
	return power_enabled
end

function power_set(id, power, enable)
	power_flags[id][power] = enable
	
	if power == POWER_FORCEFIELD then
		if enable then
			power_createforcefield(id)
			power_forcefieldlooppl(id)
			power_forcefieldloopbld(id)
		else
			power_destroyforcefield(id)
		end
	elseif power == POWER_SPEED then
		parse("speedmod " .. id .. " " .. (enable and 200 or 0))
	elseif power == POWER_MONEY then
		power_moneyloop(id)
	end
end

function power_get(id, power)
	return power_enabled and not player(id, "bot") and player(id, "exists") and power_flags[id][power] == true
end



function powers_lua__join(id)
	power_flags[id] = {}
	settimeout(200, 
		function()
			power_destroyforcefield(id)
		end
	)
end

function powers_lua__hit(id,source,weapon,hpdmg,apdmg)
	if power_get(id, POWER_INVINCIBILITY) then
		return 1
	end
	
	if power_get(source, POWER_ONESHOTKILL) then
		if game("sv_friedlyfire") == 1 or player(source, "team") ~= player(id, "team") then
			parse(string.format('customkill %d %s %d', source, itemtype(player(source, "weapon"), "name"), id))
			return 1
		end
	end
end

function powers_lua__spawn(id)
	if power_get(id, POWER_SPEED) then 
		parse("speedmod " .. id .. " 200")
	end
	if power_get(id, POWER_FORCEFIELD) then 
		settimeout(50, 
			function()
				power_createforcefield(id)
			end
		)
	end
	
end

function powers_lua__objectdamage(id,damage,player)
	if power_get(player, POWER_ONESHOTKILL) then
		parse(string.format("explosion %d %d 2 200000", object(id, "x")+16, object(id, "y")+16))
	end
end

function power_createforcefield(id)
	power_destroyforcefield(id)
	power_forcefieldimgs[id] = createimage("gfx/sprites/flare3.bmp", 1, 0, 100+id, nil, 1, 0, 0.9)
end

function power_destroyforcefield(id)
	if power_forcefieldimgs[id] == nil then return end
	
	freeimage(power_forcefieldimgs[id])
	power_forcefieldimgs[id] = nil
end

function power_moneyloop(id)
	if not power_get(id, POWER_MONEY) then return end
	
	if player(id, "money") < 16000 then
		parse("setmoney " .. id .. " 16000")
	end
	settimeout(1000, power_moneyloop, id)
end

function power_forcefieldlooppl(id)
	if not power_get(id, POWER_FORCEFIELD) then return end

	if player(id, "health") > 0 then
		local cx = player(id, "x")
		local cy = player(id, "y")
		for _,v in ipairs(player(0,"table")) do
			if math.pow(cx - player(v, "x"), 2) + math.pow(cy - player(v, "y"), 2) < 5000 then
				if player(v, "health") > 0 then
					if v ~= id then parse("killplayer " .. v) end
				end
			end
		end
	end
	settimeout(300, power_forcefieldlooppl, id)
end

function power_forcefieldloopbld(id)
	if not power_get(id, POWER_FORCEFIELD) then return end

	if player(id, "health") > 0 then
		local cx = player(id, "tilex")
		local cy = player(id, "tiley")
		for _,v in ipairs(object(0,"table")) do
			if math.pow(cx - object(v, "tilex"), 2) + math.pow(cy - object(v, "tiley"), 2) < 6 then
				parse(string.format('effect "colorsmoke" %d %d 1 30 255 255 255', object(v, "x")+15, object(v, "y")+15))
				parse("killobject " .. v)
			end
		end
	end
	settimeout(500, power_forcefieldloopbld, id)
end

cmd("powerenable",
	function(args)
		if #args == 1 then
			power_enable(args[1] == "1")
		end
		print(power_enable() and "enabled" or "disabled")
	end
)

cmd("powerset",
	function(args)
		if not power_enable() then 
			errortoconsole("enable first")
			return
		end
		if #args ~= 3 then
			errortoconsole("args")
			return
		end
		
		power_set(_tonumber(args[1]), _tonumber(args[2]), args[3] == "1")
	end
)


freehook("hit", "powers_lua__hit")
freehook("join", "powers_lua__join")
freehook("spawn", "powers_lua__spawn")
freehook("objectdamage", "powers_lua__objectdamage")



if RANK_LUA ~= nil then return end
RANK_LUA = 1

local INTERVAL = 60
local rank_players = {}
local rank_nextrefresh = 0
local rank_refreshedrows = 0

function rank_get(usgn, maxrows)
	if maxrows == nil then maxrows = math.huge end
	if os.clock() > rank_nextrefresh or maxrows > rank_refreshedrows then rank_refreshtable(maxrows) end
	local stats = rank_players[usgn]
	return stats ~= nil and rank_players[usgn][1] or math.huge
end

function rank_refreshtable(maxrows)
	local buff
	
	rank_players = {}
	
	local f = io.open(CS2D_ROOT .. "sys/stats/userstats.dat", "rb")
	if f == nil then return end
	
	f:read("*l")
	for i = 1, maxrows do
		local stats = {}
		
		stats[1] = i
		
		buff = f:read("*l")
		if buff == nil then break end
		stats[2] = buff
		
		buff = f:read(20)
		if buff == nil then break end
		for i = 1, 20, 4 do
			table.insert(stats, binstr2num(string.sub(buff, i, i+4)))
		end
		rank_players[stats[3]] = stats
		rank_refreshedrows = i
	end
	
	f:close()
	
	rank_nextrefresh = os.time() + INTERVAL
	if maxrows == math.huge then rank_refreshedrows = math.huge end
end


function binstr2num(str)
	local b1, b2, b3, b4 = string.byte(str, 1, 4)
	return b4 * 0x100000 + b3 * 0x10000 + b2 * 0x100 + b1
end


rank_refreshtable(math.huge)


so vote in poll

Admin/mod comment

Rules §2.1 - No needless and/or doubled posts (spam) Use the File Archive next time and please don't make pointless polls. /Starkkz
To the start Previous 1 Next To the start
Log in to replyTrash overviewForums overview