Forum

> > CS2D > Scripts > Tibia Button seller
Forums overviewCS2D overview Scripts overviewLog in to reply

English Tibia Button seller

5 replies
To the start Previous 1 Next To the start

old Tibia Button seller

Me Gusta
User Off Offline

Quote
I like to create a button if the tibia that sells anything and iten progress has already made ​​way to improve?

1
2
3
4
5
6
7
8
9
addhook('usebutton', 'AA_button')
function AA_button(id)
     if player(id, 'tilex') == 40 and player(id, 'tiley') == 34 then
	 PLAYERS[id].Level >= 100
          menu(id, 'title,medikit=-25exp')
		  additem(id,1)
		  addexp(id,-25)
     end
end

old Re: Tibia Button seller

RedizGaming
GAME BANNED Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
PLAYERS = {}
         Level = 0

addhook("usebutton","a")
function a(id,x,y)
if player(id, 'x') == 40 and player(id, 'y') ?? 34 then
       PLAYERS[id].Level==100
		menu(id,"Title,Medikit|25 Exp")
		additem(id,1)
		addexp(id,-25)
	end
end

Spoiler >

old Re: Tibia Button seller

Jhony
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
PLAYERS = {}
         Level = 0

addhook("usebutton","a")
function a(id,x,y)
if player(id, 'tilex') == 40 and player(id, 'tiley') == 34 then
       PLAYERS[id].Level==100
          menu(id,"Title,Medikit|25 Exp")
          additem(id,1)
          addexp(id,-25)
     end
end

old pet follow player

Me Gusta
User Off Offline

Quote
look here already have the gnchos but how to convert for use in the tibia?

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
config = {
	startdmg = 10,		--This is the first dmg of Pet
	startaccuracy = 3,		--This is the first accuracy point of pet (it >0) 
	updmgcost = 5000,		--Up Pet's dmg price
	addeddmg = 10,		--This dmg will be added to Pet's dmg in one up
	upaccuracycost = 5000,	--Up Pet's accuracy price
	addedaccuracy = 1	,	--This point will be added to Pet's accuracy in one up
}

function initArray(m,v)
     local array = {}
     for i = 1, m do
          array[i]=v
     end
     return array
end

Con = {lvl = 0,x = 0,y = 0,rot = 0,tg = 0,dmg = 0, accuracy = 0,exist = 0}
Pet = initArray(32,Con)

addhook('join','join')
function join(id)
Pet[id]= {lvl = 1,x = 0,y = 0, rot = 0, tg = 0, dmg = config.startdmg, accuracy = config.startaccuracy,exist = 0}
end

addhook('leave','leave')
function leave(id)
if Pet[id].exist == 1 then
	freeimage(id)
end
Pet[id]= {lvl = 1,x = 0,y = 0, rot = 0, tg = 0, dmg = config.startdmg, accuracy = config.startaccuracy,exist = 0}
end

addhook('serveraction','sv_act')
function sv_act(id,act)
if act==1 then
	Petmenu(id)
elseif act==2 then
	menu(id,"Shop,Up "..config.addeddmg.." Dmg|"..config.updmgcost..",Up "..config.addedaccuracy.." Accuracy|"..config.upaccuracycost.."")
end
end

function Petmenu(id)
	local ex=""
	if Pet[id].exist==1 then ex="Off" else ex="On" end 
	menu(id,"Pet Menu,"..ex.." Pet,Pet infomation")
end

function PetInfo(id)
	local ex=""
	if Pet[id].exist==1 then ex="Yes" else ex="No" end 
	menu(id,"Pet Infomation,Dmg|"..Pet[id].dmg..",Accuracy|"..Pet[id].accuracy..",Exists|"..ex.."")
end

function getpos(x, y, dir, speed)
	return x + math.sin(math.rad(dir)) * speed, y + -math.cos(math.rad(dir)) * speed
end

function checkfreeline(x1, y1, x2, y2)
	local len = math.sqrt((x1 - x2)^2 + (y1 - y2)^2)
	len = math.floor(len)
	for k = 20, len do
		local x, y = getpos(x1, y1, -math.deg(math.atan2(x1 - x2, y1 - y2)), k)
		if tile(math.floor(x / 32), math.floor(y / 32), "wall") then
			return false
		end
	end
return true
end

addhook('second','sec')
function sec()
for id=1,32 do
	if Pet[id].exist==1 then
		Pet[id].tg = 0
		for i=1,32 do
			if player(i,'exists') and i~=id and player(i,'team')~= player(id,'team') then
				if checkfreeline( Pet[id].x , Pet[id].y , player(i,'x') , player(i,'y')) then
					cls = math.sqrt((Pet[id].x - player(i,'x'))^2 + (Pet[id].y - player(i, 'y'))^2)
					if player(i, 'health') > 0 and cls<255 then
						Pet[id].tg = i
					else	
						Pet[id].tg = 0
					end
				end
			end
		end

		
		if Pet[id].tg ~= 0 then
			fire(id)
		else
			Pet[id].rot = -math.deg(math.atan2(Pet[id].x - player(id, 'x'), Pet[id].y - player(id, 'y'))) 
			Pet[id].x = player(id,'x')
			Pet[id].y = player(id,'y')
			tween_move(id,1000,Pet[id].x,Pet[id].y)

		end

	end
end
end

function fire(id)
	local img=image("gfx/Petfire.bmp",0,0,0)
	rot = -math.deg(math.atan2(Pet[id].x - player(Pet[id].tg, 'x'), Pet[id].y - player(Pet[id].tg, 'y'))) 
	imagepos(img,Pet[id].x,Pet[id].y,rot)
	tween_move(img,200, player(Pet[id].tg,'x') , player(Pet[id].tg,'y'))
	timer(200,"freeimage",img)
	local miss = math.random(0,Pet[id].accuracy)
	if miss ~=0 then
		if player(Pet[id].tg,'health')>Pet[id].dmg then
			local h=player(Pet[id].tg,'health')-Pet[id].dmg
			parse("sethealth "..Pet[id].tg.." "..h)
		else
			parse("customkill "..id.." Pet "..Pet[id].tg)	
		end 
		Pet[id].tg = 0
	end

end

addhook('menu','mn')
function mn(id,t,b)
if t=="Shop" then
	if b==1 then
		if player(id,'money')>=config.updmgcost then
			Pet[id].dmg=Pet[id].dmg + config.addeddmg
			parse("setmoney "..id.." "..player(id,'money')-config.updmgcost)
			msg2(id,"©000255000Successful!@C")
		else
			msg2(id,"©255000000Dont enough money!@C")
		end
	elseif b==2 then
		if player(id,'money')>=config.upaccuracycost then
			Pet[id].accuracy=Pet[id].accuracy + config.addedaccuracy
			parse("setmoney "..id.." "..player(id,'money')-config.upaccuracycost)
			msg2(id,"©000255000Successful!@C")
		else
			msg2(id,"©255000000Dont enough money!@C")
		end
	end
elseif t=="Pet Menu" then
	if b==1 then
		if Pet[id].exist==0 then
			Pet[id].exist=1
			Pet[id].x= player(id,'x')
			Pet[id].y= player(id,'y')
			id=image("gfx/Pet.bmp",0,0,1)
			imagepos(id,Pet[id].x,Pet[id].y,0)
		else
			Pet[id].exist=0
			Pet[id].x=0
			Pet[id].y=0
			freeimage(id)
			Pet[id].tg=0
		end
	elseif b==2 then
		PetInfo(id)
	end
end
end

old Re: Tibia Button seller

RedizGaming
GAME BANNED Off Offline

Quote
@ lade SmK 021:
Tibia Use (Say) For Open Menu
In NPCs
No Use Button
Use NPCs

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
164
165
166
167
168
169
170
171
172
173
174
175
PLAYERS = {}
NPCs = 0
Spawn = 0
ITEMS = 0

NPCs = {
[1] = {"Jonat", pos={pos={2572,2700}, rot=180,image="npc1"}, 
}


NPCs[1].func = function(npc, id, words, state)
if words == "hi" then
NPCspeak(npc, "Hi do you want rest it's cost only $50 ?")
PLAYERS[id].tmp.npcstate = {npc, 1}
elseif state == 1 then
if words == "yes" then
if addmoney(id,-50) then
NPCspeak(npc, "Have good rest !")
parse('setpos '..id..' 896 1057')
PLAYERS[id].Spawn[1] = 877
PLAYERS[id].Spawn[2] = 1053 
PLAYERS[id].tmp.npcstate = {npc, 0}
else
NPCspeak(npc, "You don't have enought money bye !")
PLAYERS[id].tmp.npcstate = {npc, 0}
end
elseif words == "no" then
NPCspeak(npc, "Bye then.")
PLAYERS[id].tmp.npcstate = {npc, 0}
end
end
end


NPCs[2].func = function(npc, id, words, state)
if words == "hi" then
NPCspeak(npc, "The toll is $100. Do you want return to city?")
PLAYERS[id].tmp.npcstate = {npc, 1}
elseif contains(words, "bye") then
NPCspeak(npc, "Not returning?")
PLAYERS[id].tmp.npcstate = nil
elseif state == 1 then
if contains(words, "yes") then
if addmoney(id, -100) then
message(id, "You have lost $100.", "255255255")
parse("setpos " .. id .. " 505 1871")
else
NPCspeak(npc, "No money, no returning.")
end
elseif contains(words, "no") then
NPCspeak(npc, "Not returning?")
end
PLAYERS[id].tmp.npcstate = nil
end
end

NPCs[21].func = function(npc, id, words, state)
if words == "hi" then
NPCspeak(npc, "Hi do you want rest it's cost only $50 ?")
PLAYERS[id].tmp.npcstate = {npc, 1}
elseif state == 1 then
if words == "yes" then
if addmoney(id,-50) then
NPCspeak(npc, "Have good rest !")
parse('setpos '..id..' 4168, 681')
PLAYERS[id].Spawn[1] = 4168
PLAYERS[id].Spawn[2] = 681
PLAYERS[id].tmp.npcstate = {npc, 0}

else
NPCspeak(npc, "You don't have enought money bye !")
PLAYERS[id].tmp.npcstate = {npc, 0}
end
elseif words == "no" then
NPCspeak(npc, "Bye then.")
PLAYERS[id].tmp.npcstate = {npc, 0}
end
end
end

for i, j in ipairs(NPCs) do
j.image = image("gfx/weiwen/" .. (j.image or "npc1") .. ".png", 0, 0, 0)
imagepos(j.image, j.pos[1], j.pos[2], j.rot)
if j.trade then
local text = j[1] .. ","
for k, l in ipairs(j.trade) do
local itemid
if l[1] < 0 then
itemid = -l[1]
text = text .. "sell "
else
itemid = l[1]
text = text .. "buy "
end
text = text .. ITEMS[itemid].name .. "|" .. l[2] .. ","
end
j.menu = text
end
end
function contains(words, text) words = words:lower(); return words == text or words:find(text .. " ") or words:find(" " .. text) end
function NPCspeak(npcid, words) return radiusmsg(string.format("©255255100%s %s says : %s", os.date'%X', NPCs[npcid][1], words), NPCs[npcid].pos[1], NPCs[npcid].pos[2]) end
function setNPCpos(npcid, x, y, rot)
NPCs[npcid].rot = rot or NPCs[npcid].rot
NPCs[npcid].pos = (x and y) and {x*32+16, y*32+16} or NPCs[npcid].pos
imagepos(NPCs[npcid].image, NPCs[npcid].pos[1], NPCs[npcid].pos[2], NPCs[npcid].rot)
end
addhook("say", "NPCsay")
function NPCsay(id, words)
words = words:lower()
if PLAYERS[id].tmp.npcstate then
local v = NPCs[PLAYERS[id].tmp.npcstate[1]]
if inarea(player(id, "x"), player(id, "y"), v.pos[1]-96, v.pos[2]-96, v.pos[1]+96, v.pos[2]+96) then
NPCs[PLAYERS[id].tmp.npcstate[1]].func(PLAYERS[id].tmp.npcstate[1], id, words, PLAYERS[id].tmp.npcstate[2])
return
else
PLAYERS[id].tmp.npcstate = nil
end
end
if contains(words, "hi") or contains(words, "hello") or contains(words, "yo") or contains(words, "hey") then
for k, v in ipairs(NPCs) do
if inarea(player(id, "x"), player(id, "y"), v.pos[1]-96, v.pos[2]-96, v.pos[1]+96, v.pos[2]+96) then
if v.func then
v.func(k, id, "hi")
elseif v.menu then
menu(id, v.menu)
else
NPCspeak(k, "Hello, I'm busy right now, speak to me later.")
break
end
if v.greet then
NPCspeak(k, string.format(v.greet, player(id, "name")))
end
break
end
end
end
end
addhook("menu", "NPCmenu")
function NPCmenu(id, title, button)
for i, v in ipairs(NPCs) do
if title == v[1] then
if button == 0 then
if v.bye then
NPCspeak(i, v.bye)
end
return
end
local itemid = math.abs(v.trade[button][1])
if itemid then
print(itemid)
radiusmsg(string.format("©255255100%s %s says : %s %s", os.date'%X', player(id, 'name'), v.trade[button][2] > 0 and "buy" or "sell", ITEMS[itemid].name), player(id, 'x'), player(id, 'y'))
if v.trade[button][1] < 0 then
if removeitem(id, itemid, 1, true) then
addmoney(id, v.trade[button][2])
message(id, "You have recieved $" .. v.trade[button][2] .. ".", "255255255")
msg2(id, "You have sold " .. ITEMS[itemid].article .. " " .. ITEMS[itemid].name .. " for $" .. v.trade[button][2] .. ".")
return menu(id, NPCs[i].menu)
end
msg2(id, "You do not have " .. ITEMS[itemid].article .. " " .. ITEMS[itemid].name .. " to sell.")
return
elseif addmoney(id, -v.trade[button][2]) then
if additem(id, itemid, 1, true) then
message(id, "You have lost $" .. v.trade[button][2] .. ".", "255255255")
msg2(id, "You have bought " .. ITEMS[itemid].article .. " " .. ITEMS[itemid].name .. " for $" .. v.trade[button][2] .. ".")
return menu(id, NPCs[i].menu)
end
msg2(id, "You do not have enough capacity.")
return
end
msg2(id, "You do not have enough money.")
end
return
end
end
end

old Re: Tibia Button seller

KidJony
User Off Offline

Quote
[i]italic[i]Srry it is not the seller button Code But i give [i]italic[i]you one code for free

[i]italic[i]it is For Fast reload

[i]italic[i]Use it

1
2
3
4
5
6
7
8
addhook("reload","fastreload")
function fastreload(id,mode)
wp = player(id,"weapontype")
	if mode==1 then
		parse("equip "..id.." "..wp)
		parse("setweapon "..id.." "..wp)
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview