function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerMoney(cid) >= 20000 then
doPlayerRemoveMoney(cid,20000)
doPlayerAddItem(cid,9020,20)
doSendMagicEffect(getPlayerPosition(cid), 13)
else
doPlayerSendTextMessage(cid,19,"You need 20k to buy an tokens.")
doSendMagicEffect(getPlayerPosition(cid), 2)
end
return TRUE
end
<action actionid="9020" script="token.lua"/>
local t = {
[1000] = {{3721, 1}, {9020, 1}}
--[actionid] = {{item, count}, {tokensid, count}}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[getItemAttribute(item.uid, 'aid')]
if doPlayerRemoveItem(cid, v[2][1], v[2][2]) then
doPlayerGiveItem(cid, v[1][1], v[1][2])
else
doPlayerSendCancel(cid, "Sorry, you need "..v[2][2].." tokens to buy this item!")
end
return TRUE
end
local t = {
[1000] = {{3721, 1}, {9020, 1}},
[1000] = {{371, 1}, {9020, 1}}
--[actionid] = {{item, count}, {tokensid, count}}
}
fuction onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[getItemAttribute(item.uid, 'aid')
if doPlayerRemoveItem(cid, v[2][1], v[2][1]) then
doPlayerGiveItem(cid, v[1][1], v[1][2])
else
doPlayerSendCancel(cid, "Sorry, you need "..v[2][2].." tokens to buy this item!")
end
return TRUE
end
local t = {
[[COLOR="#0000FF"][B]1000[/B][/COLOR]] = {{[COLOR="#008000"][B]3721[/B][/COLOR], [COLOR="#FFA500"][B]1[/B][/COLOR]}, {[COLOR="#FF0000"][B]9020[/B][/COLOR], [B]1[/B]}}
--[[B][COLOR="#0000FF"]actionid[/COLOR][/B]] = {{[COLOR="#008000"][B]item[/B][/COLOR],[B][COLOR="#FFA500"] count[/COLOR][/B]}, {[COLOR="#FF0000"][B]tokensid[/B][/COLOR], [B]count[/B]}}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[getItemAttribute(item.uid, 'aid')]
if doPlayerRemoveItem(cid, v[2][1], v[2][2]) then
doPlayerGiveItem(cid, v[1][1], v[1][2])
else
doPlayerSendCancel(cid, "Sorry, you need "..v[2][2].." tokens to buy this item!")
end
return TRUE
end
[Error - LuaScriptInterface::loadFile] data/actions/scripts/donshop/first.lua:5: '=' expected near 'onUse'
[Warning - Event::loadScript] Cannot load script (data/actions/scripts/donshop/first.lua)
data/actions/scripts/donshop/first.lua:5: '=' expected near 'onUse'
local t = {
[5100] = {{2500, 1}, {9020, 10}}
--[actionid] = {{item, count}, {tokensid, count}}
}
fuction onUse(cid, item, fromPosition, itemEx, toPosition)
local v = t[getItemAttribute(item.uid, 'aid')
if doPlayerRemoveItem(cid, v[2][1], v[2][1]) then
doPlayerGiveItem(cid, v[1][1], v[1][2])
else
doPlayerSendCancel(cid, "Sorry, you need "..v[2][2].." tokens to buy this item!")
end
return TRUE
end
thanks J.Dre!
<action actionid="1337" event="script" value="script.lua"/>
local SHOP = {
[1337] = {
i = {7898, 1},
c = 10
},
[1338] = {
i = {7898, 1},
c = 10
},
}
local k = 0
local result = ""
function onUse(cid, item, fromPosition, itemEx, toPosition)
local t = SHOP[item.actionid]
if t then
if getPlayerItemCount(cid, 9020) >= t.c then
k = doCreateItemEx(t.i[1], t.i[2] or 1)
if doPlayerAddItemEx(cid, k, false) ~= RETURNVALUE_NOERROR then
result = "You cannot carry this item."
else
doPlayerRemoveItem(cid, 9020, t.c)
result = "You have found a " .. getItemName(k) .. "."
doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
end
else
result = "You do not have enough tokens."
end
end
return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945), doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, result), true
end
I know it's already solved but I fixed the script, forgot to add ] and fixed a little typo