• 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!

Jak przerobic ten skrypt zeby dawal potiony bez bp ( sklep przez dzwignie )

zduna

Banned User
Joined
May 3, 2010
Messages
201
Reaction score
0
--[[
Potion Script v1.0
by Shawak
]]--

local config = {
[5601] = {potion = 8473, cost = 1000, backpack_id = 2000}, -- uhp
[5602] = {potion = 7588, cost = 2500, backpack_id = 2000}, -- strong health potion
[5603] = {potion = 7591, cost = 5000, backpack_id = 2000}, -- great health potion

[5604] = {potion = 8472, cost = 5000, backpack_id = 2001}, -- dla pala
[5605] = {potion = 7589, cost = 5000, backpack_id = 2001}, -- string mana potion
[5606] = {potion = 7590, cost = 5000, backpack_id = 2001}, -- great mana 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 doPlayerBuyItemContainer(cid, potion.backpack_id, potion.potion, 1, potion.cost, 1) == 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

Jak przerobic to tak zeby dawal same potiony bez bp
 
LUA:
local config = 
{
	-- [itemid] = {potion id, count in pieces, cost in gp}
	[5601] = {potion = 8473, count = 1, cost = 1000}
}


function onUse(cid, item, fromPosition, itemEx, toPosition)
	local pointer = config[item.uid]
	if (isInArray({1945, 1946}, item.itemid)) then
	else if (pointer) then
		if (doPlayerRemoveMoney(cid, pointer.cost)) then
			if (not doPlayerAddItem(cid, pointer.potion, pointer.count) then
				-- todo error message
				-- here player can't but this item, no slot or something like this
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought a backpack "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. pointer.cost .." gold coins for a backpack ".. getItemNameById(pointer.potion) ..".")
		end
	end
	
	return true
end
 
Taki blad

[9:33:10.054] [Error - LuaInterface::loadFile] data/actions/scripts/other/potions.lua:13: ')' expected near 'then'
[9:33:10.054] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/potions.lua)
[9:33:10.054] data/actions/scripts/other/potions.lua:13: ')' expected near 'then'
 
A gdzie ten nawias
Człowieku jest napisane przecież.
[9:33:10.054] data/actions/scripts/other/potions.lua:13: ')' expected near 'then'

Code:
if (not doPlayerAddItem(cid, pointer.potion, pointer.count) then
Code:
if (not doPlayerAddItem(cid, pointer.potion, pointer.count)) then
 
Last edited:
Nadal nie dziala

[10:33:57.022] [Error - LuaInterface::loadFile] data/actions/scripts/other/potions.lua:25: 'end' expected (to close 'function' at line 8) near '<eof>'
[10:33:57.022] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/potions.lua)
[10:33:57.022] data/actions/scripts/other/potions.lua:25: 'end' expected (to close 'function' at line 8) near '<eof>'
 
LUA:
config = 
{
	-- [itemid] = {potion id, count in pieces, cost in gp}
	[5601] = {potion = 8473, count = 1, cost = 1000}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local pointer = config[item.uid]
	if (isInArray({1945, 1946}, item.itemid)) then
		if (doPlayerRemoveMoney(cid, pointer.cost)) then
			if (not doPlayerAddItem(cid, pointer.potion, pointer.count)) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Dupa nie kupiles.")
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought a backpack "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. pointer.cost .." gold coins for a backpack ".. getItemNameById(pointer.potion) ..".")
		end
	end
	return true
end
 
To teraz inny problem
Potiony dzialaja extra, ale jak wstawiam drugi raz ten skrypt tylko ze z runami to:

[11:32:17.619] [Error - Action Interface]
[11:32:17.619] data/actions/scripts/other/runes.lua:onUse
[11:32:17.619] Description:
[11:32:17.619] data/actions/scripts/other/runes.lua:10: attempt to index local 'pointer' (a nil value)
[11:32:17.619] stack traceback:
[11:32:17.619] data/actions/scripts/other/runes.lua:10: in function <data/actions/scripts/other/runes.lua:7>
 
config =
{
-- [itemid] = {potion id, count in pieces, cost in gp}
[1248] = {potion = 2268, count = 1, cost = 1000}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
local pointer = config[item.uid]
if (isInArray({1945, 1946}, item.itemid)) then
if (doPlayerRemoveMoney(cid, pointer.cost)) then
if (not doPlayerAddItem(cid, pointer.potion, pointer.count)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Dupa nie kupiles.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought a backpack "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. pointer.cost .." gold coins for a backpack ".. getItemNameById(pointer.potion) ..".")
end
end
return true
end



[11:43:53.646] [Error - Action Interface]
[11:43:53.646] data/actions/scripts/other/runes.lua:onUse
[11:43:53.646] Description:
[11:43:53.646] data/actions/scripts/other/runes.lua:10: attempt to index local 'pointer' (a nil value)
[11:43:53.646] stack traceback:
[11:43:53.646] data/actions/scripts/other/runes.lua:10: in function <data/actions/scripts/other/runes.lua:7>

Takie cos
 
LUA:
config = 
{
	-- [itemid] = {potion id, count in pieces, cost in gp}
	[1248] = {potion = 2268, count = 1, cost = 1000}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local pointer = config[item.uid]
	if (isInArray({1945, 1946}, item.itemid)) then
		if (doPlayerRemoveMoney(cid, pointer.cost)) then
			if (not doPlayerAddItem(cid, pointer.potion, pointer.count)) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Dupa nie kupiles.")
			else
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought a backpack "..getItemNameById(pointer.potion).." for "..pointer.cost.." gold coins.")
			end
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need ".. pointer.cost .." gold coins for a backpack ".. getItemNameById(pointer.potion) ..".")
		end
	end
	return true
end
 
[12:41:47.796] [Error - Action Interface]
[12:41:47.796] data/actions/scripts/other/runes.lua:onUse
[12:41:47.796] Description:
[12:41:47.796] data/actions/scripts/other/runes.lua:10: attempt to index local 'pointer' (a nil value)
[12:41:47.796] stack traceback:
[12:41:47.796] data/actions/scripts/other/runes.lua:10: in function <data/actions/scripts/other/runes.lua:7>

Teraz takie cos
 
Ty, to nie jest dział request, a ty kurwa nawet konsoli lua nie czytasz? Jak widzę, że nie rozumiesz co oznaczają tak łatwe błędy w konsoli to nie rozumiem jak tacy tworzą otsy >.< Przeczytaj parę tutoriali czy coś jak nie rozumiesz..

Masz tu odemnie skrypta, nie sprawdzałem, nie wiem czy działa, idę oglądać drugą serię skoków;s
A Ty sobie przetestuj to w tym czasie:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local c = {
	[1111] = {potion_id = 2268, count = 1, cost_ea = 50},

	}
costam = c[item.uid]
	if costam then
		if getPlayerMoney(cid) >= (costam.count * costam.cost_ea) then
		doPlayerRemoveMoney(cid, (costam.count * costam.cost_ea))
		doPlayerAddItem(cid, costam.potion_id, costam.count)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought ".. costam.count .."x "..getItemNameById(costam.potion_id).." for "..(costam.count * costam.cost_ea).." gold coins.")
		else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You haven't got "..(costam.count * costam.cost_ea).." gold coins.")
		end
	end





return true
end
 
Back
Top