• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Someone? Isn't impossible

Vrotz

Member
Joined
Apr 7, 2011
Messages
1,071
Reaction score
7
Location
Brazil
Im using the console 0.3.7_SVN and would like the following Script.

I've a NPC that sells Items VIPs by Premium Points and I would like a script that did with that the Item VIP disappeared in 30 days after the player receive in its backpack. Just the items VIPS sold by this NPC.

This is the script of the NPC that sells the Items VIPs on my server. (Already configured):
PHP:
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
 
npcHandler:setMessage(MESSAGE_GREET, "Ola, |PLAYERNAME|. Eu sou o NPC responsável por vender Items VIPs para Mages. Para mais informações diga {info}.")


function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
end
 
	local bootsid = 2358
	local bootscost = 5
 
	local helmetid = 10570
	local helmetcost = 2

	local armorid = 12643
	local armorcost = 2

	local legsid = 7894
	local legscost = 2

	local shieldid = 12647
	local shieldcost = 2

	local maceid = 7424
	local macecost = 10
 
 
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
	if(msgcontains(msg, '4war boots') or msgcontains(msg, '4war boots')) then
		selfSay('Voce deseja comprar a 4war boots por '.. bootscost ..' premium points?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(getAccountPoints(cid) >= bootscost) then
			if(doAccountRemovePoints(cid, bootscost) == TRUE) then
				doPlayerAddItem(cid, bootsid)
				selfSay('Voce comprou uma 4war boots.', cid)
			else
				selfSay('Voce nao tem pontos suficientes.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)
 
 
	elseif(msgcontains(msg, '4war mage hat') or msgcontains(msg, '4war mage hat')) then
		selfSay('Voce desejar comprar o 4war mage hat por '.. helmetcost ..' premium points?', cid)
		talkState[talkUser] = 2
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
		if(getAccountPoints(cid) >= helmetcost) then
			if(doAccountRemovePoints(cid, helmetcost) == TRUE) then
				doPlayerAddItem(cid, helmetid)
				selfSay('Voce comprou o 4war mage hat.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar o 4war mage hat.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar o 4war mage hat.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)


	elseif(msgcontains(msg, '4war mage robe') or msgcontains(msg, '4war mage robe')) then
		selfSay('Voce desejar comprar o 4war mage robe por '.. armorcost ..' premium points?', cid)
		talkState[talkUser] = 3
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then
		if(getAccountPoints(cid) >= armorcost) then
			if(doAccountRemovePoints(cid, armorcost) == TRUE) then
				doPlayerAddItem(cid, armorid)
				selfSay('Voce comprou o 4war mage robe.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar a 4war mage robe.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar a 4war mage robe.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)


	elseif(msgcontains(msg, '4war mage legs') or msgcontains(msg, '4war mage legs')) then
		selfSay('Voce desejar comprar o 4war mage legs por '.. legscost ..' premium points?', cid)
		talkState[talkUser] = 4
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then
		if(getAccountPoints(cid) >= legscost) then
			if(doAccountRemovePoints(cid, legscost) == TRUE) then
				doPlayerAddItem(cid, legsid)
				selfSay('Voce comprou a 4war mage legs.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar a 4war mage legs.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar a 4war mage legs.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)


		elseif(msgcontains(msg, '4war mage spellbook') or msgcontains(msg, '4war mage spellbook')) then
		selfSay('Voce desejar comprar o 4war mage spelbook por '.. shieldcost ..' premium points?', cid)
		talkState[talkUser] = 5
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 5) then
		if(getAccountPoints(cid) >= shieldcost) then
			if(doAccountRemovePoints(cid, shieldcost) == TRUE) then
				doPlayerAddItem(cid, shieldid)
				selfSay('Voce comprou a 4war mage spellbook.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar o 4war mage spellbook.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar o 4war mage spellbook.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)


		elseif(msgcontains(msg, '4war mage staff') or msgcontains(msg, '4war mage staff')) then
		selfSay('Voce desejar comprar o 4war mage staff por '.. macecost ..' premium points?', cid)
		talkState[talkUser] = 6
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 6) then
		if(getAccountPoints(cid) >= macecost) then
			if(doAccountRemovePoints(cid, macecost) == TRUE) then
				doPlayerAddItem(cid, maceid)
				selfSay('Voce comprou a 4war mage staff.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar a 4war mage staff', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar a 4war mage staff.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)
	end
 
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

keywordHandler:addKeyword({'info'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu posso lhe dar explicações detalhadas. Diga {points} para saber para que servem, {doacao} para saber como doar, {check} para consultar os pontos de sua account ou {VIP} para comprar os seus Items.'})

keywordHandler:addKeyword({'check'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Você pode consultar quantos pontos (Premium Points) você possui em sua conta, digite, no Default, o comando !points ou !check.'})

keywordHandler:addKeyword({'vip'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Para comprar o seu Item VIP comigo, apenas diga o nome do Item e confirme. Estes são os Items VIPs para Sorcerers e Druids: {4war mage hat}, {4war mage robe}, {4war mage legs}, {4war mage spellbook}, {4war mage staff}, {4war boots}.'})

keywordHandler:addKeyword({'points'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Premium Points são pontos obtidos através de doações para o server e eles servem para que você possa troca-los comigo por Items VIPs. Igual o sistema de um "Shop System".'})

keywordHandler:addKeyword({'doacao'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'As doações são necessárias para que você possa comprar um Item VIP comigo, sem os seus pontos eu não posso lhe dar os items. Portanto, acesse o nosso site e faça já uma doação! www.enforced.4war.org.'})

Thanks a lot.
 
Last edited:
items.xml update your vip items by adding to new attributes:
XML:
<item id="2358" article="a" name="bootsId">
                <attribute key="decayTo" value="0" />
                <attribute key="duration" value="2592000" />
 </item>

LUA:
<attribute key="decayTo" value="0" /> -- decayTo 0 = become to nothing
<attribute key="duration" value="2592000" /> -- duration value sec's = 2592000 s.  = 30 days not sure such big value might not work, but worth to try
 
But in this way the items alone are going to disappear the player will be online and using them. It would like that went equal a premium account, using or not, he would have that count the days.
 
Last edited:
You'll need an creaturescript with onThink function (if you want item disappear instantly when the time expires) or add a code to login.lua (item will disappear when player logs in).

In the npc-script replace all lines like this:
LUA:
doPlayerAddItem(cid, ...)

With this
LUA:
local t = 30 * 24 * 60 * 60 --30 days in seconds.
local item = doPlayerAddItem(cid, ...)
doItemSetAttribute(item, "enddate", os.time() + t)

Then, add a code to creaturescript, search in forum for a function that scan all player items (There is one posted by Jano i think) and edit it to use like this.
LUA:
function scanContainer(getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid) --not sure if it's CONST_SLOT_BACKPACK or CONST_SLOT_CONTAINER
	--bla bla bla, items being scaned
	local item = ... --item being scaned
	if getItemAttribute(item, "enddate") and os.time() >= getItemAttribute(item, "enddate") then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "A VIP item has expired.")
		doRemoveItem(item.uid)
	end
end

--NOTE: You can add a variable and give it a value if an item is removed from player. With the variable, you'll prevent a message for each item removed.

PD: I made a script exactly as this one some months ago.
 
Ok, I change my script of the NPC and stayed like this:

PHP:
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
 
npcHandler:setMessage(MESSAGE_GREET, "Ola, |PLAYERNAME|. Eu sou o NPC responsável por vender Items VIPs para Knights e Paladins. Para mais informações diga {info}.")


function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
end
 
	local bootsid = 2358
	local bootscost = 5
 
	local helmetid = 11302
	local helmetcost = 2

	local armorid = 11301
	local armorcost = 2

	local legsid = 11304
	local legscost = 2

	local shieldid = 6391
	local shieldcost = 2

	local swordid = 12649
	local swordcost = 10

	local axeid = 11305
	local axecost = 10

	local spearid = 7367
	local spearcost = 10
 
 
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
 
	if(msgcontains(msg, '4war boots') or msgcontains(msg, 'boots')) then
		selfSay('Voce deseja comprar a 4war boots por '.. bootscost ..' premium points?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(getAccountPoints(cid) >= bootscost) then
			if(doAccountRemovePoints(cid, bootscost) == TRUE) then
                         local t = 30 * 24 * 60 * 60 --30 days in seconds.
                         local item = doPlayerAddItem(cid, bootsid)
                         doItemSetAttribute(item, "enddate", os.time() + t)
				selfSay('Voce comprou uma 4war boots.', cid)
			else
				selfSay('Voce nao tem pontos suficientes.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)
 
 
	elseif(msgcontains(msg, '4war blessed helmet') or msgcontains(msg, 'helmet')) then
		selfSay('Voce desejar comprar o 4war blessed helmet por '.. helmetcost ..' premium points?', cid)
		talkState[talkUser] = 2
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
		if(getAccountPoints(cid) >= helmetcost) then
			if(doAccountRemovePoints(cid, helmetcost) == TRUE) then
                         local t = 30 * 24 * 60 * 60 --30 days in seconds.
                         local item = doPlayerAddItem(cid, helmetid)
                         doItemSetAttribute(item, "enddate", os.time() + t)
				selfSay('Voce comprou o 4war blessed helmet.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar o 4war blessed helmet.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar o 4war blessed helmet.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)


	elseif(msgcontains(msg, '4war blessed armor') or msgcontains(msg, 'armor')) then
		selfSay('Voce desejar comprar o 4war blessed armor por '.. armorcost ..' premium points?', cid)
		talkState[talkUser] = 3
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3) then
		if(getAccountPoints(cid) >= armorcost) then
			if(doAccountRemovePoints(cid, armorcost) == TRUE) then
                         local t = 30 * 24 * 60 * 60 --30 days in seconds.
                         local item = doPlayerAddItem(cid, armorid)
                         doItemSetAttribute(item, "enddate", os.time() + t)
				selfSay('Voce comprou o 4war blessed armor.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar a 4war blessed armor.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar a 4war blessed armor.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)


	elseif(msgcontains(msg, '4war blessed legs') or msgcontains(msg, 'legs')) then
		selfSay('Voce desejar comprar o 4war blessed legs por '.. legscost ..' premium points?', cid)
		talkState[talkUser] = 4
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then
		if(getAccountPoints(cid) >= legscost) then
			if(doAccountRemovePoints(cid, legscost) == TRUE) then
                         local t = 30 * 24 * 60 * 60 --30 days in seconds.
                         local item = doPlayerAddItem(cid, legsid)
                         doItemSetAttribute(item, "enddate", os.time() + t)
				selfSay('Voce comprou a 4war blessed legs.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar a 4war blessed legs.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar a 4war blessed legs.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)


		elseif(msgcontains(msg, '4war blessed shield') or msgcontains(msg, 'shield')) then
		selfSay('Voce desejar comprar o 4war mage spelbook por '.. shieldcost ..' premium points?', cid)
		talkState[talkUser] = 5
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 5) then
		if(getAccountPoints(cid) >= shieldcost) then
			if(doAccountRemovePoints(cid, shieldcost) == TRUE) then
                         local t = 30 * 24 * 60 * 60 --30 days in seconds.
                         local item = doPlayerAddItem(cid, shieldid)
                         doItemSetAttribute(item, "enddate", os.time() + t)
				selfSay('Voce comprou a 4war blessed shield.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar o 4war blessed shield.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar o 4war blessed shield.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)


		elseif(msgcontains(msg, '4war blessed sword') or msgcontains(msg, 'sword')) then
		selfSay('Voce desejar comprar o 4war blessed sword por '.. swordcost ..' premium points?', cid)
		talkState[talkUser] = 6
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 6) then
		if(getAccountPoints(cid) >= swordcost) then
			if(doAccountRemovePoints(cid, swordcost) == TRUE) then
                         local t = 30 * 24 * 60 * 60 --30 days in seconds.
                         local item = doPlayerAddItem(cid, swordid)
                         doItemSetAttribute(item, "enddate", os.time() + t)
				selfSay('Voce comprou a 4war blessed sword.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar a 4war blessed sword.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar a 4war blessed sword.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)


		elseif(msgcontains(msg, '4war blessed axe') or msgcontains(msg, 'axe')) then
		selfSay('Voce desejar comprar o 4war blessed axe por '.. swordcost ..' premium points?', cid)
		talkState[talkUser] = 7
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 7) then
		if(getAccountPoints(cid) >= axecost) then
			if(doAccountRemovePoints(cid, axecost) == TRUE) then
                         local t = 30 * 24 * 60 * 60 --30 days in seconds.
                         local item = doPlayerAddItem(cid, axeid)
                         doItemSetAttribute(item, "enddate", os.time() + t)
				selfSay('Voce comprou a 4war blessed axe.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar a 4war blessed axe.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar a 4war blessed axe.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)


		elseif(msgcontains(msg, '4war blessed spear') or msgcontains(msg, 'spear')) then
		selfSay('Voce desejar comprar o 4war blessed spear por '.. swordcost ..' premium points?', cid)
		talkState[talkUser] = 8
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 8) then
		if(getAccountPoints(cid) >= spearcost) then
			if(doAccountRemovePoints(cid, spearcost) == TRUE) then
                         local t = 30 * 24 * 60 * 60 --30 days in seconds.
                         local item = doPlayerAddItem(cid, axeid)
                         doItemSetAttribute(item, "enddate", os.time() + t)
				selfSay('Voce comprou a 4war blessed spear.', cid)
			else
				selfSay('Voce nao tem pontos suficientes para comprar a 4war blessed spear.', cid)
			end
		else
			selfSay('Voce nao tem pontos suficientes para comprar a 4war blessed spear.', cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)
	end
 
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

keywordHandler:addKeyword({'info'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu posso lhe dar explicações detalhadas. Diga {points} para saber para que servem, {doacao} para saber como doar, {check} para consultar os pontos de sua account ou {VIP} para comprar os seus Items.'})

keywordHandler:addKeyword({'check'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Você pode consultar quantos pontos (Premium Points) você possui em sua conta, digite, no Default, o comando !points ou !check.'})

keywordHandler:addKeyword({'vip'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Para comprar o seu Item VIP comigo, apenas diga o nome do Item e confirme. Estes são os Items VIPs para Knights e Paladins: {4war blessed helmet}, {4war blessed armor}, {4war blessed legs}, {4war blessed shield}, {4war blessed sword}, {4war blessed axe}, {4war blessed spear}, {4war boots}.'})

keywordHandler:addKeyword({'points'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Premium Points são pontos obtidos através de doações para o server e eles servem para que você possa troca-los comigo por Items VIPs. Igual o sistema de um "Shop System".'})

keywordHandler:addKeyword({'doacao'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'As doações são necessárias para que você possa comprar um Item VIP comigo, sem os seus pontos eu não posso lhe dar os items. Portanto, acesse o nosso site e faça já uma doação! www.enforced.4war.org.'})

Alright, now, I've change my Login.lua and add just one item to test:
PHP:
local config = {
	loginMessage = getConfigValue('loginMessage'),
	useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
		doPlayerAddBlessing(cid, 1)
		doPlayerAddBlessing(cid, 2)
		doPlayerAddBlessing(cid, 3)
		doPlayerAddBlessing(cid, 4)
		doPlayerAddBlessing(cid, 5)
	end

	local accountManager = getPlayerAccountManager(cid)
	if(accountManager == MANAGER_NONE) then
		local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
		if(lastLogin > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
			str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
		else
			str = str .. " Please choose your outfit."
			doPlayerSendOutfitWindow(cid)
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	elseif(accountManager == MANAGER_NAMELOCK) then
		addEvent(valid(doCreatureSay), 500, cid, "Hello, it appears that your character has been locked for name violating rules, what new name would you like to have?", TALKTYPE_PRIVATE_NP, true, cid)
	elseif(accountManager == MANAGER_ACCOUNT) then
		addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to manage your account. If you would like to start over, type {cancel} anywhere.", TALKTYPE_PRIVATE_NP, true, cid)
	else
		addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to create an account or {recover} to recover an account.", TALKTYPE_PRIVATE_NP, true, cid)
	end

	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	end

	registerCreatureEvent(cid, "Idle")
	registerCreatureEvent(cid, "Mail")
	if(getPlayerOperatingSystem(cid) >= CLIENTOS_OTCLIENT_LINUX) then
		registerCreatureEvent(cid, "ExtendedOpcode")
	end

	registerCreatureEvent(cid, "ReportBug")
	if(config.useFragHandler) then
		registerCreatureEvent(cid, "SkullCheck")
	end
	registerCreatureEvent(cid, "GuildEvents")
	registerCreatureEvent(cid, "AdvanceSave")
      registerCreatureEvent(cid, "deathBroadcast")
      registerCreatureEvent(cid, "Lowlevellock")
      registerCreatureEvent(cid, "Promo")
	return true
end

function scanContainer(getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid)
	local item = {2358)
	if getItemAttribute(item, "enddate") and os.time() >= getItemAttribute(item, "enddate") then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "A VIP item has expired.")
		doRemoveItem(item.uid)
	end
end

Made that, I opened my sv and had the following errors:
Err2.JPG
Er1.JPG


And when I speak the name of the item for the NPC appears this:
Err3.JPG

As regards the variables, please help me becausae idk nothing.
So, Thanks of the same.
 
Login.lua
LUA:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
        doPlayerAddBlessing(cid, 1)
        doPlayerAddBlessing(cid, 2)
        doPlayerAddBlessing(cid, 3)
        doPlayerAddBlessing(cid, 4)
        doPlayerAddBlessing(cid, 5)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        addEvent(valid(doCreatureSay), 500, cid, "Hello, it appears that your character has been locked for name violating rules, what new name would you like to have?", TALKTYPE_PRIVATE_NP, true, cid)
    elseif(accountManager == MANAGER_ACCOUNT) then
        addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to manage your account. If you would like to start over, type {cancel} anywhere.", TALKTYPE_PRIVATE_NP, true, cid)
    else
        addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to create an account or {recover} to recover an account.", TALKTYPE_PRIVATE_NP, true, cid)
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Idle")
    registerCreatureEvent(cid, "Mail")
    if(getPlayerOperatingSystem(cid) >= CLIENTOS_OTCLIENT_LINUX) then
        registerCreatureEvent(cid, "ExtendedOpcode")
    end

    registerCreatureEvent(cid, "ReportBug")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end
    registerCreatureEvent(cid, "GuildEvents")
    registerCreatureEvent(cid, "AdvanceSave")
      registerCreatureEvent(cid, "deathBroadcast")
      registerCreatureEvent(cid, "Lowlevellock")
      registerCreatureEvent(cid, "Promo")
    return true
end

function scanContainer(getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid)
    local item = 2358
    if getItemAttribute(item, "enddate") and os.time() >= getItemAttribute(item, "enddate") then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "A VIP item has expired.")
        doRemoveItem(item.uid)
    end
end

About npc probem. Check, have you table player_statements in your database, because it looks like you dos't have.
If you haven't execute this in your database.
Code:
CREATE TABLE IF NOT EXISTS `player_statements` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `player_id` int(11) NOT NULL,
  `channel_id` int(11) NOT NULL DEFAULT '0',
  `text` varchar(255) NOT NULL,
  `date` bigint(20) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `player_id` (`player_id`),
  KEY `channel_id` (`channel_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1464 ;
 
Last edited:
if said, you can search for a function to scan player items and edit it like this
LUA:
function scanContainer(getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid)
    local item = {2358)
    if getItemAttribute(item, "enddate") and os.time() >= getItemAttribute(item, "enddate") then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "A VIP item has expired.")
        doRemoveItem(item.uid)
    end
end

I didn't said that's the function you must add to login.lua.

Anyways, this is the function i was using. add it to login.lua before the last end:
LUA:
function scanItem(cid, uid) --By Darkhaos.
	local removed = false
	local count = 0
	if isContainer(uid) then
		for k = (getContainerSize(uid) - 1), 0, -1 do
			local tmp = getContainerItem(uid, k)
			if not isContainer(tmp.uid) then
				if getItemAttribute(tmp.uid, "enddate") and os.time() >= getItemAttribute(tmp.uid, "enddate") then
					removed = true
					count = count + 1
					doRemoveItem(tmp.uid)
				end
			elseif isContainer(tmp.uid) then
				scanItem(cid, tmp.uid)
			end
		end
	else
		if getItemAttribute(uid, "enddate") and os.time() >= getItemAttribute(uid, "enddate") then
			removed = true
			count = count + 1
			doRemoveItem(uid)
		end
	end
	if removed then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, (count > 1 and "Some" or "One") .. " of your item" .. (count > 1 and "s" or "") .. " has expired.")
	end
	return true
end

scanItem(cid, getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid)
 
Last edited:
And How i do for the this variable scan the items of the player? Can u explain me better? I added the function in the Login because I remembered of another script that u had deed for myself.

I change the script in the Login.lua and upon opening the server.. I had an encounter with these errors: Err.JPG

However, the item isnt disappearing. This alone script is going to remove the items of the backpack or also the that are in the body of the player/depot?
 
Last edited:
Back
Top