Ir para conteúdo
Entre para seguir isso  
pejuge2

Master of Games (MoG) ~ 1.0

Recommended Posts

pejuge2    1
pejuge2

 

masterofgames.jpg

 

 

 

Autor: PeJuGe

 

Servidor Testado: TFS Crying Damson 5

 

Requerimentos: JIddo's Advanced NPC System (tutorial por Skyen Hasus: http://forums.otserv.com.br/f27/ot-8-2-implantando-npc-channel-68782/); PON System (Implantado no Script, para coletânea completa da LIB por PeJuGe: http://forums.otserv.com.br/f183/par-ou-impar-4-funcoes-125097/).

 

Descrição: Meu primeiro NPC, o Master of Games (MoG), o primeiro de muitos outros scripts (tomara :rolleyes:). Ele é o gerenciador de um cassino, o qual tende cada vez mais a crescer com novos scripts hehe.

Versão 1.0:

> Jogo de Par ou Ímpar

 

> Instalação:

 

Script:

[spoiler=Master of Games (MoG) - 1.0]

--[[ Created by PeJuGe (2010)

Exclusive for OT Net (www.otserv.com.br)

MoG collection

--]]

 

local minimum = 100 -- The minimum bet in gold coins

 

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

local bet = {}

local number = {}

local difficulty = {}

local option = {}

local NPCValue = 0

 

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 talkState = {}

 

function isPON(param) --> Check if the param is a pair or an odd number

if type(param) == 'number' then

if param % 2 == 0 then

return "pair"

else return "odd"

end

else return "not number"

end

end

 

function NPCPOPlay(uid, number, bet, difficulty, option)

 

local formula = bet * difficulty + bet * 3/10 * difficulty -- The formula for give prize

 

local Was = difficulty

local var = ""

if doPlayerRemoveMoney(uid, bet) then

NPCValue = NPCValue + bet

while Was ~= 0 do

var = math.random(1, 100)

if isPON(var + number) ~= option then

npcHandler:say("Sorry, you lost, my number is "..var..". But you can {Play PO} again. If you wanna select the same values talk {Play Again}.", uid)

talkState[uid] = 0

return FALSE

elseif isPON(var + number) == option and Was == 1 then

doSendMagicEffect(getCreaturePosition(uid), 13)

npcHandler:say("Congratulations, you won "..math.floor(formula).." gold coins. Let's {Play PO} again? To use the same values jus talk {Play Again}.", uid)

doPlayerAddMoney(uid, math.floor(formula))

NPCValue = NPCValue - math.floor(formula)

talkState[uid] = 0

return TRUE

else Was = Was - 1

end

end

else npcHandler:say("Sorry, you have enough money. To play whit this values talk {yes} or {any word} when you got the money.", uid)

end

end

 

function onThink()

npcHandler:onThink()

local rand = math.random(1, 600)

if rand == 1 then

selfSay('Me sinto tão solitário. :(')

elseif rand == 2 then

selfSay('Psiu!')

elseif rand == 3 then

selfSay('Venham, façam suas apostas!')

end

end

 

function getNumber(txt)

x = string.gsub(txt,"%a","")

x = tonumber(x)

if x ~= nill and x >= 0 then

return math.floor(x)

else return 0

end

end

 

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

if msgcontains(msg, 'play po') then

npcHandler:say('Wow, nice. {How much} do you wanna bet? If you wanna bet all your money use {all}. Just remember who the minimum bet is '..minimum..'.', cid)

talkState[cid] = 1

elseif talkState[cid] == 1 then

if msgcontains(msg, 'all') then

bet[cid] = getPlayerMoney(cid)

else bet[cid] = getNumber(msg)

end

if bet[cid] >= minimum then

npcHandler:say('Your bet is '..bet[cid]..'. Are u sure?', cid)

talkState[cid] = 2

else npcHandler:say("Sorry, your bet is very small or isn't a number. Please, select a number greater than "..minimum..".", cid)

end

elseif talkState[cid] == 2 then

if msgcontains(msg, 'yes') then

if getPlayerMoney(cid) >= bet[cid] then

npcHandler:say('Now, select a difficulty number greater than 0 (the more difficult, the bigger the payout).', cid)

talkState[cid] = 3

else npcHandler:say('Sorry, you have enough money. Please, select a new bet.', cid)

talkState[cid] = 1

end

else npcHandler:say('Ok, how much do you wanna bet?', cid)

talkState[cid] = 1

end

elseif talkState[cid] == 3 then

difficulty[cid] = getNumber(msg)

if difficulty[cid] > 0 then

npcHandler:say('The selected difficulty is '..difficulty[cid]..'. Are u sure?', cid)

talkState[cid] = 4

else npcHandler:say("Please, select a difficulty level greater than 0, must be a number.", cid)

end

elseif talkState[cid] == 4 then

if msgcontains(msg, 'yes') then

npcHandler:say('Alright, choose a number.', cid)

talkState[cid] = 5

else npcHandler:say('Ok, select your difficulty.', cid)

talkState[cid] = 3

end

elseif talkState[cid] == 5 then

number[cid] = getNumber(msg)

npcHandler:say("Your number is "..number[cid]..". Now wanna select {pair} or {odd}?", cid)

talkState[cid] = 6

elseif talkState[cid] == 6 then

if msgcontains(msg, 'pair') then

option[cid] = "pair"

elseif msgcontains(msg, 'odd') then

option[cid] = "odd"

else return npcHandler:say("Please, select {pair} or {odd}", cid)

end

NPCPOPlay(cid, number[cid], bet[cid], difficulty[cid], option[cid])

elseif msgcontains(msg, 'play again') and talkState[cid] == 0 and number[cid] ~= nil then

npcHandler:say("Your values are:\nNumber: "..number[cid].."\nBet: "..bet[cid].."\nDifficulty: "..difficulty[cid].."\nOption: "..option[cid].."\n{Alright}?", cid)

talkState[cid] = 7

elseif talkState[cid] == 7 then

if msgcontains(msg, 'yes') or msgcontains(msg, 'alright') then

NPCPOPlay(cid, number[cid], bet[cid], difficulty[cid], option[cid])

else npcHandler:say("Ok, select new values. How much you wanna bet?", cid)

talkState[cid] = 1

end

end

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

ncHandler:addModule(FocusModule:new())

 

Bom, para instalar é bem simples, basta criar um arquivo .Lua de nome mogPO na pasta ...\data\npc\scripts, agora, crie um arquivo XML de nome Master of Games na pasta ...\data\npc e colar o conteúdo a seguir.

 

Existem 2 variáveis a serem editadas, o valor mínimo de aposta e a fórmula quando há vitória, estas estão marcadas respectivamente de verde e roxo no script.

 

[spoiler=Arquivo XML - (MoG) 1.0]

<?xml version="1.0" encoding="UTF-8"?>

<npc name="Master of Games" script="data/npc/scripts/mogPO.lua" walkinterval="1500" floorchange="0">

<health now="100" max="100"/>

<look type="139" head="20" body="39" legs="45" feet="7" addons="0"/>

<parameters>

<parameter key="message_greet" value="Hello |PLAYERNAME|. I'm the Master of Games. At moment, i'm playing only pair or odd ({Play PO}). What game do you wanna play? Don't forget to check my mulplayer games." />

<parameters>

</npc>

 

Bom, agora é só se divertir.

 

 

Grato, Pedro(PeJuGe) ~ Favor postar caso haja algum erro de escrita ou dicas para melhora favor postar.

Editado por pejuge2
URL Removida.

Compartilhar este post


Link para o post
Gpwjhlkdcf    21
Gpwjhlkdcf

Obrigado pela contribuição. Eu removi a URL, pois links são proibidos, mas manti o script.

Movido.

Compartilhar este post


Link para o post
pejuge2    1
pejuge2

Desculpe, não sabia que eram proibidos links. Obrigado pela aprovação.

 

TÓPICO EDITADO

Compartilhar este post


Link para o post
Demoniac Maker    0
Demoniac Maker

Nao curti muito mas Ficou bem Organizado o TOPICO vlw

Compartilhar este post


Link para o post
thays123    0
thays123

ixi tira isso dae coisa Ruim nem fufo aki :(

Compartilhar este post


Link para o post
pejuge2    1
pejuge2

qual o erro thays?

Compartilhar este post


Link para o post
Eduardo Santos    0
Eduardo Santos

ta bem rox =D

Compartilhar este post


Link para o post
pejuge2    1
pejuge2

Obrigad Eduardo

Compartilhar este post


Link para o post
kelsen    0
kelsen

Bem axei até legal e resolvi testa-lo no meu FTS 8.54 então quando botei para sumona-lo eis o erro

 

[Warning - Npc::loadFromXml] Cannot load npc file <data/npc/Master of Games.xml>

Line:8, info: Premature and of data in tag npc line 2

 

 

Bom se puder da uma ajuda eu agradeço

Compartilhar este post


Link para o post
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×