Ir para conteúdo

Featured Replies

Postado

tenta esse script

    -- ### CONFIG ###
    -- message send to player by script "type" (types you can check in "global.lua")
    SHOP_MSG_TYPE = 17
    -- time (in seconds) between connections to SQL database by shop script
    SQL_interval = 30
    -- ### END OF CONFIG ###
    SQL_COMUNICATION_INTERVAL = SQL_interval * 1000
    function onLogin(cid)
    if(InitShopComunication == 0) then
    local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, {})
    InitShopComunication = eventServ
    end
    registerCreatureEvent(cid, "PlayerDeath")
    return TRUE
    end
     
    function sql_communication(parameters)
    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 = getPlayerByName(tostring(result_plr:getDataString("name")))
    if isPlayer(cid) == TRUE then
    if action == 'give_item' 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 b_head_slot = getPlayerSlotItem(cid, 1)
    local b_necklace_slot = getPlayerSlotItem(cid, 2)
    local b_backpack_slot = getPlayerSlotItem(cid, 3)
    local b_armor_slot = getPlayerSlotItem(cid, 4)
    local b_right_hand = getPlayerSlotItem(cid, 5)
    local b_left_hand = getPlayerSlotItem(cid, 6)
    local b_legs_slot = getPlayerSlotItem(cid, 7)
    local b_feet_slot = getPlayerSlotItem(cid, 8)
    local b_ring_slot = getPlayerSlotItem(cid, 9)
    local b_arrow_slot = getPlayerSlotItem(cid, 10)
    if b_arrow_slot.itemid == 0 or (b_left_hand.itemid == 0 and b_right_hand.itemid == 0) then
    local full_weight = 0
    if add_item_type == 'container' then
    container_weight = getItemWeight(container_id, 1)
    items_weight = container_count * getItemWeight(itemtogive_id, itemtogive_count)
    full_weight = items_weight + container_weight
    else
    full_weight = getItemWeight(itemtogive_id, itemtogive_count)
    end
    local free_cap = getPlayerFreeCap(cid)
    if full_weight <= free_cap then
    if add_item_type == 'container' then
    local new_container = doCreateItemEx(container_id)
    local iter = 0
    while iter ~= container_count do
    doAddContainerItem(new_container, itemtogive_id, itemtogive_count)
    iter = iter + 1
    end
    doPlayerAddItemEx(cid, new_container)
    itemtogive_id = container_id
    else
    local addeditem = doPlayerAddItem(cid, itemtogive_id, itemtogive_count)
    end
    local head_slot = getPlayerSlotItem(cid, 1)
    local necklace_slot = getPlayerSlotItem(cid, 2)
    local backpack_slot = getPlayerSlotItem(cid, 3)
    local armor_slot = getPlayerSlotItem(cid, 4)
    local right_hand = getPlayerSlotItem(cid, 5)
    local left_hand = getPlayerSlotItem(cid, 6)
    local legs_slot = getPlayerSlotItem(cid, 7)
    local feet_slot = getPlayerSlotItem(cid, 8)
    local ring_slot = getPlayerSlotItem(cid, 9)
    local arrow_slot = getPlayerSlotItem(cid, 10)
    if ring_slot.itemid == itemtogive_id or feet_slot.itemid == itemtogive_id or legs_slot.itemid == itemtogive_id or armor_slot.itemid == itemtogive_id or necklace_slot.itemid == itemtogive_id or head_slot.itemid == itemtogive_id or arrow_slot.itemid == itemtogive_id or left_hand.itemid == itemtogive_id or right_hand.itemid == itemtogive_id or backpack_slot.itemid == itemtogive_id then
    if b_ring_slot.uid ~= ring_slot.uid or b_feet_slot.uid ~= feet_slot.uid or b_legs_slot.uid ~= legs_slot.uid or b_armor_slot.uid ~= armor_slot.uid or b_necklace_slot.uid ~= necklace_slot.uid or b_head_slot.uid ~= head_slot.uid or b_backpack_slot.uid ~= backpack_slot.uid or b_right_hand.uid ~= right_hand.uid or b_left_hand.uid ~= left_hand.uid or b_arrow_slot.uid ~= arrow_slot.uid then
    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS shop. You should re-login now to become sure your new item will not disappear if any error occur.')
    db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
    db.query("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 OTS shop not added. Unknown error occured. Wait about '.. SQL_interval ..' seconds. If error will occur again contact with admin. Error item ID is: '.. id ..'')
    end
    else
    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop not added. Unknown error occured. Wait about '.. SQL_interval ..' seconds. If error will occur again contact with admin. Error item ID is: '.. id ..'')
    end
    else
    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot or give to friend and wait about '.. SQL_interval ..' seconds to get it.')
    end
    else
    doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please take items from both hands or item from arrow slot and wait about '.. SQL_interval ..' seconds to get it.')
    end
    end
    end
    if not(result_plr:next()) then
    break
    end
    end
    result_plr:free()
    end
    local eventServ = addEvent(sql_communication, SQL_COMUNICATION_INTERVAL, parameters)
    end

@EDIT
copie todo o código acima e rode esse script na sua DB:

CREATE TABLE IF NOT EXISTS `z_ots_comunication` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`type` varchar(255) NOT NULL,
`action` varchar(255) NOT NULL,
`param1` varchar(255) NOT NULL,
`param2` varchar(255) NOT NULL,
`param3` varchar(255) NOT NULL,
`param4` varchar(255) NOT NULL,
`param5` varchar(255) NOT NULL,
`param6` varchar(255) NOT NULL,
`param7` varchar(255) NOT NULL,
`delete_it` int(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

Editado por Patrick Jean (veja o histórico de edições)

Ajudei??? Rep + ae! :D

gtYFjO8.gif

 

1iiu7Gw.png

Facebook: Béria Alternative Server

  • Respostas 16
  • Visualizações 1.6k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Sim, o erro é na hora de executar a query para confimar a entrega do item. Tenta deletar essa linha aqui no seu 100-compat.lua db.executeQuery = db.query Se não funcionar.. tenta usar essa lib: lib

  • mudou os db.executeQuery para db.query??   Se não funcionou denovo, tente usar esse... -- ### CONFIG ### -- time (in seconds) between connections to SQL database by shop script SQL_interval = 30

  • Tenta com esse:   local SHOP_MSG_TYPE = MESSAGE_STATUS_CONSOLE_RED local SQL_interval = 30 function generateSerial() --local lettersUsedToGenerateHash = "AaBbCcDdEeFfGgHhIiJjKkLlMmOoPpQqRrSsTtUu

Posted Images

Postado
  • Autor

Esse script que Você mando o item não chega na conta.

 

@EDIT

 

Eu ja tenho essa table criada na minha database:z_ots_comunication

Editado por matheuskc (veja o histórico de edições)

Postado

mudou os db.executeQuery para db.query??

 

Se não funcionou denovo, tente usar esse...

-- ### CONFIG ###
-- 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.storeQuery("SELECT * FROM z_ots_comunication")
    if result_plr ~= false then
        repeat
            local id = tonumber(result.getDataInt(result_plr, "id"))
            local action = tostring(result.getDataString(result_plr, "action"))
            local delete = tonumber(result.getDataInt(result_plr, "delete_it"))
            local player = Player(tostring(result.getDataString(result_plr, "name")))
            if player then
                local itemtogive_id = tonumber(result.getDataInt(result_plr, "param1"))
                local itemtogive_count = tonumber(result.getDataInt(result_plr, "param2"))
                local container_id = tonumber(result.getDataInt(result_plr, "param3"))
                local container_count = tonumber(result.getDataInt(result_plr, "param4"))
                local add_item_type = tostring(result.getDataString(result_plr, "param5"))
                local add_item_name = tostring(result.getDataString(result_plr, "param6"))
                local received_item = 0
                local full_weight = 0
        local itemType = ItemType(itemtogive_id)
                if add_item_type == 'container' then
                    if itemType:isRune() then
                        items_weight = container_count * itemType:getWeight()
                    else
                        items_weight = container_count * itemType:getWeight(itemtogive_count)
                    end
                    full_weight = items_weight + ItemType(container_id):getWeight()
                else
                    if itemType:isRune() then
                        full_weight = itemType:getWeight()
                    else
                        full_weight = itemType:getWeight(itemtogive_count)
                    end
                end
                local free_cap = player:getFreeCapacity()
                if full_weight <= free_cap then
                    if add_item_type == 'container' then
                        local new_container = Game.createItem(container_id, 1)
                        local iter = 0
                        while iter ~= container_count do
                            new_container:addItem(itemtogive_id, itemtogive_count)
                            iter = iter + 1
                        end
                        received_item = player:addItemEx(new_container)
                    else
                        local new_item = Game.createItem(itemtogive_id, itemtogive_count)
                        received_item = player:addItemEx(new_item)
                    end
                    if type(received_item) == 'number' and received_item == RETURNVALUE_NOERROR then
                        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You received >> '.. add_item_name ..' << from OTS shop.')
                        db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";")
                        db.query("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")
                    else
                        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '>> '.. add_item_name ..' << from OTS 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
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, '>> '.. add_item_name ..' << from OTS 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
            end
        until not result.next(result_plr)
        result.free(result_plr)
    end
    return true
end

Ajudei??? Rep + ae! :D

gtYFjO8.gif

 

1iiu7Gw.png

Facebook: Béria Alternative Server

Postado

Tenta com esse:
 

local SHOP_MSG_TYPE = MESSAGE_STATUS_CONSOLE_RED
local SQL_interval = 30

function generateSerial()
  --local lettersUsedToGenerateHash = "AaBbCcDdEeFfGgHhIiJjKkLlMmOoPpQqRrSsTtUuVvWwXxYyZz"
	local lettersUsedToGenerateHash = "ABCDEFGHIJKLMOPQRSTUVWXYZ"
	local newSerial = "!"
	for k = 1, 10 do
		local l = math.random(1, string.len(lettersUsedToGenerateHash))
		newSerial = newSerial .. string.sub(lettersUsedToGenerateHash, l, l)
	end
	local newSerialInt  = math.random(999999)
	newSerial = newSerial .."-" .. newSerialInt
	-- Set TIME -> newSerial = newSerialStr .. "-" .. os.time() .. "-" .. newSerialInt
	-- length: ![10 letters]-[10 numbers (unix date)]-[6 numbers]
	-- length = 29 [always!]
	return newSerial
end 
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
			local id = tonumber(result_plr:getDataInt("id"))
			local action = tostring(result_plr:getDataString("action"))
			local delete = tonumber(result_plr:getDataInt("delete_it"))
			local cid = getCreatureByName(tostring(result_plr:getDataString("name")))
			if isPlayer(cid) 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)
						--doItemSetAttribute(new_item, "description",  "Name: ".. getPlayerName(cid) ..". Data: ".. os.date("%d %B %Y Hora: %X. ").."Serial: "..generateSerial().."")
						doItemSetAttribute(new_item, "description", "Serial: "..generateSerial().."")
						--doItemSetAttribute(new_item, "description", "This item was purchased at the shop by the player ".. getPlayerName(cid) ..".")
						--doItemSetAttribute(new_item, "aid", getPlayerGUID(cid)+10000)
						received_item = doPlayerAddItemEx(cid, new_item)
					end
					if received_item == RETURNVALUE_NOERROR then
						doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '{Shopping System} Entrega do Item '.. add_item_name ..' Feita com Sucesso!.')
						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, ' {Shopping System} Sua Backpack Nao Tem Espaco Para Receber o Item '.. add_item_name ..' Por Favor Abra Espaco em Sua Backpack, Estaremos Tentando Entregar o Item Em '.. SQL_interval ..' Segundos!.')
					end
				else
					doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS 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
			end
			if not(result_plr:next()) then
				break
			end
		end
		result_plr:free()
	end
	return true
end

Se não funcionar posta o seu 100-compat.lua (fica em data/lib).

                                                                     Ajudei? De nada \o/                                            Att Rusherzin

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo