Tudo bem galera? preciso de ajuda, coloquei em meu shop no site para vender as outfits mas não estou conseguindo fazer o script
para quando o player comprar no site ir pra ele em game..
Sou noob em lua, alguem poderia me ajudar?? (o script tentei copiar de outro servidor e encaixar no meu, mas o código completo do servidor não reconheceu no meu distro ai tentei fazer uma gambiarra usando o meu mesmo e adicionando somente o código do outfit
Código que estou tentando fazer:
Erros no distro:
[Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/shop.lua)
[20:34:38.306] data/globalevents/scripts/shop.lua:92: 'end' expected (to close 'function' at line 11) near '<eof>'
-- ### CONFIG ###
-- message send to player by script "type" (types you can check in "global.lua")
SHOP_MSG_TYPE = 19
-- time (in seconds) between connections to SQL database by shop script
SQL_interval = 30
-- ### END OF CONFIG ###
--- ### Outfits List ###
local femaleOutfits = {["citizen"] = 136, ["hunter"] = 137, ["knight"] = 139, ["noblewoman"]=140, ["summoner"]=141, ["warrior"]=142, ["barbarian"]=147, ["druid"]=148, ["wizard"]=149, ["oriental"]=150, ["pirate"]=155, ["assassin"]=156, ["beggar"]=157, ["shaman"]=158, ["norsewoman"]=252, ["nightmare"]=269, ["jester"]=270, ["brotherhood"]=279, ["demonhunter"]=288, ["yalaharian"]=324, ["warmaster"]=336}
local maleOutfits = {["citizen"]=128, ["hunter"]=129, ["mage"]=130, ["knight"]=131, ["nobleman"]=132,["summoner"]=133, ["warrior"]=134, ["barbarian"]=143, ["druid"]=144, ["oriental"]=146, ["pirate"]=151, ["assassin"]=152, ["beggar"]=153, ["shaman"]=154, ["norsewoman"]=251, ["nightmare"]=268, ["jester"]=273, ["brotherhood"]=278, ["demonhunter"]=289, ["yalaharian"]=325, ["warmaster"]=335, ["wayfarer"]=366}
function onThink(interval, lastExecution)
local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';")
if(result_plr:getID() ~= -1) then
while(true) do
id = tonumber(result_plr:getDataInt("id"))
action = tostring(result_plr:getDataString("action"))
delete = tonumber(result_plr:getDataInt("delete_it"))
cid = getCreatureByName(tostring(result_plr:getDataString("name")))
if isPlayer(cid) == TRUE then
local itemtogive_id = tonumber(result_plr:getDataInt("param1"))
local itemtogive_count = tonumber(result_plr:getDataInt("param2"))
local container_id = tonumber(result_plr:getDataInt("param3"))
local container_count = tonumber(result_plr:getDataInt("param4"))
local add_item_type = tostring(result_plr:getDataString("param5"))
local add_item_name = tostring(result_plr:getDataString("param6"))
local received_item = 0
local full_weight = 0
if add_item_type == 'container' then
container_weight = getItemWeightById(container_id, 1)
if isItemRune(itemtogive_id) == TRUE then
items_weight = container_count * getItemWeightById(itemtogive_id, 1)
else
items_weight = container_count * getItemWeightById(itemtogive_id, itemtogive_count)
end
full_weight = items_weight + container_weight
else
full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
if isItemRune(itemtogive_id) == TRUE then
full_weight = getItemWeightById(itemtogive_id, 1)
else
full_weight = getItemWeightById(itemtogive_id, itemtogive_count)
end
end
local free_cap = getPlayerFreeCap(cid)
if full_weight <= free_cap then
if add_item_type == 'container' then
local new_container = doCreateItemEx(container_id, 1)
local iter = 0
while iter ~= container_count do
doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
iter = iter + 1
end
received_item = doPlayerAddItemEx(cid, new_container)
else
local new_item = doCreateItemEx(itemtogive_id, itemtogive_count)
received_item = doPlayerAddItemEx(cid, new_item)
end
if received_item == RETURNVALUE_NOERROR then
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from ProTibia shop.')
db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from ProTibia shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.')
end
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from ProTibia shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.')
end
if(action == 'give_outfit') then
if outfit_name ~= "" and maleOutfits[outfit_name] and femaleOutfits[outfit_name] then
local add_outfit = getPlayerSex(cid) == 0 and femaleOutfits[outfit_name][1] or maleOutfits[outfit_name][1]
if not canPlayerWearOutfit(cid, add_outfit, 3) then
db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS)
doPlayerAddOutfit(cid, add_outfit, 3)
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, "You received the outfit " .. add_item_name .. " of our Shop Online.")
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, "You already have this outfit. Your coins were returned, thank you.")
db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. coins .. " WHERE `id` = " .. getAccountNumberByPlayerName(cid) .. ";")
end
end
end
if not(result_plr:next()) then
break
end
end
result_plr:free()
end
return TRUE
end
Pergunta
Rodrigo94 0
Tudo bem galera? preciso de ajuda, coloquei em meu shop no site para vender as outfits mas não estou conseguindo fazer o script
para quando o player comprar no site ir pra ele em game..
Sou noob em lua, alguem poderia me ajudar?? (o script tentei copiar de outro servidor e encaixar no meu, mas o código completo do servidor não reconheceu no meu distro ai tentei fazer uma gambiarra usando o meu mesmo e adicionando somente o código do outfit
Código que estou tentando fazer:
Erros no distro:
[Warning - Event::loadScript] Cannot load script (data/globalevents/scripts/shop.lua)
[20:34:38.306] data/globalevents/scripts/shop.lua:92: 'end' expected (to close 'function' at line 11) near '<eof>'
-- ### CONFIG ### -- message send to player by script "type" (types you can check in "global.lua") SHOP_MSG_TYPE = 19 -- time (in seconds) between connections to SQL database by shop script SQL_interval = 30 -- ### END OF CONFIG ### --- ### Outfits List ### local femaleOutfits = {["citizen"] = 136, ["hunter"] = 137, ["knight"] = 139, ["noblewoman"]=140, ["summoner"]=141, ["warrior"]=142, ["barbarian"]=147, ["druid"]=148, ["wizard"]=149, ["oriental"]=150, ["pirate"]=155, ["assassin"]=156, ["beggar"]=157, ["shaman"]=158, ["norsewoman"]=252, ["nightmare"]=269, ["jester"]=270, ["brotherhood"]=279, ["demonhunter"]=288, ["yalaharian"]=324, ["warmaster"]=336} local maleOutfits = {["citizen"]=128, ["hunter"]=129, ["mage"]=130, ["knight"]=131, ["nobleman"]=132,["summoner"]=133, ["warrior"]=134, ["barbarian"]=143, ["druid"]=144, ["oriental"]=146, ["pirate"]=151, ["assassin"]=152, ["beggar"]=153, ["shaman"]=154, ["norsewoman"]=251, ["nightmare"]=268, ["jester"]=273, ["brotherhood"]=278, ["demonhunter"]=289, ["yalaharian"]=325, ["warmaster"]=335, ["wayfarer"]=366} function onThink(interval, lastExecution) local result_plr = db.getResult("SELECT * FROM z_ots_comunication WHERE `type` = 'login';") if(result_plr:getID() ~= -1) then while(true) do id = tonumber(result_plr:getDataInt("id")) action = tostring(result_plr:getDataString("action")) delete = tonumber(result_plr:getDataInt("delete_it")) cid = getCreatureByName(tostring(result_plr:getDataString("name"))) if isPlayer(cid) == TRUE then local itemtogive_id = tonumber(result_plr:getDataInt("param1")) local itemtogive_count = tonumber(result_plr:getDataInt("param2")) local container_id = tonumber(result_plr:getDataInt("param3")) local container_count = tonumber(result_plr:getDataInt("param4")) local add_item_type = tostring(result_plr:getDataString("param5")) local add_item_name = tostring(result_plr:getDataString("param6")) local received_item = 0 local full_weight = 0 if add_item_type == 'container' then container_weight = getItemWeightById(container_id, 1) if isItemRune(itemtogive_id) == TRUE then items_weight = container_count * getItemWeightById(itemtogive_id, 1) else items_weight = container_count * getItemWeightById(itemtogive_id, itemtogive_count) end full_weight = items_weight + container_weight else full_weight = getItemWeightById(itemtogive_id, itemtogive_count) if isItemRune(itemtogive_id) == TRUE then full_weight = getItemWeightById(itemtogive_id, 1) else full_weight = getItemWeightById(itemtogive_id, itemtogive_count) end end local free_cap = getPlayerFreeCap(cid) if full_weight <= free_cap then if add_item_type == 'container' then local new_container = doCreateItemEx(container_id, 1) local iter = 0 while iter ~= container_count do doAddContainerItem(new_container, itemtogive_id, itemtogive_count) iter = iter + 1 end received_item = doPlayerAddItemEx(cid, new_container) else local new_item = doCreateItemEx(itemtogive_id, itemtogive_count) received_item = doPlayerAddItemEx(cid, new_item) end if received_item == RETURNVALUE_NOERROR then doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from ProTibia shop.') db.executeQuery("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";") db.executeQuery("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";") else doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from ProTibia shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.') end else doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from ProTibia shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.') end if(action == 'give_outfit') then if outfit_name ~= "" and maleOutfits[outfit_name] and femaleOutfits[outfit_name] then local add_outfit = getPlayerSex(cid) == 0 and femaleOutfits[outfit_name][1] or maleOutfits[outfit_name][1] if not canPlayerWearOutfit(cid, add_outfit, 3) then db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";") doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS) doPlayerAddOutfit(cid, add_outfit, 3) doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, "You received the outfit " .. add_item_name .. " of our Shop Online.") else doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, "You already have this outfit. Your coins were returned, thank you.") db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";") db.query("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. coins .. " WHERE `id` = " .. getAccountNumberByPlayerName(cid) .. ";") end end end if not(result_plr:next()) then break end end result_plr:free() end return TRUE end
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados