Forum

> > CS2D > Scripts > Tibia script thread (Post tibia requests here)
Forums overviewCS2D overview Scripts overviewLog in to reply

English Tibia script thread (Post tibia requests here)

347 replies
Page
To the start Previous 1 213 14 1517 18 Next To the start

old Re: Tibia script thread (Post tibia requests here)

mattasha
User Off Offline

Quote
Ok thanks reset level NPC is nice it work's but i got another problem can you resolve please?

When a guyz level +60

Reset level For add a new itemsin his inventory and forkick him automaticly

Please help me

-Thanks

old Re: Tibia script thread (Post tibia requests here)

Crabby
User Off Offline

Quote
Hello, I got a problem. When I added this to my items.lua

Spoiler >


I got this error:

Spoiler >


Line of hooks:

Spoiler >


Could anyone please help me?
edited 2×, last 07.06.13 08:28:59 am

old Re: Tibia script thread (Post tibia requests here)

Dimas541
User Off Offline

Quote
@user Crabby: You really like this one a friend

-Using MP

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
[593] = {
          name = "Crystall Sword", 
          desc = "Crystall Sword is used for killing dangerious beasts.",
          r = 180, g = 0, b = 0,  
          action = {"equip","cast"}, 
          slot = 3, 
          eimage = "gfx/weiwen/Crabby/ArmourWeapon/Crystalline_Sword.png",
          fimage = "gfx/weiwen/Crabby/ArmourWeapon/Crystalline_Sword.png",
          offsetx = 6,
          offsety = 17,
          atk = 2.0, 
          speed = 0.25, 
          level = 30,
          func = equip,{
		function(id,itemslot,itemid,equip)
        if PLAYERS[id].MP < 20 then message(id, "You don't have enough mana",'255255255') return end
        if PLAYERS[id].Level < 30 then message(id, "You need to be level 20.","255255255") return end
               radiusmsg(player(id,"name") .. " used special attack.", player(id,"x"), player(id,"y"))
               explosion(player(id, "x"), player(id,"y"), 64, 20, id)
               local pos = player(id,"x") .. " " .. player(id,"y")
               parse("effect \"colorsmoke\" " .. pos .. " 100 96 128 128 0")
			PLAYERS[id].MP = PLAYERS[id].MP - 20
            updateHUD(id)
		end,equip},	
	},

-Using Mana

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
[593] = {
          name = "Crystall Sword", 
          desc = "Crystall Sword is used for killing dangerious beasts.",
          r = 180, g = 0, b = 0,  
          action = {"equip","cast"}, 
          slot = 3, 
          eimage = "gfx/weiwen/Crabby/ArmourWeapon/Crystalline_Sword.png",
          fimage = "gfx/weiwen/Crabby/ArmourWeapon/Crystalline_Sword.png",
          offsetx = 6,
          offsety = 17,
          atk = 2.0, 
          speed = 0.25, 
          level = 30,
          func = equip,{
		function(id,itemslot,itemid,equip)
        if PLAYERS[id].Mana < 20 then message(id, "You don't have enough mana",'255255255') return end
        if PLAYERS[id].Level < 30 then message(id, "You need to be level 20.","255255255") return end
               radiusmsg(player(id,"name") .. " used special attack.", player(id,"x"), player(id,"y"))
               explosion(player(id, "x"), player(id,"y"), 64, 20, id)
               local pos = player(id,"x") .. " " .. player(id,"y")
               parse("effect \"colorsmoke\" " .. pos .. " 100 96 128 128 0")
			PLAYERS[id].Mana = PLAYERS[id].MP - 20
            updateHUD(id)
		end,equip},	
	},

old Re: Tibia script thread (Post tibia requests here)

ubmasterr
BANNED Off Offline

Quote
@user Dimas541: false.
@user Crabby:
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
[593] = {
          name = "Crystall Sword", 
          desc = "Crystall Sword is used for killing dangerious beasts.",
          r = 180, g = 0, b = 0,  
          action = {"equip","cast"}, 
          slot = 3, 
          eimage = "gfx/weiwen/Crabby/ArmourWeapon/Crystalline_Sword.png",
          fimage = "gfx/weiwen/Crabby/ArmourWeapon/Crystalline_Sword.png",
          offsetx = 6,
          offsety = 17,
          atk = 2.0, 
          speed = 0.25, 
          level = 30,
          func = {equip, 
               function(id, itemslot, itemid, equip)
               if PLAYERS[id].Mana >= 20 then
               radiusmsg(player(id,"name") .. " used special attack.", player(id,"x"), player(id,"y"))
               explosion(player(id, "x"), player(id,"y"), 64, 20, id)
               local pos = player(id,"x") .. " " .. player(id,"y")
               parse("effect \"colorsmoke\" " .. pos .. " 100 96 128 128 0")
          else
               message(id, "You don't have enough mana")
                  updateHUD(id)
                  end
          end},
     },

EDİT:

hey KenVo, i need your skill system (skill menu, lvl up skill point and hotkey menu.)
you put at your thread.
edited 1×, last 09.09.13 10:06:26 am

old Re: Tibia script thread (Post tibia requests here)

Dready
User Off Offline

Quote
@user lenovo: Here u go

Attack, Def, Speed

1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("ms100","atk") 
function atk()
for id = 1,32 do
if player(id,"exists") and PLAYERS[id] then
parse('hudtxt2 '..id..' 11 "©255255000 '..PLAYERS[id].tmp.atk..' " 470 437 1')
parse('hudtxt2 '..id..' 12 "©255255000 '..PLAYERS[id].tmp.def..' " 470 425 1')
parse('hudtxt2 '..id..' 13 "©255255000 '..PLAYERS[id].tmp.spd..' " 470 410 1')
parse('hudtxt2 '..id..' 14 "©255255255 Atack " 420 437 1')
parse('hudtxt2 '..id..' 15 "©255255255 Defence " 420 425 1')
parse('hudtxt2 '..id..' 16 "©255255255 Speed " 420 410 1')
end
end 
end


Monster.lua

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
function Monster:damage(id, dmg, wpntype)
     if not PLAYERS[id].Tutorial.damagem then
          message(id, "You have attacked a monster! Good job! Keep on attacking it until it dies.", "255128000")
          PLAYERS[id].Tutorial.damagem = true
     end
     local wpnName
     if wpntype == 251 then
          wpnName = 'rune'
     elseif wpntype == 46 then
          wpnName = 'firewave'
          dmg = dmg/5
     else
          wpnName = PLAYERS[id].Equipment[3] and ITEMS[PLAYERS[id].Equipment[3]].name or 'dagger'
     end
     self.health = self.health - dmg
     hudtxt2(id,41, 'Dealt '..dmg..' damage, '..self.health..' health left.', '255255255', 200,250,0)
     print(player(id, 'name') .. ' deals ' .. dmg .. ' damage to ' .. self.name .. ' usng a ' .. wpnName .. '.')
     if self.health <= 0 then
          if not PLAYERS[id].Tutorial.killm then
               message(id, "Congratulation! You have killed your first monster. You can proceed to pick up the loot by using the drop weapon button (default G)", "255128000")
               PLAYERS[id].Tutorial.killm = true
          end
          addexp(id, math.floor(self.exp*CONFIG.EXPRATE))
          self:die()
     else
          parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 0 ' .. self.scaley .. ' ' .. (self.r and (self.r .. ' ' .. self.g .. ' ' .. self.b) or '192 0 0'))
     end
     radiussound("weapons/machete_hit.wav", self.x, self.y)
     return true
end

old Re: Tibia script thread (Post tibia requests here)

TrialAndError
User Off Offline

Quote
@user Nixo: If you did everything correct it should look like this:

admin.lua:

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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
function adminCommands(id,words)
	if isAdmin(id) and words:sub(1,1) =='!' then
		local command = words:lower():sub(2,2)
		if words:sub(3,3) ~= ' ' and #words ~= 2 then return end
		print(player(id,'name')..' used a command:'..words)
		if command =='a' then
			local distance = tonumber(words:sub(4))
			if distance then
				local rot = math.rad(player(id,'rot')-180)
				local x, y = -math.sin(rot)*distance*32, math.cos(rot)*distance*32
				parse('setpos '..id..' '..player(id,'x')+x..' '..player(id,'y')+y)
			else
				msg2(id,'Teleport forward: "!a <distance>"')
			end
			return 1
		elseif command =='b' then
			msg('©255100100'..player(id,'name')..' : '..words:sub(4)..'@C')
			return 1
		elseif command =='c' then
			local target = tonumber(words:sub(4))
			if target then
				if player(target,'exists') then
					if target == id then
						msg2(id,'You may not teleport to yourself!')
					end
					parse('setpos '..target..' '..player(id,'x')..' '..player(id,'y'))
					return 1
				end
			end
			msg2(id,'Teleport player to you: "!c <targetid>"')
			return 1
		elseif command =='d' then
			msg('©255100100'..words:sub(4)..'@C')
			return 1
		elseif command =='e' then
			local dmg = tonumber(words:sub(4))
			if dmg then
				parse('explosion '..player(id,'x')..' '..player(id,'y')..' '..dmg..' '..dmg..' '..id)
				return 1
			end
			msg2(id,'Spawn explosion: "!e <dmg>"')
			return 1
		elseif command =='i' then
			local itemid = tonumber(words:sub(4))
			if itemid then
				additem(id,itemid)
				return 1
			end
			msg2(id,'Spawn item: "!i <itemid>"')
			return 1
		elseif command =='h' then
			local s = words:find(' ',4)
			local target = tonumber(words:sub(4,s))
			if target then
				if player(target,'exists') then
					local heal = s and tonumber(words:sub(s+1,words:find(' ',s+1))) or nil
					if heal then
						parse('explosion '..player(target,'x')..' '..player(target,'y')..' 1 '..(-heal))
						return 1
					end
				end
			end
			msg2(id,'Heal player: "!h <targetid> <amount>"')
			return 1
		elseif command =='l' then
			local script = words:sub(4)
			if script then
				msg2(id,tostring(assert(loadstring(script))() or 'done!'))
				return
			end
			msg2(id,'Run lua script: "!l <script>"')
			return 1
		elseif command =='m' then
			if gettile(player(id, 'tilex'), player(id, 'tiley')).SAFE then
				msg2(id,'You may not spawn a mosnter in a safe zone.')
				return 1
			end
			local name = words:sub(4)
			if name then
				for i, v in pairs(CONFIG.MONSTERS) do
					if v.name:lower() == name:lower() then
						local m = deepcopy(v)
						m.x, m.y = player(id, 'x'), player(id, 'y')
						Monster:new(m)
						msg2(id,'Monster ' .. name .. ' spawned.')
						return 1
					end
				end
			end
			msg2(id,'Monster ' .. name .. ' does not exist.')
			return 1
		elseif command =='n' then
			msg2(id,'{'..player(id,'tilex')*32+16 ..', '..player(id,'tiley')*32+16 ..'}')
			return 1
		elseif command =='o' then
			msg2(id,'{'..player(id,'tilex')..', '..player(id,'tiley')..'}')
			return 1
		elseif command =='p' then
			msg2(id,'{'..player(id,'x')..', '..player(id,'y')..'}')
			return 1
		elseif command =='q' then
			local length = tonumber(words:sub(3))
			if length then
				length = math.min(length*50,250)
				for _, id in ipairs(player(0,'table')) do
					parse('shake '..id..' '..length)
				end
				for i = 1, 6 do
					if math.random(0,1) == 1 then
						parse('sv_sound weapons/explode'..i..'.wav')
					end
				end
			else
				msg2(id,'Earthquake: "!q <length in seconds, max 5>"')
			end
			return 1
		elseif command =='s' then
			local s = words:find(' ',4)
			local target = tonumber(words:sub(4,s))
			if target then
				if player(target,'exists') then
					local speed = s and tonumber(words:sub(s+1,words:find(' ',s+1))) or nil
					if speed then
						parse('speedmod '..target..' '..speed)
						return 1
					end
				end
			end
			msg2(id,'Speed modifier: "!s <targetid> <speedmod, between -100 and 100>"')
			return 1
		elseif command =='t' then
			local target = tonumber(words:sub(3))
			if target then
				if player(target,'exists') then
					if target == id then
						msg2(id,'You may not teleport to yourself!')
					end
					parse('setpos '..id..' '..player(target,'x')..' '..player(target,'y'))
					return 1
				end
			end
			msg2(id,'Teleport to player: "!t <targetid>"')
			return 1
		elseif command =='u' then
			local delay = tonumber(words:sub(3)) or 0
			shutdown(delay*1000)
			return 1
		elseif command =='v' then
			saveserver()
			msg2(id,'Saved server!')
			return 1
			elseif command =='g' then
     if PLAYERS[id].tmp.god ~= 1 then
          PLAYERS[id].tmp.god = 1
          msg2(id,'God mode on')
     else
          PLAYERS[id].tmp.god = 0
          msg2(id,'God mode off')
     end
     return 1
		end
	end
end

hooks.lua

1
PLAYERS[id].tmp = {hp = 100, atk = 1, def = 1, spd = 0, god = 0, usgn = player(id, "usgn"), equip = {}, exhaust = {}}

and

1
2
3
4
5
6
7
8
addhook("hit","EXPhit")
function EXPhit(id,source,weapon,hpdmg,apdmg)
if PLAYERS[id].tmp.god == 1 then return 1 end
	local HP, dmg, wpnName, name = player(id, "health")
	if hpdmg <= 0 or source == 0 then
		PLAYERS[id].HP = HP-hpdmg
		return
	end

Monsters.lua

1
2
3
4
5
6
function Monster:hit(id, dmg)
if PLAYERS[id].tmp.god == 1 then return end
	if not PLAYERS[id].Tutorial.hitm then
		message(id, "A monster is attacking you! You can fight back by swinging your weapon at it.", "255128000")
		PLAYERS[id].Tutorial.hitm = true
	end

old Re: Tibia script thread (Post tibia requests here)

TrialAndError
User Off Offline

Quote
Config.lua

1
2
--minutes delay until dropped items are automatically remove from the map (except items in houses)
     CLEANITEMSDELAY= 5,

Functions.lua

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
function cleanitems()
     for k,v in pairs (GROUNDITEMS) do
          local x,y,height
          for a,b in pairs (v) do
               for c,d in pairs (b) do
                    d[4] = d[4] -1
                    y=k
                    x=a
                    height=c
                    if d[4] <= 0 and not TILEZONE[y][x].HOUSE then
                         local item = d
                         if item[1] == 1337 then
                              if item[2] then freeimage(item[2]) end
                              GROUNDITEMS[y][x][height] = nil
                         else
							local tile = GROUNDITEMS[y][x]
                              if tile.HEAL and ITEMS[item[1]].heal then
                                   tile.HEAL = tile.HEAL - ITEMS[item[1]].heal
                                   if tile.HEAL == 0 then
                                        tile.HEAL = nil
                                   end
                              end
                              if item[2] then freeimage(item[2]) end
                              GROUNDITEMS[y][x][height] = nil
                         end
                    end
               end
          end
     end  
end

Under function updateTileItems(x,y), find local heightoffset. Add this code under it:

1
2
local heightoffset = (height < MAXHEIGHT and height or MAXHEIGHT)*3
          item[4] = CONFIG.CLEANITEMSDELAY --this code

hooks.lua

1
2
3
4
5
6
7
8
addhook("minute","EXPminute")
function EXPminute()
     cleanitems()
     MINUTES = MINUTES+1
     if game'sv_password' == '' and MINUTES%5 == 0 then
          saveserver()
     end
end

This should work, because it works for me.

old Re: Tibia script thread (Post tibia requests here)

X-Files
User Off Offline

Quote
man its worked after i change the function name
EXPminute was matching with another hook thats why its didnt work before
1
2
3
4
5
6
7
8
addhook("minute","EXPminute2")
function EXPminute2()
     cleanitems()
     MINUTES = MINUTES+1
     if game'sv_password' == '' and MINUTES%5 == 0 then
          saveserver()
     end
end
To the start Previous 1 213 14 1517 18 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview