Forum

> > CS2D > Scripts > ask about objectkill
Forums overviewCS2D overview Scripts overviewLog in to reply

English ask about objectkill

2 replies
To the start Previous 1 Next To the start

old ask about objectkill

Devil-Thanh
GAME BANNED Off Offline

Quote
hey guys. i made a short script about getting exp when i killed zombie. The script run ok but i found this bug when zombies hit me

LUA ERROR: sys/lua/mainlua.lua:311: attempt to perform arithmetic on field '?' (a nil value)

how to fix this bug?
P/S: script run well with this bug

old Re: ask about objectkill

Devil-Thanh
GAME BANNED 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
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
addhook("objectkill","okill")
function okill(od,id)
	if id>0 then
	parse("killobject "..od)
	if (object(od,'typename')=='NPC') then
		if object(od,"player") == 1 then
			exp[id]= exp[id] + 5000 + (lvl[id]*500)*goti
			mo[id]=mo[id] + (20*lvl[id]) + 125
			dque[id]=dque[id]+1

			if object(od,'xtile')>=51 and object(od,'xtile')<=107 then
				local x=math.random(51,107)
				local y=math.random(2,47)
				if tile(x,y,"walkable") then
				parse("spawnnpc 1 "..x.." "..y)
				end
			else
				local x=math.random(199,255)
				local y=math.random(4,53)
				if tile(x,y,"walkable") then
				parse("spawnnpc 1 "..x.." "..y)
				end	
			end
		elseif (object(od,"player") == 2) then
			exp[id]= exp[id] + 3000 + (lvl[id]*500)*goti
			mo[id]=mo[id] + (15*lvl[id]) + 200
			local x=math.random(0,40)
			local y=math.random(97,149)
			if tile(x,y,"walkable") then
			parse("spawnnpc 2 "..x.." "..y)
			end
		elseif (object(od,"player") == 2) then
			exp[id]= exp[id] + 3000 + (lvl[id]*500)*goti
			mo[id]=mo[id] + (15*lvl[id]) + 200
			local x=math.random(0,40)
			local y=math.random(97,149)
			if tile(x,y,"walkable") then
			parse("spawnnpc 3 "..x.." "..y)
			end
		elseif object(od,"player") == 4 then
			exp[id]= exp[id] + 50000 + (lvl[id]*10000)*goti
			mo[id]=mo[id] + (500*lvl[id]) + 500000
			msg("©000255000"..player(id,"name").." killed BOSS Vortigaunt!@C")
		end
	end

	if exp[id] == asd[id] or exp[id] > asd[id] and lvl[id]<150 then
		exp[id]=exp[id]-asd[id]
		lvl[id]=lvl[id]+1
		h[id]= hi[id]
		if UsgnIds[id] > 0 then
			SaveUserStat(id)
    		end
		parse("setmaxhealth "..id.." "..h[id])
		msg2(id,"©000255000Level up!@C")
		msg("©255075000"..player(id,"name").." reached "..lvl[id].." level!")
	end

		if quest[id]==0 then quest[id]=1 end
		if dque[id]>=que[id] then
		msg2(id,"©000255000Completed Quest level "..quest[id].."!You Recive a new Quest!@C")
		msg("©000255000"..player(id,"name").." completed quest level "..quest[id].."!")
			exp[id]=exp[id]+10000*quest[id]
			mo[id]=mo[id]+5000*quest[id]
			am[id]=am[id]+quest[id]
			dme[id]=dme[id]+quest[id]
			quest[id]=quest[id]+1
			dque[id]=0
		end
	updatehud(id)
end
return 0
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview