Ir para conteúdo
Entre para seguir isso  
Oneshot

Loan Shark

Recommended Posts

Oneshot    24
Oneshot

Loan Shark

Afinal, faltava só um agiota no Tibia, né?

Olá, pessoas.

 

Este é um NPC bem simples, com uso de os.time() e ociosidade no trabalho, desenvolvi um NPC que empresta dinheiro para jogadores necessitados e depois cobra com juros abusivos, super divertido. E tem mais, se o jogador não pagar a divida no tempo configurado, no próximo login, ele fica com 1 de HP e uma red skull.

 

data/npc/scripts/loan shark.lua

 

[/font]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

local storage = {
       [1] = 12345,
       [2] = 12346,
       [3] = 12347,
}

function onCreatureSayCallback(cid, type, msg)
       if(not npcHandler:isFocused(cid)) then
               return false
       end

       msg = msg:lower() or ""
       local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

       local loan = getPlayerLevel(cid) * 2000

       if getCreatureStorage(cid, storage[1]) == -1 then
               if not talkState[talkUser] or talkState[talkUser] == 0 then
                       if msgcontains(msg, "money") then
                               selfSay("Well, well. I can loan some money to you, but I'm not stupid, don't try to be a smartass with me, agreed?", cid)
                               talkState[talkUser] = 1
                       end
               elseif talkState[talkUser] == 1 then
                       if msgcontains(msg, "yes") then
                               selfSay("Okay, are you really desperate, heh? Well, I can loan to you, a maximum amount of ".. loan .." gold.", cid)
                               selfSay("So, how much money, do you need?", cid)
                               talkState[talkUser] = 2
                       elseif msgcontains(msg, "no") then
                               selfSay("Okay.")
                               talkState[talkUser] = 0
                               npcHandler:releaseFocus(cid)
                       end
               elseif talkState[talkUser] == 2 then
                       if not tonumber(msg) then
                               selfSay("Say a number amount, stupid.")
                       else
                               if tonumber(msg) > loan then
                                       selfSay("Hey, smartass, I can loan to you a maximum amount of ".. loan .." gold.", cid)
                               else
                                       doCreatureSetStorage(cid, storage[2], tonumber(msg))
                                       selfSay("You will need ".. tonumber(msg) .." gold? Okay, my interest is 50% by day, agreed?", cid)
                                       talkState[talkUser] = 3
                               end
                       end
               elseif talkState[talkUser] == 3 then
                       if msgcontains(msg, "yes") then
                               selfSay("Good choice, kid. Here is your money, but don't forget to pay me in 2 days, or my boys will beat up you pretty bad, after that I will forgive the debt.", cid)
                               doPlayerAddMoney(cid, getCreatureStorage(cid, storage[2]))
                               doCreatureSetStorage(cid, storage[1], 1)
                               doCreatureSetStorage(cid, storage[3], os.time())
							npcHandler:releaseFocus(cid)
                       elseif msgcontains(msg, "no") then
                               selfSay("Do you give up? Ooh, I forgot you are a milksop.", cid)
                               talkState[talkUser] = 0
                               npcHandler:releaseFocus(cid)
                       end
               end    
       else
               local days = math.floor((os.time() - getCreatureStorage(cid, storage[3])) / 86400)
               local value = (days > 0 and (getCreatureStorage(cid, storage[2]) * (1.5 ^ days)) or getCreatureStorage(cid, storage[2]))

               if not talkState[talkUser] or talkState[talkUser] == 0 then
                       selfSay("Well, well... ".. getCreatureName(cid) ..", do you remember you borrowed ".. getCreatureStorage(cid, storage[2]) .." gold from me, right?", cid)
                       talkState[talkUser] = 1
               elseif talkState[talkUser] == 1 then
                       if msgcontains(msg, "yes") then
                               selfSay("Good, because you need to pay me for ".. (days == 0 and "no" or days) .." days using my money.", cid)
                               selfSay("The value you owe me is ".. value .." gold. Do you have it?", cid)
                               talkState[talkUser] = 2
                       elseif msgcontains(msg, "no") then
                               selfSay("Okay, then...", cid)
                               selfSay("Just kidding, bitch! You need to pay me ".. value .." gold for ".. (days == 0 and "no" or days) .." days using my money. Do you have it, right?", cid)
                               talkState[talkUser] = 2
                       end
               elseif talkState[talkUser] == 2 then
                       if msgcontains(msg, "yes") then
                               if getPlayerMoney(cid) >= value then
                                       doPlayerRemoveMoney(cid, value)
                                       selfSay("Very good, daug! If you need my money again, you can ask me, heheh...", cid)
                                       doCreatureSetStorage(cid, storage[1], -1)
                                       doCreatureSetStorage(cid, storage[2], -1)
                                       doCreatureSetStorage(cid, storage[3], -1)
                               else
                                       selfSay("You don't have my money, no problem, you have ".. (days > 1 and "no more days" or "one day") .." before my boys hunt you, heh.", cid)
                                       talkState[talkUser] = 0
                                       npcHandler:releaseFocus(cid)
                               end
                       elseif msgcontains(msg, "no") then
                               selfSay("So, it is good to get my money, because you have ".. (days > 1 and "no more days" or "one day") .." before my boys hunt you.", cid)
                               talkState[talkUser] = 0
                               npcHandler:releaseFocus(cid)
                       end
               end
       end
       return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onCreatureSayCallback)
npcHandler:addModule(FocusModule:new())[font=verdana]

 

data/creaturescripts/scripts/loan shark.lua

 

[/font]local storage = {
       [1] = 12345,
       [2] = 12346,
       [3] = 12347,
}


function onLogin(cid)
local days = math.floor((os.time() - getCreatureStorage(cid, storage[3])) / 86400)
if getCreatureStorage(cid, storage[1]) == 1 and days > 2 then
	doCreatureSetStorage(cid, storage[1], -1)
	doCreatureSetStorage(cid, storage[2], -1)
	doCreatureSetStorage(cid, storage[3], -1)
	doCreatureAddHealth(cid, (1 - getCreatureMaxHealth(cid)))
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The Loan Shark's boys beat up you pretty hard because you didn't paid the your debt in 2 days.")
	doSendMagicEffect(getCreaturePosition(cid), CONST_ME_BLOCKHIT)
	doCreatureSetSkullType(cid, SKULL_RED)
end
return true
end[font=verdana]

 

data/creaturescripts/creaturescripts.xml

 

[/font]<event type="login" name="LoanShark" event="script" value="loan shark.lua"/>[font=verdana]

Compartilhar este post


Link para o post
Convidado Avuenja   
Convidado Avuenja

Muito bom Garou, eu que não vou querer pegar dinheiro emprestado com este agiota... rsrs

 

Obrigado por partilhar conosco esse script! :D

Compartilhar este post


Link para o post
Lordfire    110
Lordfire

CARA, já falei que esse NPC é MUITO LEGAL?

 

ESSE NPC É MUITO LEGAL!!!!!!!!!!

Compartilhar este post


Link para o post
Startix    9
Startix

NPC Agiota, era só o que faltava! kkkkkkk

 

Parabéns pela criatividade e pelo excelente script!

Compartilhar este post


Link para o post
xS0NYx    15
xS0NYx

Bastante criativo!! show kkk

Compartilhar este post


Link para o post
jadsondossantos    4
jadsondossantos

Facil burlar isto dai. Só chegar com os markers da vida e roubar vários kk's do npc.

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×