Forum

> > CS2D > Scripts > Script crashing cs2d
Forums overviewCS2D overview Scripts overviewLog in to reply

English Script crashing cs2d

8 replies
To the start Previous 1 Next To the start

old Script crashing cs2d

Suprise
BANNED Off Offline

Quote
So This script crash my cs2d:

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
function prefix(n)
     local x = tonumber(string.len(n))
     if string.sub(map("name"),1,x) == n then
          return true
     end
     return false
end

if prefix("zm_") then
	parse("mp_autoteambalance 0")
	parse("mp_turretdamage 5")
	parse("mp_infammo 1")
end

addhook("spawn","spawnitem")
function spawnitem(id)
if prefix("zm_") then
if player(id,"team") == 1 then
	parse("equip "..id.." 74")
elseif player(id,"team") == 2 then
	parse("equip "..id.." 74")
end
end
end

addhook("kill","gre")
function gre(id)
if prefix("zm_") then
if player(id,"team") == 1 then
parse("equip "..id.." 72")
end
end
end

addhook("startround","start")
function start()
	if prefix("zm_") then
		parse("bot_remove_all")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("bot_add_t")
		parse("sv_gm 4")
		parse("mp_autoteambalance 0")
		parse("mp_turretdamage 5")
		parse("mp_infammo 1")
		msg("BOT VS. PLAYER Enabled!@C")
	end
end

Any idea what's the problem? Or better fix this :3

old Re: Script crashing cs2d

EngiN33R
Moderator Off Offline

Quote
I'm not sure why it crashes your CS2D, but here's an optimized version of the code.

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
function prefix(n)
	local x = tonumber(string.len(n))
	if string.sub(map("name"),1,x) == n then
		return true
	end
	return false
end

if prefix("zm_") then
	parse("mp_autoteambalance 0")
	parse("mp_turretdamage 5")
	parse("mp_infammo 1")
end

addhook("spawn","spawnitem")
function spawnitem(id)
	if prefix("zm_") then
		return 74 --Did not understand why there were two if clauses for both teams, both containing the same line, also changed to return since that is better
	end
end

addhook("kill","gre")
function gre(id)
	if prefix("zm_") then
		if player(id,"team") == 1 then
			parse("equip "..id.." 72")
		end
	end
end

addhook("startround","start")
function start()
	if prefix("zm_") then
		parse("bot_remove_all")
		for i=1,15 do
			parse("bot_add_t")
		end
		parse("sv_gm 4")
		parse("mp_autoteambalance 0")
		parse("mp_turretdamage 5")
		parse("mp_infammo 1")
		msg("BOT VS. PLAYER Enabled!@C")
	end
end

Also, on line 26, why do you give a dead man an item?

old Re: Script crashing cs2d

EngiN33R
Moderator Off Offline

Quote
Your whole thread has no point then. Unless you can pinpoint the part that crashes your script - if it is yours then I doubt that, since you wrote 15 same lines instead of using a for loop (no offence) - I cannot do anything. And I most certainly do not want to read up to 2000 lines of code to find something that crashes the game. You might look for ways of optimization though, such as using loops and avoiding unneeded conditional clauses - might be there.

old Re: Script crashing cs2d

DC
Admin Off Offline

Quote
Is it possible that you're still using the version with that annoying Lua bug?
Re-download CS2D so you get the version that doesn't crash when a Lua error occurs. Just replace your exe file with the exe from the zip download version at www.cs2d.com/download

old Re: Script crashing cs2d

Suprise
BANNED Off Offline

Quote
@user DC: Maybe bcuz i don't download since it has been relased first time. btw the script no has error. No console error i mean.

old Re: Script crashing cs2d

DC
Admin Off Offline

Quote
Then do what I just told you. There was a bug when the latest version has been released. The game crashes ALWAYS when there is a Lua bug instead of simply displaying the bug.

I fixed that bug without increasing the version number.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview