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

need help fixing a simple scrpit

healer007

New Member
Joined
Nov 11, 2008
Messages
174
Reaction score
0
Location
doesnt matter
-- Starting the function --
function onSay ( cid, words, param )

--Start configuration --

-- Items you can buy --
items =
{

['bp'] = { id = 1988, amount = 1, stackable = 0, costmoney = 1,

bpwithitems = 0, countinbp = 20, bpid = 3940, cost = 10, itemcost = 2472,

itemamountcost = 1 } ,
['aol'] = { id = 2173, amount = 1, stackable = 0, bpwithitems =

0, countinbp = 20, bpid = 3940,costmoney = 1, cost = 10000, itemcost =

2472, itemamountcost = 1 },
['bpsd'] = { id = 2268, amount = 100, stackable = 0, bpwithitems =

1, countinbp = 20, bpid = 2003, costmoney = 1, cost = 1000, itemcost =

2472, itemamountcost = 0 },
['food'] = { id = 2789, amount = 100, stackable = 1, costmoney =

1, bpwithitems = 0, countinbp = 20, bpid = 3940, cost = 100, itemcost =

2472, itemamountcost = 1 },
['Bp Drunkness'] = { id = 2267, amount = 13, stackable = 0,

costmoney = 1, bpwithitems = 1, countinbp = 20, bpid = 3940, cost = 30000,

itemcost = 0, itemamountcost = 0 }

}

-- End configuration --

-- Gets the itemname --
local item = items[param]

-- Checks if we can use that itemname --
if item then

-- Checks if it should cost money --
if item.costmoney == 1 then

-- Checks if the player has enough money --
if doPlayerRemoveMoney ( cid, item.cost )

== 1 then

-- Checks if its going to use a bp

with items--
if item.bpwithitems == 1 then



-- Sends the player a

message wich includes what he has bought and how much it cost --
doPlayerSendTextMessage (

cid, 24, 'You have bought a backpack with '..getItemNameById(item.id)..'

for '..item.cost..' golden pieces.' )

-- Gives the player the

items --
local bp = doPlayerAddItem

( cid, item.bpid, 1 )

-- starting a function so

it gives enough items and not just 1 --
for i = 1,item.countinbp do


doAddContainerItem(

bp, item.id, item.amount )

-- ends the for function --
end

-- what to do if it isn't going to

use a bp with items--
else

-- Checks if the item is

stackable --
if item.stackable == 0 then

-- Checks if the

amount is 1 --
if item.amount == 1

then

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.cost..' golden pieces.' )

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- What to do if

the amount is higher then 1 --
else

-- starting

a function so it gives enough items and not just 1 --
for i =

1,item.amount do

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- ends the

for function --
end

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.cost..' golden pieces.' )

-- Ends the amount

check -
end

elseif item.stackable == 1

then

-- Sends the player

a message wich includes what he has bought and how much it cost --


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.cost..' golden pieces.' )

-- Gives the player

the item --
doPlayerAddItem (

cid, item.id, item.amount )

-- Ends the stackable check

--
end

-- ends the bp with items check --
end

-- What to do when the player doesn't have

enough money --
else

-- Gives the player a message that

he doesn't have enough money --
doPlayerSendCancel ( cid, 'You need

at least '..item.cost..' golden coins to buy this item.' )

-- Shows an effect on the player --
doSendMagicEffect (

getPlayerPosition ( cid ), CONST_ME_POFF )

-- Ends the money check --
end

-- Checks if it should cost money --
elseif item.costmoney == 0 then

-- Checks if the player has enough amount

of the correct item --
if doPlayerRemoveItem ( cid, item.itemcost,

item.itemamountcost ) == 1 then

-- Checks if its going to use a bp

with items--
if item.bpwithitems == 1 then



-- Sends the player a

message wich includes what he has bought and how much it cost --
doPlayerSendTextMessage (

cid, 24, 'You have bought a backpack with '..getItemNameById(item.id)..'

for '..item.itemamountcost..'x a '..itemname..'.' )

-- Gives the player the

items --
local bp = doPlayerAddItem

( cid, item.bpid, 1 )

-- starting a function so

it gives enough items and not just 1 --
for i = 1,item.countinbp do


doAddContainerItem(

bp, item.id, item.amount )

-- ends the for function --
end

-- what to do if it isn't going to

use a bp with items--
else

-- Checks if the item is

stackable --
if item.stackable == 0 then

-- Checks if the

amount is 1 --
if item.amount == 1

then

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.itemamountcost..'x a '..itemname..'.' )

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- What to do if

the amount is higher then 1 --
else

-- starting

a function so it gives enough items and not just 1 --
for i =

1,item.amount do

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- ends the

for function --
end

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.itemamountcost..'x a '..itemname..'.' )

-- Ends the amount

check -
end

elseif item.stackable == 1

then

-- Gets the name of

the item --
itemname =

getItemName(item.itemcost)

-- Sends the player

a message wich includes what he has bought and how much it cost --


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.itemamountcost..'x a '..itemname..'.' )

-- Gives the player

the item --
doPlayerAddItem (

cid, item.id, item.amount )

-- Ends the stackable check

--
end

--ends the bp with items check --
end

-- What to do when the player doesn't have

the amount of the item --
else

-- Gets the name of the item --
itemname = getItemNameById (

item.itemcost )

-- Gives the player a message that

he doesn't have the amount of the item --
doPlayerSendCancel ( cid, 'You need

at least '..item.itemamountcost..'x a '..itemname..' to get this item.' )

-- Shows an effect on the player --
doSendMagicEffect (

getPlayerPosition ( cid ), CONST_ME_POFF )

-- Ends the item check --
end

-- Ends the moneycheck --
end

else

-- Sends the player a message wich includes items

he can buy --
doPlayerSendTextMessage ( cid, 24, 'You can buy the

following items:' )

-- Getting the all itemnames --
for item1 in pairs (items) do

-- Sends a message with each itemname and

price --
doPlayerSendTextMessage ( cid, 24, item1 )

-- Ends the for function--
end

-- ends the itemname check --
end

-- Ends the functions --
end

can anyone help me with the scrpit it has some error, eveytime i write something that isnt in the list it says "'Bp Drunkness" insted on (that's not in the list"
and also wen i say !list it gives me the list but also says ('Bp Drunkness')
 
wrapped code
-- Starting the function --
function onSay ( cid, words, param )

--Start configuration --

-- Items you can buy --
items =
{

['bp'] = { id = 1988, amount = 1, stackable = 0, costmoney = 1,

bpwithitems = 0, countinbp = 20, bpid = 3940, cost = 10, itemcost = 2472,

itemamountcost = 1 } ,
['aol'] = { id = 2173, amount = 1, stackable = 0, bpwithitems =

0, countinbp = 20, bpid = 3940,costmoney = 1, cost = 10000, itemcost =

2472, itemamountcost = 1 },
['bpsd'] = { id = 2268, amount = 100, stackable = 0, bpwithitems =

1, countinbp = 20, bpid = 2003, costmoney = 1, cost = 1000, itemcost =

2472, itemamountcost = 0 },
['food'] = { id = 2789, amount = 100, stackable = 1, costmoney =

1, bpwithitems = 0, countinbp = 20, bpid = 3940, cost = 100, itemcost =

2472, itemamountcost = 1 },
['Bp Drunkness'] = { id = 2267, amount = 13, stackable = 0,

costmoney = 1, bpwithitems = 1, countinbp = 20, bpid = 3940, cost = 30000,

itemcost = 0, itemamountcost = 0 }

}

-- End configuration --

-- Gets the itemname --
local item = items[param]

-- Checks if we can use that itemname --
if item then

-- Checks if it should cost money --
if item.costmoney == 1 then

-- Checks if the player has enough money --
if doPlayerRemoveMoney ( cid, item.cost )

== 1 then

-- Checks if its going to use a bp

with items--
if item.bpwithitems == 1 then



-- Sends the player a

message wich includes what he has bought and how much it cost --
doPlayerSendTextMessage (

cid, 24, 'You have bought a backpack with '..getItemNameById(item.id)..'

for '..item.cost..' golden pieces.' )

-- Gives the player the

items --
local bp = doPlayerAddItem

( cid, item.bpid, 1 )

-- starting a function so

it gives enough items and not just 1 --
for i = 1,item.countinbp do


doAddContainerItem(

bp, item.id, item.amount )

-- ends the for function --
end

-- what to do if it isn't going to

use a bp with items--
else

-- Checks if the item is

stackable --
if item.stackable == 0 then

-- Checks if the

amount is 1 --
if item.amount == 1

then

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.cost..' golden pieces.' )

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- What to do if

the amount is higher then 1 --
else

-- starting

a function so it gives enough items and not just 1 --
for i =

1,item.amount do

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- ends the

for function --
end

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.cost..' golden pieces.' )

-- Ends the amount

check -
end

elseif item.stackable == 1

then

-- Sends the player

a message wich includes what he has bought and how much it cost --


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.cost..' golden pieces.' )

-- Gives the player

the item --
doPlayerAddItem (

cid, item.id, item.amount )

-- Ends the stackable check

--
end

-- ends the bp with items check --
end

-- What to do when the player doesn't have

enough money --
else

-- Gives the player a message that

he doesn't have enough money --
doPlayerSendCancel ( cid, 'You need

at least '..item.cost..' golden coins to buy this item.' )

-- Shows an effect on the player --
doSendMagicEffect (

getPlayerPosition ( cid ), CONST_ME_POFF )

-- Ends the money check --
end

-- Checks if it should cost money --
elseif item.costmoney == 0 then

-- Checks if the player has enough amount

of the correct item --
if doPlayerRemoveItem ( cid, item.itemcost,

item.itemamountcost ) == 1 then

-- Checks if its going to use a bp

with items--
if item.bpwithitems == 1 then



-- Sends the player a

message wich includes what he has bought and how much it cost --
doPlayerSendTextMessage (

cid, 24, 'You have bought a backpack with '..getItemNameById(item.id)..'

for '..item.itemamountcost..'x a '..itemname..'.' )

-- Gives the player the

items --
local bp = doPlayerAddItem

( cid, item.bpid, 1 )

-- starting a function so

it gives enough items and not just 1 --
for i = 1,item.countinbp do


doAddContainerItem(

bp, item.id, item.amount )

-- ends the for function --
end

-- what to do if it isn't going to

use a bp with items--
else

-- Checks if the item is

stackable --
if item.stackable == 0 then

-- Checks if the

amount is 1 --
if item.amount == 1

then

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.itemamountcost..'x a '..itemname..'.' )

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- What to do if

the amount is higher then 1 --
else

-- starting

a function so it gives enough items and not just 1 --
for i =

1,item.amount do

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- ends the

for function --
end

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.itemamountcost..'x a '..itemname..'.' )

-- Ends the amount

check -
end

elseif item.stackable == 1

then

-- Gets the name of

the item --
itemname =

getItemName(item.itemcost)

-- Sends the player

a message wich includes what he has bought and how much it cost --


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.itemamountcost..'x a '..itemname..'.' )

-- Gives the player

the item --
doPlayerAddItem (

cid, item.id, item.amount )

-- Ends the stackable check

--
end

--ends the bp with items check --
end

-- What to do when the player doesn't have

the amount of the item --
else

-- Gets the name of the item --
itemname = getItemNameById (

item.itemcost )

-- Gives the player a message that

he doesn't have the amount of the item --
doPlayerSendCancel ( cid, 'You need

at least '..item.itemamountcost..'x a '..itemname..' to get this item.' )

-- Shows an effect on the player --
doSendMagicEffect (

getPlayerPosition ( cid ), CONST_ME_POFF )

-- Ends the item check --
end

-- Ends the moneycheck --
end

else

-- Sends the player a message wich includes items

he can buy --
doPlayerSendTextMessage ( cid, 24, 'You can buy the

following items:' )

-- Getting the all itemnames --
for item1 in pairs (items) do

-- Sends a message with each itemname and

price --
doPlayerSendTextMessage ( cid, 24, item1 )

-- Ends the for function--
end

-- ends the itemname check --
end

-- Ends the functions --
end

now can anyone help me?
 
-- Starting the function --
function onSay ( cid, words, param )

--Start configuration --

-- Items you can buy --
items =
{

['bp'] = { id = 1988, amount = 1, stackable = 0, costmoney = 1,

bpwithitems = 0, countinbp = 20, bpid = 3940, cost = 10, itemcost = 2472,

itemamountcost = 1 } ,
['aol'] = { id = 2173, amount = 1, stackable = 0, bpwithitems =

0, countinbp = 20, bpid = 3940,costmoney = 1, cost = 10000, itemcost =

2472, itemamountcost = 1 },
['bpsd'] = { id = 2268, amount = 100, stackable = 0, bpwithitems =

1, countinbp = 20, bpid = 2003, costmoney = 1, cost = 1000, itemcost =

2472, itemamountcost = 0 },
['food'] = { id = 2789, amount = 100, stackable = 1, costmoney =

1, bpwithitems = 0, countinbp = 20, bpid = 3940, cost = 100, itemcost =

2472, itemamountcost = 1 },
['Bp Drunkness'] = { id = 2267, amount = 13, stackable = 0,

costmoney = 1, bpwithitems = 1, countinbp = 20, bpid = 3940, cost = 30000,

itemcost = 0, itemamountcost = 0 }

}

-- End configuration --

-- Gets the itemname --
local item = items[param]

-- Checks if we can use that itemname --
if item then

-- Checks if it should cost money --
if item.costmoney == 1 then

-- Checks if the player has enough money --
if doPlayerRemoveMoney ( cid, item.cost )

== 1 then

-- Checks if its going to use a bp

with items--
if item.bpwithitems == 1 then



-- Sends the player a

message wich includes what he has bought and how much it cost --
doPlayerSendTextMessage (

cid, 24, 'You have bought a backpack with '..getItemNameById(item.id)..'

for '..item.cost..' golden pieces.' )

-- Gives the player the

items --
local bp = doPlayerAddItem

( cid, item.bpid, 1 )

-- starting a function so

it gives enough items and not just 1 --
for i = 1,item.countinbp do


doAddContainerItem(

bp, item.id, item.amount )

-- ends the for function --
end

-- what to do if it isn't going to

use a bp with items--
else

-- Checks if the item is

stackable --
if item.stackable == 0 then

-- Checks if the

amount is 1 --
if item.amount == 1

then

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.cost..' golden pieces.' )

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- What to do if

the amount is higher then 1 --
else

-- starting

a function so it gives enough items and not just 1 --
for i =

1,item.amount do

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- ends the

for function --
end

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.cost..' golden pieces.' )

-- Ends the amount

check -
end

elseif item.stackable == 1

then

-- Sends the player

a message wich includes what he has bought and how much it cost --


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.cost..' golden pieces.' )

-- Gives the player

the item --
doPlayerAddItem (

cid, item.id, item.amount )

-- Ends the stackable check

--
end

-- ends the bp with items check --
end

-- What to do when the player doesn't have

enough money --
else

-- Gives the player a message that

he doesn't have enough money --
doPlayerSendCancel ( cid, 'You need

at least '..item.cost..' golden coins to buy this item.' )

-- Shows an effect on the player --
doSendMagicEffect (

getPlayerPosition ( cid ), CONST_ME_POFF )

-- Ends the money check --
end

-- Checks if it should cost money --
elseif item.costmoney == 0 then

-- Checks if the player has enough amount

of the correct item --
if doPlayerRemoveItem ( cid, item.itemcost,

item.itemamountcost ) == 1 then

-- Checks if its going to use a bp

with items--
if item.bpwithitems == 1 then



-- Sends the player a

message wich includes what he has bought and how much it cost --
doPlayerSendTextMessage (

cid, 24, 'You have bought a backpack with '..getItemNameById(item.id)..'

for '..item.itemamountcost..'x a '..itemname..'.' )

-- Gives the player the

items --
local bp = doPlayerAddItem

( cid, item.bpid, 1 )

-- starting a function so

it gives enough items and not just 1 --
for i = 1,item.countinbp do


doAddContainerItem(

bp, item.id, item.amount )

-- ends the for function --
end

-- what to do if it isn't going to

use a bp with items--
else

-- Checks if the item is

stackable --
if item.stackable == 0 then

-- Checks if the

amount is 1 --
if item.amount == 1

then

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.itemamountcost..'x a '..itemname..'.' )

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- What to do if

the amount is higher then 1 --
else

-- starting

a function so it gives enough items and not just 1 --
for i =

1,item.amount do

-- Gives

the player the item --


doPlayerAddItem ( cid, item.id, 1 )

-- ends the

for function --
end

-- Sends

the player a message wich includes what he has bought and how much it cost

--


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.itemamountcost..'x a '..itemname..'.' )

-- Ends the amount

check -
end

elseif item.stackable == 1

then

-- Gets the name of

the item --
itemname =

getItemName(item.itemcost)

-- Sends the player

a message wich includes what he has bought and how much it cost --


doPlayerSendTextMessage ( cid, 24, 'You have bought '..item.amount..'

'..param..' for '..item.itemamountcost..'x a '..itemname..'.' )

-- Gives the player

the item --
doPlayerAddItem (

cid, item.id, item.amount )

-- Ends the stackable check

--
end

--ends the bp with items check --
end

-- What to do when the player doesn't have

the amount of the item --
else

-- Gets the name of the item --
itemname = getItemNameById (

item.itemcost )

-- Gives the player a message that

he doesn't have the amount of the item --
doPlayerSendCancel ( cid, 'You need

at least '..item.itemamountcost..'x a '..itemname..' to get this item.' )

-- Shows an effect on the player --
doSendMagicEffect (

getPlayerPosition ( cid ), CONST_ME_POFF )

-- Ends the item check --
end

-- Ends the moneycheck --
end

else

-- Sends the player a message wich includes items

he can buy --
doPlayerSendTextMessage ( cid, 24, 'You can buy the

following items:' )

-- Getting the all itemnames --
for item1 in pairs (items) do

-- Sends a message with each itemname and

price --
doPlayerSendTextMessage ( cid, 24, item1 )

-- Ends the for function--
end

-- ends the itemname check --
end

-- Ends the functions --
end
now can anyone one help me?
 
PHP:
local items = {
    ['bp'] = 
        {
            id = 1988, 
            amount = 1, 
            stackable = 0, 
            costmoney = 1,
            bpwithitems = 0, 
            countinbp = 20, 
            bpid = 3940, 
            cost = 10, 
            itemcost = 2472,
            itemamountcost = 1 
        },
    ['aol'] = 
        { 
            id = 2173, 
            amount = 1, 
            stackable = 0, 
            bpwithitems = 0, 
            countinbp = 20, 
            bpid = 3940,
            costmoney = 1, 
            cost = 10000, 
            itemcost = 2472, 
            itemamountcost = 1 
        },
    ['bpsd'] = 
        { 
            id = 2268, 
            amount = 100, 
            stackable = 0, 
            bpwithitems = 1, 
            countinbp = 20, 
            bpid = 2003, 
            costmoney = 1, 
            cost = 1000, 
            itemcost = 2472, 
            itemamountcost = 0 
        },
    ['food'] = 
        { 
            id = 2789, 
            amount = 100, 
            stackable = 1, 
            costmoney = 1, 
            bpwithitems = 0, 
            countinbp = 20, 
            bpid = 3940, 
            cost = 100, 
            itemcost = 2472, 
            itemamountcost = 1 
        },
    ['Bp Drunkness'] = 
        { 
            id = 2267, 
            amount = 13, 
            stackable = 0,
            costmoney = 1, 
            bpwithitems = 1, 
            countinbp = 20, 
            bpid = 3940,
            cost = 30000,
            itemcost = 0, 
            itemamountcost = 0
        }
    }

function onSay ( cid, words, param)
    local Continue = TRUE
    local item = items[param]
    if item then
        if item.costmoney == 1 then
            if doPlayerRemoveMoney (cid, item.cost) == FALSE then
                Continue = FALSE
            end
        end
        if Continue == TRUE then
            if item.bpwithitems == 1 then
                doPlayerSendTextMessage (cid, 24, 'You have bought a backpack with '..getItemNameById(item.id)..'for '..item.cost..' golden pieces.')
                local bp = doPlayerAddItem(cid, item.bpid, 1)
                for i = 1, item.countinbp do
                    doAddContainerItem(bp, item.id, item.amount)
                end
            else
                if item.stackable == 0 then
                    if item.amount == 1 then
                        doPlayerSendTextMessage (cid, 24, 'You have bought '..item.amount..' '..param..' for '..item.cost..' golden pieces.')
                        doPlayerAddItem (cid, item.id, 1)
                    else
                        for i = 1, item.amount do
                            doPlayerAddItem (cid, item.id, 1)
                        end
                        doPlayerSendTextMessage (cid, 24, 'You have bought '..item.amount..' '..param..' for '..item.cost..' golden pieces.')
                    end
                elseif item.stackable == 1 then
                    doPlayerSendTextMessage (cid, 24, 'You have bought '..item.amount..' '..param..' for '..item.cost..' golden pieces.')
                    doPlayerAddItem(cid, item.id, item.amount)
                end
            end
        else
            doPlayerSendCancel(cid, 'You need at least '..item.cost..' golden coins to buy this item.')
            doSendMagicEffect(getPlayerPosition(cid ), CONST_ME_POFF)
        end
    else
        doPlayerSendCancel(cid, 'Invalid item.')
    end
    return TRUE
end

who have done that shit o_O
 
PHP:
local items = {
    ['bp'] = 
        {
            id = 1988, 
            amount = 1, 
            stackable = 0, 
            costmoney = 1,
            bpwithitems = 0, 
            countinbp = 20, 
            bpid = 3940, 
            cost = 10, 
            itemcost = 2472,
            itemamountcost = 1 
        },
    ['aol'] = 
        { 
            id = 2173, 
            amount = 1, 
            stackable = 0, 
            bpwithitems = 0, 
            countinbp = 20, 
            bpid = 3940,
            costmoney = 1, 
            cost = 10000, 
            itemcost = 2472, 
            itemamountcost = 1 
        },
    ['bpsd'] = 
        { 
            id = 2268, 
            amount = 100, 
            stackable = 0, 
            bpwithitems = 1, 
            countinbp = 20, 
            bpid = 2003, 
            costmoney = 1, 
            cost = 1000, 
            itemcost = 2472, 
            itemamountcost = 0 
        },
    ['food'] = 
        { 
            id = 2789, 
            amount = 100, 
            stackable = 1, 
            costmoney = 1, 
            bpwithitems = 0, 
            countinbp = 20, 
            bpid = 3940, 
            cost = 100, 
            itemcost = 2472, 
            itemamountcost = 1 
        },
    ['Bp Drunkness'] = 
        { 
            id = 2267, 
            amount = 13, 
            stackable = 0,
            costmoney = 1, 
            bpwithitems = 1, 
            countinbp = 20, 
            bpid = 3940,
            cost = 30000,
            itemcost = 0, 
            itemamountcost = 0
        }
    }

function onSay ( cid, words, param)
    local Continue = TRUE
    local item = items[param]
    if item then
        if item.costmoney == 1 then
            if doPlayerRemoveMoney (cid, item.cost) == FALSE then
                Continue = FALSE
            end
        end
        if Continue == TRUE then
            if item.bpwithitems == 1 then
                doPlayerSendTextMessage (cid, 24, 'You have bought a backpack with '..getItemNameById(item.id)..'for '..item.cost..' golden pieces.')
                local bp = doPlayerAddItem(cid, item.bpid, 1)
                for i = 1, item.countinbp do
                    doAddContainerItem(bp, item.id, item.amount)
                end
            else
                if item.stackable == 0 then
                    if item.amount == 1 then
                        doPlayerSendTextMessage (cid, 24, 'You have bought '..item.amount..' '..param..' for '..item.cost..' golden pieces.')
                        doPlayerAddItem (cid, item.id, 1)
                    else
                        for i = 1, item.amount do
                            doPlayerAddItem (cid, item.id, 1)
                        end
                        doPlayerSendTextMessage (cid, 24, 'You have bought '..item.amount..' '..param..' for '..item.cost..' golden pieces.')
                    end
                elseif item.stackable == 1 then
                    doPlayerSendTextMessage (cid, 24, 'You have bought '..item.amount..' '..param..' for '..item.cost..' golden pieces.')
                    doPlayerAddItem(cid, item.id, item.amount)
                end
            end
        else
            doPlayerSendCancel(cid, 'You need at least '..item.cost..' golden coins to buy this item.')
            doSendMagicEffect(getPlayerPosition(cid ), CONST_ME_POFF)
        end
    else
        doPlayerSendCancel(cid, 'Invalid item.')
    end
    return TRUE
end

who have done that shit o_O

you rox thanks ;)
 
Back
Top