-
Ajuda com getslot item
@Vodkart Obrigado por ajudar!
-
-
Ajuda com getslot item
Olá pessoal alguém poderia me ajudar a criar uma checagem de item no slot do jogador? Preciso adicionar isso há um npcs onde ele faça a checagem antes que continue o script. Preciso que o jogador tenha que retirar todos os items e colocar na bp para conseguir falar com o npc. Preciso que o npcs faça a checagem nos slots, armors, legs, boots, helmet, armas, shield. Preciso que check esses slots, se estiver com algum deles equipado o npc retorna a mensagem abaixo if (getItemInfo(uid.itemid) ~= 1) and (getItemWeaponType(uid.uid) == 1) then doPlayerSendTextMessage(cid, 24, "Você não pode fazer está ação com algum item equipado! Retire todos os seus itens e coloque em sua backpack.") return false end local items = {12372, 12373} local helmets = getPlayerSlotItem(cid, CONST_SLOT_HEAD).itemid local armors = getPlayerSlotItem(cid, CONST_SLOT_ARMOR).itemid local legs = getPlayerSlotItem(cid, CONST_SLOT_LEGS).itemid local boots = getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid local left_hand = getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid local right_hand = getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid if isInArray(items, helmets) or isInArray(items, armors) or isInArray(items, legs) or isInArray(items, boots) or isInArray(items, left_hand) or isInArray(items, right_hand) then selfSay('Você não pode fazer está ação com algum item equipado! Retire todos os seus itens e coloque em sua backpack.') focus = 0 talk_start = 0 end Consegui fazer desta forma, alguém poderia me mostrar alguma forma melhor e com menos código para fazer funcionar dessa mesma forma? ja testei e funcionou, está verificando todos os slots, mas dessa forma eu preciso adicionar id por id de todos os itens equipaveis do jogo, existe alguma função que ja verifique todos os itens do jogo? @Vodkart
-
Erro em database
Olá gente, alguém poderia me ajudar com este erro que está acontecendo em meu servidor? As vezes ele acontece, outras não. Isso acontece quando reinicio o servidor algumas vezes para testar alguma coisa, existe alguma solução para isso? Utilizo Otx: 2.15 Website: Myacc 0.8.6 Teria algo haver com o init.lua em globalevents? ou um conflito entre o init.lua e essa function do config.lua: saveGlobalStorage = true local config = { creationTime = 7 * 86400, checkTime = 7 * 86400, viceCount = 4, memberCount = 10 } local positions = { pos1 = {x = 927, y = 1160, z = 13}, } function onStartup() db.query("DELETE FROM `guild_wars` WHERE `status` = 0 AND `begin` < " .. (os.time() - 2 * 86400) .. ";") db.query("UPDATE `guild_wars` SET `status` = 5, `end` = " .. os.time() .. " WHERE `status` = 1 AND `end` > 0 AND `end` < " .. os.time() .. ";") -- doCreateMonster('RB Goku SSJ4', positions.pos1) local data, time, result = {}, os.time(), db.getResult("SELECT `id`, `ownerid`, `creationdata`, `checkdata` FROM `guilds` WHERE `world_id` = " .. getConfigValue('worldId') .. ";") if(result:getID() ~= -1) then repeat data[result:getDataInt("id")] = {result:getDataInt("ownerid"), result:getDataInt("creationdata"), result:getDataInt("checkdata")} until not(result:next()) result:free() end for id, v in ipairs(data) do local owner, created, check = v[1], v[2], v[3] if(created < (time - config.creationTime)) then result = db.getResult("SELECT `id`, `level` FROM `guild_ranks` WHERE `guild_id` = " .. id .. ";") if(result:getID() ~= -1) then local rank, ranks = 0, {} repeat ranks[result:getDataInt("id")] = result:getDataInt("level") if(result:getDataInt("level") == 1) then rank = result:getDataInt("id") end until not(result:next()) result:free() local members = {0, 0, 0, 0} for k, v in ipairs(ranks) do result = db.getResult("SELECT COUNT(`id`) AS `count` FROM `players` WHERE `rank_id` = " .. k .. ";") if(result:getID() ~= -1) then members[v] = members[v] + result:getDataInt("count") result:free() end if(v == 2) then result = db.getResult("SELECT `p`.`id` FROM `players` p LEFT JOIN `accounts` a ON `p`.`account_id` = `a`.`id` WHERE `p`.`rank_id` = " .. k .. " AND (`a`.`premdays` = 0 OR (`a`.`lastday` + (`a`.`premdays` * 86400) <= 0));") if(result:getID() ~= -1) then local demote = "" repeat demote = demote .. result:getDataInt("id") .. "," members[2] = members[2] - 1 members[1] = members[1] + 1 until not(result:next()) result:free() if(demote ~= "" and rank ~= 0) then db.query("UPDATE `players` SET `rank_id` = " .. rank .. " WHERE `id` IN (" .. demote:sub(1, -2) .. ");") end end end end for i = 1, 3 do members[4] = members[4] + members[i] end if(members[2] < config.viceCount or members[4] < config.memberCount) then if(check == 0) then db.query("UPDATE `guilds` SET `checkdata` = " .. (time + config.checkTime) .. " WHERE `id` = " .. id .. ";") elseif(check < time) then local tmp = "" for rank, _ in ipairs(ranks) do tmp = tmp .. rank .. "," end db.query("UPDATE `players` SET `rank_id` = 0, `guildnick` = '', `guildjoin` = 0 WHERE `rank_id` IN (" .. tmp:sub(1, -2) .. ");") db.query("DELETE FROM `guilds` WHERE `id` = " .. id .. ";") end end end end end db.query("UPDATE `players` SET `online` = 0 WHERE `world_id` = " .. getConfigValue('worldId') .. " AND `online` > 0;") db.query("UPDATE `bans` SET `active` = 0 WHERE `expires` <= " .. time .. " AND `expires` >= 0 AND `active` = 1") db.query("DELETE FROM `guild_wars` WHERE `status` = 0 AND `begin` < " .. (time - 2 * 86400) .. ";") return true end function onGlobalSave() if(getGameState() ~= GAMESTATE_CLOSING) then return onStartup() end return true end
-
XShadowmoses se registrou na comunidade
-
Hirashin Ni No Dan
@xWhiteWolf desculpe-me reviver o tópico, tenho uma dúvida sobre a spells. ja tenho a sua função do isWalkable dentro da lib mas a spell não funciona, fica retornando a mensagem doPlayerSendCancel(cid, "You can't reach your target") a spell só funciona quando adiciono a function como um local dentro da própria spell, alguém saberia me explicar o porque da spell não está conseguindo ler a lib? OBS: não acontece nenhum erro, a spell apenas não funciona se a function não estiver dentro da spell local config = { storage = 49708, tempo = 20, effect = 863 } local exception = {"Trainer", "Training Monk", "GOD"} local function isWalkable(pos, creature, proj, pz)-- by Nord if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end if getTopCreature(pos).uid > 0 and creature then return false end if getTileInfo(pos).protection and pz then return false, true end local n = not proj and 3 or 2 for i = 0, 255 do pos.stackpos = i local tile = getTileThingByPos(pos) if tile.itemid ~= 0 and not isCreature(tile.uid) then if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then return false end end end return true end function onCastSpell(cid, var) local name = getCreatureName(getCreatureTarget(cid)) local pos1 = {x = getPlayerPosition(cid).x + 1, y = getPlayerPosition(cid).y + 1, z = getPlayerPosition(cid).z} local position1 = {x=getThingPosition(getCreatureTarget(cid)).x+1, y=getThingPosition(getCreatureTarget(cid)).y+1, z=getThingPosition(getCreatureTarget(cid)).z} if not isInArray(exception, name) then if getPlayerStorageValue(cid, config.storage) <= 0 then doPlayerSetStorageValue(cid, config.storage, 1) doSendMagicEffect(pos1, config.effect) doSendMagicEffect(position1, config.effect) addEvent(function() doPlayerSetStorageValue(cid, config.storage, 0) if isCreature(cid) and isCreature(variantToNumber(var)) then if isWalkable(getCreaturePosition(variantToNumber(var)), false, true, true) then doTeleportThing(cid, getThingPos(variantToNumber(var)), true) arr = {3} doAreaCombatHealth(cid, 1, getThingPos(variantToNumber(var)), arr, -getPlayerLevel(cid), -2*(getPlayerLevel(cid)), 0) elseif isCreature(cid) and not isWalkable(getCreaturePosition(variantToNumber(var)), false, true, true) then doPlayerSendCancel(cid, "You can't reach your target") end end end, 1000*config.tempo) elseif getPlayerStorageValue (cid, config.storage) > 0 then doSendMagicEffect(getThingPos(cid), 2) doPlayerSendCancel(cid, "You've already set your target.") end else doPlayerSendCancel (cid, "You can't use this spell in this creature.") return false end return true end