Ir para conteúdo
  • Cadastre-se

Shop Entrega Storage pra o Player


Posts Recomendados

colokei no meu shop system pra vende storange que é uma magia. quando o player compra no shop do site libera uma magia no jogo. mas quando eu compro n chega nds so chega o vip.

 

eu add isso no globalevents :

-- ### 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 ###
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
full_weight = getItemWeightById(itemtogive_id, 1)
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 OTS 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 .. ";")
doPlayerSave(cid)
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> The item '.. add_item_name ..' << that you just bought on the website couldnt be added. Han error has ocurred, please wait '.. SQL_interval ..' seconds.. Shop ID: '.. id ..'')
end
else
doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> The item '.. add_item_name ..' << that you just bought on the website couldnt be added. Han error has ocurred, please wait '.. SQL_interval ..' seconds.. Shop ID: '.. id ..'')
end
end
if not(result_plr:next()) then
break
end
end
result_plr:free()
end
return TRUE
end

 

iae tag:

 

 

o jogador n receber espero varios tempo e nds. alguem pra ajuda

Editado por Admnwso (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • 2 weeks later...

seu shops ta funcionando normal addons e mouts pois to com problema no storange deles

eu não coloquei nem pra vende mounts e de addons.

-- Topico --

alguém ajuda porfavor. Eu coloquei algumas magia só pode ser liberado no shop.

Link para o post
Compartilhar em outros sites
  • 7 months later...
  • 3 years later...
-- ### CONFIG ###
-- message to player "type", if delivery of item debugs client, it can be because of undefinied type (type that does not exist in your server LUA)
SHOP_MSG_TYPE = MESSAGE_EVENT_ADVANCE
-- ### END OF CONFIG ###

function onThink(interval)
	local resultId = db.storeQuery("SELECT * FROM z_ots_guildcomunication")
	if resultId ~= false then
		repeat
			local transactionId = result.getDataInt(resultId, "id")
			local player = Player(result.getDataString(resultId, "name"))

			if player then
				local itemId = tonumber(result.getDataString(resultId, "param1"))
				local itemCount = tonumber(result.getDataString(resultId, "param2"))
				local containerId = tonumber(result.getDataString(resultId, "param3"))
				local containerItemsInsideCount = tonumber(result.getDataString(resultId, "param4"))
				local shopOfferType = result.getDataString(resultId, "param5")
				local shopOfferName = result.getDataString(resultId, "param6")

				local item = Game.createItem(itemid, count)
				if item then
					return item:getUniqueId()
				end


				-- DELIVER ITEM
				if shopOfferType == 'item' then
					local newItem = Game.createItem(itemId, itemCount)
					--  item does not exist, wrong id OR count
					if not newItem then
						player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
						print('ERROR! Website Shop (' .. player:getName() .. ') - cannot create item - invalid item ID OR count - ITEM ID: ' .. itemId .. ', ITEM COUNT: ' .. itemCount)
						return true
					end

					-- get player store inbox as container, so we can add item to it
					local playerStoreInbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
					-- cannot open Store Inbox, report problem
					if not playerStoreInbox then
						player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
						print('ERROR! Website Shop (' .. player:getName() .. ') - cannot open player "Store Inbox" - it is not supported in your server OR variable "CONST_SLOT_STORE_INBOX" is not definied in LUA')
						return true
					end

					-- add container with items to Store Inbox
					receivedItemStatus = playerStoreInbox:addItemEx(newItem)

					if type(receivedItemStatus) == "number" and receivedItemStatus == RETURNVALUE_NOERROR then
						player:sendTextMessage(SHOP_MSG_TYPE, 'You received ' .. shopOfferName .. ' from Website Shop. You can find your item in STORE INBOX (under EQ).')
						db.asyncQuery("DELETE FROM `z_ots_guildcomunication` WHERE `id` = " .. transactionId)
						db.asyncQuery("UPDATE `z_shopguild_history_item` SET `trans_state`= 'realized', `trans_real`=" .. os.time() .. " WHERE `id` = " .. transactionId)
					else
						player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
						print('ERROR! Website Shop (' .. player:getName() .. ') - cannot add item to STORE INBOX - unknown reason, is it\'s size limited and it is full? - ITEM ID: ' .. itemId .. ', ITEM COUNT: ' .. itemCount)
					end
				

					-- DELIVER CONTAINER
				elseif shopOfferType == 'container' then
					local newContainer = Game.createItem(containerId, 1)
					if not newContainerUID or not Container(newContainer.uid) then
						player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
						print('ERROR! Website Shop (' .. player:getName() .. ') - cannot create container - invalid container ID - CONTAINER ID:' .. containerId)
						return true
					end

					-- add items to container
					for i = 1, containerItemsInsideCount do
						-- create new item
						local newItem = Game.createItem(itemId, itemCount)
						--  item does not exist, wrong id OR count
						if not newItem then
							player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
							print('ERROR! Website Shop (' .. player:getName() .. ') - cannot create item - invalid item ID OR count - ITEM ID: ' .. itemId .. ', ITEM COUNT: ' .. itemCount)
							return true
						end

						-- add item to container
						local addItemToContainerResult = newContainer:addItemEx(newItem)
						-- report error if it's not possible to add item to container
						if type(addItemToContainerResult) ~= "number" or addItemToContainerResult ~= RETURNVALUE_NOERROR then
							player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
							print('ERROR! Website Shop (' .. player:getName() .. ') - cannot add item to container - item is not pickable OR variable "RETURNVALUE_NOERROR" is not definied in LUA - ITEM ID: ' .. itemId .. ', ITEM COUNT: ' .. itemCount)
							return true
						end
					end

					-- get player store inbox as container, so we can add item to it
					local playerStoreInbox = player:getSlotItem(CONST_SLOT_STORE_INBOX)
					-- cannot open Store Inbox, report problem
					if not playerStoreInbox then
						player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
						print('ERROR! Website Shop (' .. player:getName() .. ') - cannot open player "Store Inbox" - it is not supported in your server OR variable "CONST_SLOT_STORE_INBOX" is not definied in LUA')
						return true
					end
					-- add container with items to Store Inbox
					receivedItemStatus = playerStoreInbox:addItemEx(newContainer)

					if type(receivedItemStatus) == "number" and receivedItemStatus == RETURNVALUE_NOERROR then
						player:sendTextMessage(SHOP_MSG_TYPE, 'You received ' .. shopOfferName .. ' from Website Shop. You can find your item in STORE INBOX (under EQ).')
						db.asyncQuery("DELETE FROM `z_ots_guildcomunication` WHERE `id` = " .. transactionId)
						db.asyncQuery("UPDATE `z_shopguild_history_item` SET `trans_state`= 'realized', `trans_real`=" .. os.time() .. " WHERE `id` = " .. transactionId)
					else
						player:sendTextMessage(SHOP_MSG_TYPE, 'Website Shop bugged. Contact with administrator! Error is visible in server console.')
						print('ERROR! Website Shop (' .. player:getName() .. ') - cannot add container with items to STORE INBOX - unknown reason, is it\'s size limited and it is full? - ITEM ID: ' .. itemId .. ', ITEM COUNT: ' .. itemCount .. ', CONTAINER ID:' .. containerId .. ', ITEMS IN CONTAINER COUNT:' .. containerItemsInsideCount)
					end

					-- DELIVER YOUR CUSTOM THINGS
				elseif shopOfferType == 'mounts' then -- addon, mount etc.
		        if(add_item_type == 'mounts') then
				local player = Player(cid)
				if (getPlayerStorageValue(cid,itemtogive_id) == -1) then
				doPlayerAddMount(cid, itemtogive_id)
				setPlayerStorageValue(cid,itemtogive_id,1)
				doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYDAMAGE)
				doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received '.. add_item_name ..' from Th3 Insanity Shop.')
				db.query("DELETE FROM `z_ots_guildcomunication` WHERE `id` = " .. id .. ";")
                                db.query("UPDATE `z_shopguild_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
				else
				doPlayerSendTextMessage(cid,25,"You Already have this Mount.")
				end
				return TRUE
				
				end		
			end
		end
		until not result.next(resultId)
		result.free(resultId)
	end

	return true
end

ta ai o scripter para entrega os items addons e mount testado ?  by: Miguel Oliveira

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo