I'm using a script done by the user View Profile: Darkhaos - OtLand
It works as follows:
I add Premium Points in ur account and in-game player buys Items VIPs by an NPC made by me.
I did everything correctly, since the function in NPC until Login.lua.. There are no errors in the console and not the time of purchase of the item. He just doesn't disappear on time.
How I can fix this?
Script NPC:
NOTE: I change this:
For this:
Function scan on Login.lua:
I edited only part to understand the script and see if it works, if you need the complete script here this:
I'm used Tfs 0.3.7 R1 by MartyX.
It works as follows:
I add Premium Points in ur account and in-game player buys Items VIPs by an NPC made by me.
I did everything correctly, since the function in NPC until Login.lua.. There are no errors in the console and not the time of purchase of the item. He just doesn't disappear on time.
How I can fix this?
Script NPC:
PHP:
elseif(msgcontains(msg, '4war blessed helmet') or msgcontains(msg, 'blessed')) 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
local item = doPlayerAddItem(cid, helmetid)
doItemSetAttribute(item, "boughtdate", 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)
NOTE: I change this:
PHP:
if(doAccountRemovePoints(cid, armorcost) == TRUE) then
doPlayerAddItem(cid, helmetid)
selfSay('Voce comprou o 4war blessed helmet.', cid)
For this:
PHP:
if(doAccountRemovePoints(cid, helmetcost) == TRUE) then
local t = 30
local item = doPlayerAddItem(cid, helmetid)
doItemSetAttribute(item, "boughtdate", os.time() + t)
selfSay('Voce comprou o 4war blessed helmet.', cid)
Function scan on Login.lua:
PHP:
function scanItem(cid, uid) --By Darkhaos.
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, "boughtdate") and os.time() >= getItemAttribute(tmp.uid, "boughtdate") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getItemNameById(tmp.itemid) .. " has expired.")
doRemoveItem(tmp.uid)
end
elseif isContainer(tmp.uid) then
scanItem(cid, tmp.uid)
end
end
else
if getItemAttribute(uid, "boughtdate") and os.time() >= getItemAttribute(uid, "boughtdate") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getItemNameById(getThing(uid).itemid) .. " has expired.")
doRemoveItem(uid)
end
end
return true
end
I edited only part to understand the script and see if it works, if you need the complete script here 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
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 blessed helmet') or msgcontains(msg, '4war blessed 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 = 1
local item = doPlayerAddItem(cid, helmetid)
doItemSetAttribute(item, "boughdate", 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, '4war blessed 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
doPlayerAddItem(cid, armorid)
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, '4war blessed 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
doPlayerAddItem(cid, legsid)
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, '4war blessed 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
doPlayerAddItem(cid, shieldid)
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, '4war blessed 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
doPlayerAddItem(cid, swordid)
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, '4war blessed 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
doPlayerAddItem(cid, axeid)
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, '4war blessed 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
doPlayerAddItem(cid, spearid)
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.'})
I'm used Tfs 0.3.7 R1 by MartyX.
Last edited: