Postado Julho 27, 2015 9 anos Autor Tentei fazer o meu, mas quando fala red skull da esse erro: local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if getCreatureCondition(cid, CONDITION_INFIGHT) then npcHandler:say("You are in fight! Wait!", cid) return true end if(msgcontains(msg, 'remove')) then selfSay('I can remove you skulls: {red skull} [5 tokens], {black skull} [10 tokens]', cid) elseif(msgcontains(msg, 'red skull')) then if not getPlayerItemCount(cid, 6527) >= 5 then selfSay("You dont have 5 tokens!", cid) return true end if not getCreatureSkullType(cid) < 4 then selfSay("You dont have RED SKULL!", cid) return true end doPlayerRemoveItem(cid, 6527, 5) selfSay("Here it is.", cid) db.executeQuery("UPDATE killers SET unjustified = '0' WHERE id IN (SELECT kill_id FROM player_killers WHERE player_id = "..getPlayerGUID(cid)..")") doCreatureSetSkullType(cid, 0) elseif(msgcontains(msg, 'black skull')) then if not getPlayerItemCount(cid, 6527) >= 10 then selfSay("You dont have 10 tokens!", cid) return true end if not getCreatureSkullType(cid) < 5 then selfSay("You dont have BLACK SKULL!", cid) return true end doPlayerRemoveItem(cid, 6527, 10) selfSay("Here it is.", cid) db.executeQuery("UPDATE killers SET unjustified = '0' WHERE id IN (SELECT kill_id FROM player_killers WHERE player_id = "..getPlayerGUID(cid)..")") doCreatureSetSkullType(cid, 0) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
Postado Julho 27, 2015 9 anos Fiz um aqui, testa ai: local t = { itemneed = 9971, count = {5, 10} -- Red/Black skull. } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end msg = msg:lower(); local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid local n = getItemNameById(t.itemneed) if msgcontains(msg, 'remove') then selfSay('Eu removo {black skull} por '.. t.count[2] ..' '.. n ..' e {red skull} por '.. t.count[1] ..' '.. n ..'.', cid) elseif msgcontains(msg, 'black skull') then if getCreatureSkullType(cid) == SKULL_BLACK then selfSay('Você deseja remover sua black skull por '.. t.count[2] ..' '.. n ..'?', cid) talkState[talkUser] = 1 else selfSay('Você não tem uma black skull.', cid) end elseif msgcontains(msg, 'red skull') then if getCreatureSkullType(cid) == SKULL_RED then selfSay('Você deseja remover sua red skull por '.. t.count[1] ..' '.. n ..'?', cid) talkState[talkUser] = 2 else selfSay('Você não tem uma red skull.', cid) end end if msgcontains(msg, 'yes') then if talkState[talkUser] == 1 then if doPlayerRemoveItem(cid, t.itemneed, t.count[2]) then db.executeQuery("UPDATE killers SET unjustified = '0' WHERE id IN (SELECT kill_id FROM player_killers WHERE player_id = "..getPlayerGUID(cid)..")") doCreatureSetSkullType(cid, 0) selfSay('Sua black skull foi removida.', cid) talkState[talkUser] = 0 else selfSay('Você não tem '.. t.count[2] ..' '.. n ..'.', cid) talkState[talkUser] = 0 end elseif talkState[talkUser] == 2 then if doPlayerRemoveItem(cid, t.itemneed, t.count[1]) then db.executeQuery("UPDATE killers SET unjustified = '0' WHERE id IN (SELECT kill_id FROM player_killers WHERE player_id = "..getPlayerGUID(cid)..")") doCreatureSetSkullType(cid, 0) selfSay('Sua red skull foi removida.', cid) talkState[talkUser] = 0 else selfSay('Você não tem '.. t.count[1] ..' '.. n ..'.', cid) talkState[talkUser] = 0 end end end end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) ➥ Regras | Seções OTServ | Seções BOT
Postado Julho 29, 2015 9 anos Autor Teu script ta funcionando perfeitamente brother, mas só uma dúvida To achando que esse problema é no meu !frags, quando eu dou !frags da como se eu tive-se red ainda, fica a msg Your black skull will... Dessa parte do script eu acho if(skullEnd > 0) then result = result .. "\nYour " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd) end Será que isso não vai dar problema depois no meu ot não? Pq a variavel skullend ta > q 0 !frags.lua local config = { useFragHandler = getBooleanFromString(getConfigValue('useFragHandler')), advancedFragList = getBooleanFromString(getConfigValue('advancedFragList')) } function onSay(cid, words, param, channel) if(not config.useFragHandler) then return false end local time = os.time() local times = {today = (time - 86400), week = (time - (7 * 86400))} local contents, result = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC") if(result:getID() ~= -1) then repeat local content = { name = result:getDataString("name"), level = result:getDataInt("level"), date = result:getDataInt("date") } if(content.date > times.today) then table.insert(contents.day, content) elseif(content.date > times.week) then table.insert(contents.week, content) else table.insert(contents.month, content) end until not result:next() result:free() end local size = { day = table.maxn(contents.day), week = table.maxn(contents.week), month = table.maxn(contents.month) } if(config.advancedFragList) then local result = "Frags gained today: " .. size.day .. "." if(size.day > 0) then for _, content in ipairs(contents.day) do result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level end result = result .. "\n" end result = result .. "\nFrags gained this week: " .. (size.day + size.week) .. "." if(size.week > 0) then for _, content in ipairs(contents.week) do result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level end result = result .. "\n" end result = result .. "\nFrags gained this month: " .. (size.day + size.week + size.month) .. "." if(size.month > 0) then for _, content in ipairs(contents.month) do result = result .. "\n* " .. os.date("%d %B %Y %X at ", content.date) .. content.name .. " on level " .. content.level end result = result .. "\n" end local skullEnd = getPlayerSkullEnd(cid) if(skullEnd > 0) then result = result .. "\nYour " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd) end doPlayerPopupFYI(cid, result) else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You currently have " .. size.day .. " frags today, " .. (size.day + size.week) .. " this week and " .. (size.day + size.week + size.month) .. " this month.") if(size.day > 0) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Last frag at " .. os.date("%d %B %Y %X", contents.day[1].date) .. " on level " .. contents.day[1].level .. " (" .. contents.day[1].name .. ").") end local skullEnd = getPlayerSkullEnd(cid) if(skullEnd > 0) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your " .. (getCreatureSkullType(cid) == SKULL_RED and "red" or "black") .. " skull will expire at " .. os.date("%d %B %Y %X", skullEnd)) end end return true end
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.