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

Lua Need help to modify script.

Wiw3K

New Member
Joined
Apr 16, 2008
Messages
371
Reaction score
3
Need help to modify script !vials , to !vials PARAM.

!vials small
!vials strong
!vials great

LUA:
function onSay(cid, words, param, channel)
        local ids = {
                7636,   -- ID of small vial.
                7634,   -- ID of strong vial.
                7635    -- ID of great vial.
        }

        local costs = {
                2,      -- Price of small vial.
                3,      -- Price of strong vial.
                4       -- Price of great vial.
        }

        local small = getPlayerItemCount(cid, ids[1])
        local strong = getPlayerItemCount(cid, ids[2])
        local great = getPlayerItemCount(cid, ids[3])

        if (small > 0) then
                doPlayerAddMoney(cid, (small * costs[1]))
                doPlayerRemoveItem(cid, ids[1], small)
        elseif (strong > 0) then
                doPlayerAddMoney(cid, (strong * costs[2]))
                doPlayerRemoveItem(cid, ids[2], strong)
        elseif (great > 0) then
                doPlayerAddMoney(cid, (great * costs[3]))
                doPlayerRemoveItem(cid, ids[3], great)
        end

        return TRUE
end

because if someone have small , strong and great he got DEBUG after using this command...
 
Try this

Try this:

LUA:
function onSay(cid, words, param, channel)
local vials = {
["small"] = {vi = 7636, cost = 2},
["strong"] = {vi = 7634, cost = 3},
["great"] = {vi = 7635, cost = 4},
}

if not(vials[param]) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid parameter. Try: small, strong, great as a parameter.")
		return TRUE
		end
local via = vials[param]
	if getPlayerItemCount(cid, via.vi) ~= 0 then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You sold ".. getPlayerItemCount(cid, via.vi) .." of ".. param .. " for " .. via.cost .. " .")
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enough ".. param .." vial to sell.")
	end
	return TRUE
end
 
Last edited:
No..

Wait! Gave you wrong script XD

Fixed:

LUA:
  function onSay(cid, words, param, channel)
local vials = {
["small"] = {vi = 7636, cost = 2},
["strong"] = {vi = 7634, cost = 3},
["great"] = {vi = 7635, cost = 4},
}

if not(vials[param]) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Invalid parameter. Try: small, strong, great as a parameter.")
                return TRUE
                end
local via = vials[param]
        if getPlayerItemCount(cid, via.vi) ~= 0 then
		local totalcostt = via.cost * getPlayerItemCount(cid, via.vi)
		doPlayerRemoveItem(cid, via.vi, getPlayerItemCount(cid, via.vi))
		doPlayerAddMoney(cid, totalcostt)
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You sold ".. getPlayerItemCount(cid, via.vi) .." of ".. param .. " for " .. totalcostt .. " gold coins.")
        else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have enough ".. param .." vial to sell.")
        end
        return TRUE
end
 
Back
Top