- Joined
- Aug 6, 2007
- Messages
- 1,767
- Reaction score
- 36
Just to let people stop whining i'll release my advanced one...
Good Job!!!! Very nice work there! Thanks for release
Thanks for this. Was needing this.
function doPlayerBuyItem(cid, itemid, count, cost, charges)
if(doPlayerRemoveMoney(cid, cost) == TRUE) then
return doPlayerGiveItem(cid, itemid, count, charges)
end
return LUA_ERROR
end
function doPlayerBuyItem(cid, itemid, count, cost, charges)
if(type(itemid) == "table") then
cost = cost*count
end
if(doPlayerRemoveMoney(cid, cost) == TRUE) then
if(type(itemid) == "table") then
y = 0
while y < count do
bp = doPlayerAddItem(cid, itemid[1], 1)
x = 0
while x < itemid[4] do
doAddContainerItem(bp, itemid[2], itemid[3])
x = x + 1
end
y = y + 1
end
return LUA_NO_ERROR
else
return doPlayerGiveItem(cid, itemid, count, charges)
end
else
return LUA_ERROR
end
end
The best way for buy container(bp with rune or something):
working on TFS.
in file global.lua
change this function
from
PHP:function doPlayerBuyItem(cid, itemid, count, cost, charges) if(doPlayerRemoveMoney(cid, cost) == TRUE) then return doPlayerGiveItem(cid, itemid, count, charges) end return LUA_ERROR end
to
PHP:function doPlayerBuyItem(cid, itemid, count, cost, charges) if(type(itemid) == "table") then cost = cost*count end if(doPlayerRemoveMoney(cid, cost) == TRUE) then if(type(itemid) == "table") then y = 0 while y < count do bp = doPlayerAddItem(cid, itemid[1], 1) x = 0 while x < itemid[4] do doAddContainerItem(bp, itemid[2], itemid[3]) x = x + 1 end y = y + 1 end return LUA_NO_ERROR else return doPlayerGiveItem(cid, itemid, count, charges) end else return LUA_ERROR end end
sample rune shop:
shopModule:addBuyableItem({'bp uh'}, {1988, 2273, 1, 20}, 20*150, 'bp of ultimate healing runes')
where:
1988 - is bp
2273 - uh rune
1 - charges in uh rune
20 - amount runes in bp
20*150 (20 runes * price 150gp each)
supported buy more than one bp.. buy 3 bp uh...
function StdModule.buyContainer(cid, message, keywords, parameters, node)
if(cid ~= npcHandler.focus) then
return false
end
local bpID, runeID, cost, charges = parameters[1], parameters[2], parameters[3], parameters[4]
if(doPlayerRemoveMoney(cid, cost) ~= TRUE) then
selfSay('You do not have enough money!')
else
if(isContainer(bpID) == TRUE) then
local containerID = doPlayerAddItem(cid, bpID, 1)
while getContainerSize(bpID) ~= 20 do
doAddContainerItem(containerId, runeID, charges)
end
end
end
return true
end
Viorka said:PHP:function doPlayerBuyItem(cid, itemid, count, cost, charges) ........ end
sample rune shop:
shopModule:addBuyableItem({'bp uh'}, {1988, 2273, 1, 20}, 20*150, 'bp of ultimate healing runes')
where:
1988 - is bp
2273 - uh rune
1 - charges in uh rune
20 - amount runes in bp
20*150 (20 runes * price 150gp each)
supported buy more than one bp.. buy 3 bp uh...<<FIX IT!
How to fix it:when i buy 1 BP with 20 runes for 800gp/each npc take 16k from my bp, when i buy 2 bp npc take 64 k (cash for 4 bp), when i buy 16 bp npc take 4kk+, but always first he say "18:07 Runeiro: Czy chcesz kupic 16 bp of multi sd za 256000 GP?" (16000gp - bp, 32000-2bp - always good price) and when i say "yes" he take his "price*numer of bp" (256000*16= 4kk+)
cost = cost*count
cost = cost
function doPlayerBuyItem(cid, itemid, count, cost, charges)
if(type(itemid) == "table") then
cost = cost
end
if(doPlayerRemoveMoney(cid, cost) == TRUE) then
if(type(itemid) == "table") then
y = 0
while y < count do
bp = doPlayerAddItem(cid, itemid[1], 1)
x = 0
while x < itemid[4] do
doAddContainerItem(bp, itemid[2], itemid[3])
x = x + 1
end
y = y + 1
end
return LUA_NO_ERROR
else
return doPlayerGiveItem(cid, itemid, count, charges)
end
else
return LUA_ERROR
end
end
THANK YOU! It really help me. Rep+
EDIT--------------------EDIT-----------EDIT----------
@I FOUND BUG IN YOUR CODE "Viorka":
How to fix it:
change:
to:Code:cost = cost*count
Fixed code of "Viorka":Code:cost = cost
/\ Tested by me. Work fine with 1 and more BPs/runes.Code:function doPlayerBuyItem(cid, itemid, count, cost, charges) if(type(itemid) == "table") then cost = cost end if(doPlayerRemoveMoney(cid, cost) == TRUE) then if(type(itemid) == "table") then y = 0 while y < count do bp = doPlayerAddItem(cid, itemid[1], 1) x = 0 while x < itemid[4] do doAddContainerItem(bp, itemid[2], itemid[3]) x = x + 1 end y = y + 1 end return LUA_NO_ERROR else return doPlayerGiveItem(cid, itemid, count, charges) end else return LUA_ERROR end end
I tried to add your advanced containter, but server show errors :>
This code is easier.
I will not give you rep just because you asked for it.
I think people sould want to give reputation and not give because people beg for it.
I doubt you will get 15 rep in one WEEK.