▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
CS2D specification map format hat geschrieben
STRING = string, 8 bit per character, ended with a linebreak
Strings in CS2D map file ended with a linebreak and I guess its byte is 13 or carriage return. Used code below solved the problem by ignoring the last character which is the linebreak.
1
2
3
4
5
2
3
4
5
function readstring(file) 	local string = file:read("*l") 	 	return string:sub(1, #string - 1) end
I want you to try code below. Write "test <map>" in console if you want to test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
addhook("parse", "parsehook") function parsehook(command) 	if (command:sub(1, 4) == "test") then 		local file = io.open("maps/" .. command:sub(6, #command) .. ".map", "rb") 		local header = file:read("*l") 		 		print("Header = \"" .. header .. "\"") 		print("String = \"Unreal Software's Counter-Strike 2D Map File (max)\"") 		 		if (header == "Unreal Software's Counter-Strike 2D Map File (max)") then 			print("It works!") 		else 			print("What's wrong?") 		end 		 		return 2 	end end
1× editiert, zuletzt 29.04.15 17:08:58