• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

fix

Status
Not open for further replies.

Sherlok

Active Member
Joined
Aug 29, 2008
Messages
2,116
Reaction score
44
Location
Poland, Wrocław.
Hiho,
Mógłby ktoś naprawić mi poniższe dwa skrypt, aby działały na 0.3.6pl1?

Błąd:
Code:
[Error - Action Interface]
data/actions/scripts/sherlok/runes.lua:onUse
Description:
data/actions/scripts/sherlok/runes.lua:20: attempt to index local 'potion' (a ni
l value)
stack traceback:
        data/actions/scripts/sherlok/runes.lua:20: in function <data/actions/scr
ipts/sherlok/runes.lua:15>

Skrypt:
LUA:
local config = {
        [1248] = {potion = 2268, cost = 6500, backpack_id = 2003, charges = 9}, -- sudden death rune
        [1249] = {potion = 2269, cost = 6400, backpack_id = 2002, charges = 6}, -- wild growth rune
        [1250] = {potion = 2274, cost = 3600, backpack_id = 2002, charges = 12}, -- avalanche rune
		[1251] = {potion = 2305, cost = 7000, backpack_id = 2000, charges = 6}, -- fire bomb rune
		
		[1252] = {potion = 2308, cost = 4200, backpack_id = 2000, charges = 9}, -- soulfire rune
        [1253] = {potion = 2278, cost = 14000, backpack_id = 5949, charges = 3}, -- paralyze rune
        [1254] = {potion = 2273, cost = 3500, backpack_id = 2002, charges = 3}, -- ultimate healing rune
		[1255] = {potion = 2261, cost = 900, backpack_id = 2003, charges = 9}, -- destroy field rune
		
		[1256] = {potion = 2293, cost = 7000, backpack_id = 2004, charges = 9}, -- magic wall rune
} -- config end --

function onUse(cid, item, fromPosition, itemEx, toPosition)
        local potion = config[item.uid]
        if isInArray({1945, 1946}, item.itemid) ~= TRUE then
                return TRUE
        end
        if doPlayerBuyItemContainer(cid, potion.backpack_id, potion.potion, 1, potion.cost, potion.charges) == TRUE then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought a backpack "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..potion.cost.." gold coins for a backpack "..getItemNameById(potion.potion)..".")
        end
        return TRUE
end

____________________________________________

Błąd:
Code:
[Error - Action Interface]
data/actions/scripts/sherlok/potions.lua:onUse
Description:
data/actions/scripts/sherlok/potions.lua:18: attempt to index local 'potion' (a
nil value)
stack traceback:
        data/actions/scripts/sherlok/potions.lua:18: in function <data/actions/s
cripts/sherlok/potions.lua:13>

Skrypt:
LUA:
local config = {
[1240] = {potion = 7618, cost = 1000}, -- health potion
[1241] = {potion = 7588, cost = 2500}, -- strong health potion
[1242] = {potion = 7591, cost = 5000}, -- great health potion
[1243] = {potion = 8473, cost = 6200}, -- ultimate healing rune

[1244] = {potion = 7620, cost = 5000}, -- mana potion
[1245] = {potion = 7589, cost = 5000}, -- string mana potion
[1246] = {potion = 7590, cost = 5000}, -- great mana potion
[1247] = {potion = 8472, cost = 3800}, -- great spirit potion
} -- config end --

function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = config[item.uid]
if isInArray({1945, 1946}, item.itemid) ~= TRUE then
return TRUE
end
if doPlayerBuyItem(cid, potion.potion, 1, potion.cost, 1) == TRUE then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have bought "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..potion.cost.." gold pieces to buy "..getItemNameById(potion.potion)..".")
end
return TRUE
end


Z góry dzięki :)
Pozdrawiam,
Sherlok
 
Usun przecinki za ostatnimi elementami tablicy config.
Pokaz jeszcze linijke z actions.xml.

Pozatym jestes pewien, ze
LUA:
local potion =  config[item.uid]

a nie:
LUA:
local potion =  config[item.itemid]
?
 
Pozatym, zrob sobie takie cos:
Code:
if(not potion) then
	return true
end

+ zmien nazwe variabla z id z potion na cos innego ;p
 
Ale naap ze mnie - błąd tkwił w tym, że ustawiłem na mapie actionid zamiast uniqueid :S

Repki dla panów wyżej, dzięki :)
 
Last edited:
Status
Not open for further replies.
Back
Top