Forum

> > CS2D > Scripts > Kick if file is modified
Forums overviewCS2D overview Scripts overviewLog in to reply

English Kick if file is modified

3 replies
To the start Previous 1 Next To the start

old Kick if file is modified

mrc
User Off Offline

Quote
I want a script that kicks the player if he has modified hitsounds. I've tryied this but this doesn't work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("clientdata", "checkfile")
function checkfile(id, mode, data1, data2)
   if (mode == 4) then
      if (checksumfile("sfx/player/hit1.wav") ~= data2) then
         parse('kick '..id..' "Você está usando um arquivo modificado!"')
      elseif (checksumfile("sfx/player/hit2.wav") ~= data2) then
         parse('kick '..id..' "Você está usando um arquivo modificado!"')
      elseif (checksumfile("sfx/player/hit3.wav") ~= data2) then
         parse('kick '..id..' "Você está usando um arquivo modificado!"')
      end
   end
end

addhook("join", "reqcheck")
function reqcheck(id)
   reqcld(id, 4, "sfx/player/hit1.wav")
   reqcld(id, 4, "sfx/player/hit2.wav")
   reqcld(id, 4, "sfx/player/hit3.wav")
end

old Re: Kick if file is modified

jerezinho
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
hitsounds = {}
hashes = {}

hashes["1ff855e59dc1d55fbdd899b3734bf65747078f41738b7ebdb1e6fdda54298e6b"] = "sfx/player/hit1.wav"
hashes["bb2b7393b580220df80966a5d4ed89c1f4eaa7e0d4690f27221e9dc021c4d9f2"] = "sfx/player/hit2.wav"
hashes["ebabd453fd91ef46f4067720bedf2ff51140e1d0f9f5cafd29c530c29bfddd4a"] = "sfx/player/hit3.wav"

addhook("team","hitsounds.team")
function hitsounds.team(id,team)
	if player(id,"team") == 0 then
		for _,path in pairs(hashes) do
			reqcld(id,4,path)
		end
	end
end

addhook("clientdata","hitsounds.clientdata")
function hitsounds.clientdata(id,mode,data1,data2)
	if mode == 4 and not hashes[data2] then
		parse("kick "..id.." \"Você está usando um arquivo modificado!\"")
	end
end

old Re: Kick if file is modified

Vehk
User Off Offline

Quote
You need to use a program to calculate the hash.

On Windows you can use powershell. Open the directory containing the file in Explorer, in the Explorer menu go to File > Open Powershell. Then type
sha256sum.exe filename
. Obviously, you need to replace filename with the actual name of the file.

You don't need to do that if you're checking against your server's files.

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
hitsounds = {}
-- files to verify
local verifyfiles = {"sfx/player/hit1.wav", "sfx/player/hit2.wav", "sfx/player/hit3.wav"}

-- automatically get sums from server files
for _, path in ipairs(verifyfiles) do
	local sum = checksumfile(path)
	verifyfiles[sum] = true
end

addhook("team","hitsounds.team")
function hitsounds.team(id,team)
     if player(id,"team") == 0 then
          for _,path in ipairs(verifyfiles) do
               reqcld(id,4,path)
          end
     end
end

addhook("clientdata","hitsounds.clientdata")
function hitsounds.clientdata(id,mode,data1,data2)
     if mode == 4 and not verifyfiles[data2] then
          parse("kick "..id.." \"Você está usando um arquivo modificado!\"")
     end
end

Edit: user mrc was asking how to get a checksum, but edited his post.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview