Ir para conteúdo

Featured Replies

Postado

Uso esse npc para da recompensa aos player, gostaria de um função que não entregasse para player com mesmo IP. Alguém ajuda ae!!!

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
   

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
msg = string.lower(msg)
   
local storage = 5665465  


local item = {
{name = "caixa", id = 15999, quantidade = 1},
}
 
local effect = 763  

--------------------------------- CÓDIGO --------------------------------
   
    if msgcontains(msg, 'box') then
		if getPlayerStorageValue(cid, storage) <= os.time() then
			selfSay("Would you like to receive: {" .. item[1].name .. "}? You can come here again to get it", cid)
			talkState[talkUser] = 1 
        return true       
		
		else
			selfSay("You need to wait days to get new items in the quest.", cid)
			talkState[talkUser] = 0
		return true
		end				   
	  	
	elseif msgcontains(msg, string.lower(item[1].name)) and talkState[talkUser] == 1 then
		doPlayerAddItem(cid, item[1].id, item[1].quantidade)	 
		doSendMagicEffect(getThingPos(cid), effect)
		doPlayerSendTextMessage(cid, 27, "Congratulation, you won " .. item[1].name .. ".")
		setPlayerStorageValue(cid, storage, os.time() + (dias * 24 * 60 * 60))	
		talkState[talkUser] = 0	
	return true
	
	elseif (not msgcontains(msg, string.lower(item[1].name))) and talkState[talkUser] == 1 then
		selfSay("Please write correctly, I don't understand what you said", cid)
	return true	
	
	elseif (msgcontains(msg, 'bye') or msgcontains(msg, 'goodbye')) and talkState[talkUser] == 1 then
		selfSay("Goodbye!", cid)
		talkState[talkUser] = 0
	return true
	end
   
end       
                    
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Postado

adicione essas funções no seu servidor:

 

LUA IP STORAGE

 

 

e usa o código assim

 

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
	local talkUser,msg = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid,msg:lower()
	local storage, ip = 501, getPlayerIp(cid)
	local item = {
		{name = "caixa", id = 15999, quantidade = 1},
	}
	local dias = 1
	local effect = 763 	
	--------------------------------- CÓDIGO --------------------------------
	if msgcontains(msg, 'box') then
		if getIpStorageValue(ip, storage) - os.time() <= 0 then
			selfSay("Would you like to receive: {" .. item[1].name .. "}? You can come here again to get it", cid)
			talkState[talkUser] = 1 
		else
			selfSay("You need to wait days to get new items in the quest.", cid)
			talkState[talkUser] = 0
		end				 
	elseif msgcontains(msg, string.lower(item[1].name)) and talkState[talkUser] == 1 then
		doPlayerAddItem(cid, item[1].id, item[1].quantidade)	 
		doSendMagicEffect(getThingPos(cid), effect)
		doPlayerSendTextMessage(cid, 27, "Congratulation, you won " .. item[1].name .. ".")
		setIpStorageValue(ip, storage, os.time() + (dias * 24 * 60 * 60))	
		talkState[talkUser] = 0	
		return true
	elseif (not msgcontains(msg, string.lower(item[1].name))) and talkState[talkUser] == 1 then
		selfSay("Please write correctly, I don't understand what you said", cid) return true	
	elseif (msgcontains(msg, 'bye') or msgcontains(msg, 'goodbye')) and talkState[talkUser] == 1 then
		selfSay("Goodbye!", cid)
		talkState[talkUser] = 0
	end
	return true
end                           
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

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.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.8k

Informação Importante

Confirmação de Termo