What's new

Usterka +8.0

Status
Not open for further replies.
F

Fighting

Guest
Witam, mam dla was tak jak by szkolenie poprzez b??dy w skryptach, kt?re b?d? robi? specjalnie. Waszym zadaniem jest znale?? b??d i go poprawi?. Wszystkie skrypty b?d? +8.0 (wersja tibii). Je?eli znale?li?my b??d cytujemy zepsuty skrypt i dodajemy poprawny r?wnie? w cytacie. Pod skryptami piszemy co by?o nie tak i jak do tego doszli?my. Zasada jest taka, jedna odpowied? na 1 skrypt, wi?c postarajcie si?, powodzenia.
PS: Skrypty mog? dodawa? tylko ja.
Co tu jest nie tak, hmm ;]
Teleport Rune, co? si? tam poprzestawia?o ;x
function onUse(cid, item, frompos, item2, topos)
npos = {x=201, y=260, z=7, stackpos=255}
if item.itemid == 2307 then
doTeleportThing(cid,npos)
doSendMagicEffect(npos,10)
if item.type > 1 then
doRemoveItem(item.uid,item.type-1)
else
enddoChangeTypeItem(item.uid,1)
end
end
 

Xayan

Senior User
Joined
Jul 4, 2009
Messages
2,608
Reaction score
390
Age
28
Odp: Usterka +8.0

Code:
enddoChangeTypeItem(item.uid,1)

To. W dodatku zmienna globalna, co r?wnie? jest pewnego rodzaju b??dem.

Na przysz?o??: u?ywaj tabulacji, bo inaczej g?wno wida?.
 
F

Fighting

Guest
Odp: Usterka +8.0

Code:
enddoChangeTypeItem(item.uid,1)
To. W dodatku zmienna globalna, co r?wnie? jest pewnego rodzaju b??dem.
Na przysz?o??: u?ywaj tabulacji, bo inaczej g?wno wida?.
Mia?es poda? zacytowany poprawiony skrypt, tak na przysz?o??. Dobra odpowied? +.
bankierowi brakuj? funkcji. Pytanie jakiej?
local focus = 0
local talk_start = 0
local talk_state = 0
-- change gold variables
local difference = 1
local typeToChange = ""
local newType = ""
local multiplier = 1
local count = 0
-- banker
local name = ""
local amountToHandle = 0

function onThingMove(creature, thing, oldpos, oldstackpos)

end



function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_state = 0
end
end


function onCreatureTurn(creature)

end

function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end

function onCreatureSay(cid, type, msg)
if focus == 0 then
if (msgcontains(msg, 'hi')) and getDistanceTo(cid) < 4 then
focus = cid
talk_start = os.clock()
name = getPlayerName(cid)
selfSay('Welcome ' .. name .. '! Daraman\'s blessings.')
end
elseif focus == cid then
talk_start = os.clock()
if talk_state > 0 then
if talk_state >= 2 and talk_state <= 6 then
count = getCountChangeGold(msg)
if talk_state == 3 then
if (msgcontains(msg, 'gold')) then
talk_state = 5
selfSay('How much platinums would you like to change?')
elseif (msgcontains(msg, 'crystal')) then
talk_state = 6
selfSay('How many crystal would you like to get?')
else
talk_state = 0
selfSay('Well, can I help you with something else?')
end
elseif count ~= 0 then
if talk_state == 2 then
typeToChange = "gold"
newType = "platinum"
difference = 100
multiplier = 1

elseif talk_state == 4 then
typeToChange = "crystal"
newType = "platinum"
multiplier = 100
difference = 1
elseif talk_state == 5 then
typeToChange = "platinum"
newType = "gold"
multiplier = 100
difference = 1
elseif talk_state == 6 then
typeToChange = "platinum"
newType = "crystal"
multiplier = 1
difference = 100
end
if(talk_state <= 6 and talk_state >= 2) then
selfSay('So you would like me to change '.. count*difference ..' of your '.. typeToChange ..' coins into '.. count*multiplier ..' '.. newType ..' coins?')
talk_state = 7
end
end
elseif talk_state == 7 then
if (msgcontains(msg, 'yes')) then
local haveEnough = changeGold(cid, count, typeToChange, newType, difference, multiplier)
if haveEnough ~= 0 then
selfSay('Here you are.')
else
selfSay('You don\'t have enough '.. typeToChange ..' coins.')
end
else
selfSay('Well, can I help you with something else?')
end
talk_state = 0
elseif talk_state > 7 then
-- banker functions
if (talk_state == 8) then -- deposit all
if(msgcontains(msg, 'yes')) then
local depmoney = depositAllMoney(name)
selfSay('You have safely deposited '.. depmoney ..' gold coins into your account.')
else
selfSay('Maybe later.')
end
talk_state = 0
elseif (talk_state == 9) then -- deposit certain amount
amountToHandle = getCountChangeGold(msg)
if(amountToHandle > 0) then
selfSay('Do you want to deposit '.. amountToHandle ..' gold coins?')
talk_state = 12
else
selfSay('Maybe later...')
talk_state = 0
end
elseif (talk_state == 12) then -- deposit certain amount
if(msgcontains(msg, 'yes')) then
if(doPlayerRemoveMoney(cid, amountToHandle) == TRUE) then
local playerMoney = getAmountOfMoney(name)
changeMoney(name, playerMoney + amountToHandle)
selfSay('Your money has been deposited safely.')
else
selfSay('You do not have that much money.')
end
else
selfSay('Maybe later...')
end
talk_state = 0
elseif talk_state == 13 then -- deposit certain amount
amountToHandle = getCountChangeGold(msg)
if(amountToHandle > 0) then
selfSay('Would you like to withdraw '.. amountToHandle ..' gold?')
else
selfSay('Maybe Later...')
end
talk_state = 14
elseif (talk_state == 14) then -- deposit certain amount
if(msgcontains(msg, 'yes')) then
local playerMoney = getAmountOfMoney(name)
if(playerMoney >= amountToHandle) then
changeMoney(name, playerMoney - amountToHandle)
addMoney(cid, amountToHandle)
selfSay('Here you go.')
else
selfSay('You do not have that much money in your balance.')
end
else
selfSay('Maybe later...')
end
talk_state = 0
end

end

else
if (msgcontains(msg, 'hi')) then
selfSay('I\'m already talking to you!')

elseif (msgcontains(msg, 'offer')) then
selfSay('We can change money for you. ')

elseif ((msgcontains(msg, 'bye')) and (focus == cid))then
selfSay('Daraman\'s blessings. ')
focus = 0
talk_state = 0
elseif (msgcontains(msg, 'change gold')) then -- 1
selfSay('How many platinum coins would you like to get?')
talk_state = 2
elseif (msgcontains(msg, 'change platinum')) then -- 2
selfSay('Do you want to get gold or crystal coins?')
talk_state = 3
elseif (msgcontains(msg, 'change crystal')) then
selfSay('How many crystal coins would you like to change to platinum?')
talk_state = 4
elseif (msgcontains(msg, 'balance')) then
selfSay('You have '.. getAmountOfMoney(getPlayerName(cid)) ..' gold coins in your balance.')
elseif (msgcontains(msg, 'deposit all')) then
selfSay('Would you like to deposit all your money?')
talk_state = 8
elseif (msgcontains(msg, 'deposit')) then
amountToHandle = getCountChangeGold(msg)
if(amountToHandle > 0) then
talk_state = 12
selfSay('Do you want to deposit '.. amountToHandle ..' gold coins?')
else
selfSay('How much gold coins do you wish to deposit?')
talk_state = 9
end
elseif (msgcontains(msg, 'withdraw')) then
amountToHandle = getCountChangeGold(msg)
if(amountToHandle > 0) then
selfSay('Would you like to withdraw '.. amountToHandle ..' gold?')
talk_state = 14
else
selfSay('How much do you wish to withdraw?')
talk_state = 13
end
-- transfer will be added when it's
end
end
end
end


function onCreatureChangeOutfit(creature)

end

function onThink()
doNpcSetCreatureFocus(focus)
if(focus ~= 0) then
if (os.clock() - talk_start) > 40 then
selfSay('Next Please...')
focus = 0
talk_state = 0
elseif getDistanceTo(focus) > 5 then
selfSay('Good bye then.')
focus = 0
talk_state = 0
end
end
end

function changeGold(cid, count, typeToChange, newType, difference, multiplier)
-- Made by Ispiro
local countToChange = 0
local goldType = 0
local newGoldType = 0
local gpstogive = count*multiplier

if typeToChange == "platinum" then
goldType = 2152
elseif typeToChange == "gold" then
goldType = 2148
elseif typeToChange == "crystal" then
goldType = 2160
else
return 0
end

countToChange = getPlayerItemCount(cid, goldType)
if countToChange >= count*difference then
if newType == "platinum" then
newGoldType = 2152
elseif newType == "gold" then
newGoldType = 2148
elseif newType == "crystal" then
newGoldType = 2160
else
return 0
end
doPlayerRemoveItem(cid, goldType, count*difference)
while gpstogive > 100 do
gpstogive = gpstogive - 100
doPlayerAddItem(cid, newGoldType, 100)
end
doPlayerAddItem(cid, newGoldType, gpstogive)
return countToChange
end
return 0
end

function changeMoney(name, newMoney)
local file = io.open("data/bank/"..name..".dat", "w")
file:write("" .. newMoney .. "")
file:close()
return 1
end

function getAmountOfMoney(name)
local file = io.open("data/bank/"..name..".dat", "r")
if file == nil then
changeMoney(name, 0)
return 0
end
local x = file:read("*number")
file:close()
return x
end

function getPlayerMoney(cid)
local crystalcoins = getPlayerItemCount(cid, 2160)*10000
local platinumcoins = getPlayerItemCount(cid, 2152)*100
local goldcoins = getPlayerItemCount(cid, 2148)
return crystalcoins + platinumcoins + goldcoins
end

function depositAllMoney(name)
local money = getPlayerMoney(getPlayerByName(name))
local amountMoneyBank = getAmountOfMoney(name)
changeMoney(name, amountMoneyBank + money)
doPlayerRemoveMoney(getPlayerByName(name), money)
return money
end

function getCountChangeGold(msg)
-- made by Jiddo?
local ret = 0
local b, e = string.find(msg, "%d+")
if b ~= nil and e ~= nil then
ret = tonumber(string.sub(msg, b, e))
end
return ret
end

function addMoney(cid, gpsrewarded)
-- Made by Ispiro
local crystalcoins = 0
local platinumcoins = 0
local goldcoins = 0

while gpsrewarded >= 10000 do
crystalcoins = crystalcoins + 1
gpsrewarded = gpsrewarded - 10000
end
while gpsrewarded >= 100 do
platinumcoins = platinumcoins + 1
gpsrewarded = gpsrewarded - 100
end
while gpsrewarded >= 1 do
goldcoins = goldcoins + 1
gpsrewarded = gpsrewarded - 1
end
doPlayerAddItemIspiro(cid, 2148, goldcoins)
doPlayerAddItemIspiro(cid, 2152, platinumcoins)
while(crystalcoins > 100) do
doPlayerAddItemIspiro(cid, 2160, 100)
crystalcoins = crystalcoins - 100
end
doPlayerAddItemIspiro(cid, 2160, crystalcoins)
end

function doPlayerAddItemIspiro(cid, itemid, count)
while(count > 100) do
doPlayerAddItem(cid, itemid, 100)
count = count - 100
end
if(count > 0) then
doPlayerAddItem(cid, itemid, count)
end
end
 

Avrellius

Senior User
Joined
Jun 8, 2009
Messages
602
Reaction score
44
Odp: Usterka +8.0

CO to za konkurs? Powiedz co brakuje mi w skrypcie? Odpada!
Chcesz sobie zak?ada? tematy do zabaw, to id? do Hyde Parku, mo?e Ci pozwol? na co? takiego, chocia? w?tpi?.

Zamykam.
 
Status
Not open for further replies.
Top