Debian Codegraph @

lua/antihack/starcraft.lua

raw symbols SCIP
1 --[[
2 Simple Anti MapHack for Starcraft: BroodWar 1.16.1
3
4
5 Copyright (C) 2014 HarpyWar ([email protected])
6
7 This file is a part of the PvPGN Project http://pvpgn.pro
8 Licensed under the same terms as Lua itself.
9 ]]--
10
11
12 -- just unique request id for maphack
13 ah_mh_request_id = 99
14 -- map visible offset
15 ah_mh_offset = 0x0047FD12
16 -- map visible normal value (without maphack)
17 ah_mh_value = 139
18
19
20 function ah_init()
21 timer_add("ah_timer", config.ah_interval, ah_timer_tick)
22 INFO("Starcraft Antihack activated")
23 end
24
25 -- send memory check request to all players in games
26 function ah_timer_tick(options)
27 -- iterate all games
28 for i,game in pairs(api.server_get_games()) do
29 -- check only Starcraft: BroodWar
30 if game.clienttag and (game.clienttag == CLIENTTAG_BROODWARS) then
31 -- check only games where count of players > 1
32 if game.players and (substr_count(game.players, ",") > -1) then
33 --DEBUG(game.players)
34 -- check every player in the game
35 for username in string.split(game.players,",") do
36 api.client_readmemory(username, ah_mh_request_id, ah_mh_offset, 2)
37 -- HINT: place here more readmemory requests
38
39 end
40 end
41 end
42 end
43 end
44
45 -- handle response from the client
46 function ah_handle_client(account, request_id, data)
47 local is_cheater = false
48
49 -- maphack
50 if (request_id == ah_mh_request_id) then
51 -- read value from the memory
52 local value = bytes_to_int(data, 0, 2)
53 --TRACE(account.name .. " memory value: " .. value)
54
55 if not (value == ah_mh_value) then
56 is_cheater = true
57 end
58
59 -- process another hack check
60 --elseif (request_id == ...) then
61
62 end
63
64
65 if (is_cheater) then
66 -- lock cheater account
67 account_set_auth_lock(account.name, true)
68 account_set_auth_lockreason(account.name, "we do not like cheaters")
69
70 -- notify all players in the game about cheater
71 local game = api.game_get_by_id(account.game_id)
72 if game then
73 for username in string.split(game.players,",") do
74 api.message_send_text(username, message_type_error, nil, account.name .. " was banned by the antihack system.")
75 end
76 end
77
78 -- kick cheater
79 api.client_kill(account.name)
80
81 INFO(account.name .. " was banned by the antihack system.")
82 end
83 end