Ir para conteúdo

Featured Replies

Postado

Olá tk meu problema é o npc não verifica se tem dinheiro ele joga sem ter dinheiro.

-- Preços das apostas --

aposta1 = 1000000 -- 1k ou 1000gold
premio1 = 2000000 -- 1k ou 1000gold
aposta2 = 1000000 -- 1k ou 1000gold
premio2 = 2000000 -- 1k ou 1000gold
aposta3 = 100000000 -- 1k ou 1000gold
premio3 = 200000000 -- 1k ou 1000gold
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

function thinkCallback(cid)
local rand = math.random(1,100)
if rand == 1 then
selfSay('Oi! Ganhe dinheiro com sua sorte!') -- msg que vai sair do npc
end
if rand == 2 then
selfSay ('Só entendo português, diga oi.')
end
if rand == 3 then
selfSay ('Posso te ajudar?')
end
return true
end
function greetCallback(cid)
return true
end

local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'jogar')) then
selfSay('O jogo é bem simples, você só precisa decidir se quer apostar 1 crystal coin, 10 crystal coins ou 100 crystal coins. Após decidir sua aposta, será sorteado um número entre 1 e 10 para mim e para você, vence quem sortear o maior número. Se der empate, você recebe o dinheiro da aposta de volta, se você ganhar receberá o dobro do valor da aposta e se perder eu fico com o seu dinheiro da aposta. Diga {1 crystal coin}, {10 crystal coins} ou {100 crystal coins} para começar o jogo.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, '1 crystal coin') and talkState[talkUser] == 1) then
selfSay('Você tem certeza que quer apostar 1 crystal coin?', cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'sim') and talkState[talkUser] == 1) then
if doPlayerRemoveMoney(cid, aposta1) == TRUE then
talkState[talkUser] = 0
local mpn = math.random(1,10)
local npcn = math.random(1,10)
setPlayerStorageValue(cid, 2224, npcn)
setPlayerStorageValue(cid, 55411, mpn)
if getPlayerStorageValue(cid, 55411) < getPlayerStorageValue(cid, 2224)then
selfSay('Seu número: '..getPlayerStorageValue(cid, 55411)..'. Meu número: '..getPlayerStorageValue(cid, 2224)..'. Você Perdeu!',cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, 55411) == getPlayerStorageValue(cid, 2224) then
selfSay('Seu número: '..getPlayerStorageValue(cid, 55411)..'. Meu número: '..getPlayerStorageValue(cid, 2224)..'. Deu Empate!',cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, 55411) > getPlayerStorageValue(cid, 2224) then
selfSay('Seu número: '..getPlayerStorageValue(cid, 55411)..'. Meu número: '..getPlayerStorageValue(cid, 2224)..'. Você Venceu!',cid)
doPlayerAddMoney(cid, premio1)
talkState[talkUser] = 1
else
selfSay('Desculpe, mais você não possui dinheiro está aposta',cid)
end
elseif(msgcontains(msg, '10 crystal coin') and talkState[talkUser] == 1) then
selfSay('Você tem certeza que quer apostar 10 crystal coin?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'sim') and talkState[talkUser] == 1) then
if doPlayerRemoveMoney(cid, aposta2) == TRUE then
end
local mpn2 = math.random(1,10)
local npcn2 = math.random(1,10)
setPlayerStorageValue(cid, 2225, npcn2)
setPlayerStorageValue(cid, 55412, mpn2)
if getPlayerStorageValue(cid, 55412) < getPlayerStorageValue(cid, 2225)then
selfSay('Seu número: '..getPlayerStorageValue(cid, 55412)..'. Meu número: '..getPlayerStorageValue(cid, 2225)..'. Você Perdeu!',cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, 55412) == getPlayerStorageValue(cid, 2225) then
selfSay('Seu número: '..getPlayerStorageValue(cid, 55412)..'. Meu número: '..getPlayerStorageValue(cid, 2225)..'. Deu Empate!',cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, 55412) > getPlayerStorageValue(cid, 2225) then
selfSay('Seu número: '..getPlayerStorageValue(cid, 55412)..'. Meu número: '..getPlayerStorageValue(cid, 2225)..'. Você Venceu!',cid)
doPlayerAddMoney(cid, premio2)
talkState[talkUser] = 1
else
selfSay('Desculpe, mais você não possui dinheiro está aposta',cid)
end
elseif(msgcontains(msg, '100 crystal coin') and talkState[talkUser] == 1) then
selfSay('Você tem certeza que quer apostar 100 crystal coin?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'sim') and talkState[talkUser] == 1) then
if doPlayerRemoveMoney(cid, aposta3) == TRUE then
end
local mpn = math.random(1,10)
local npcn = math.random(1,10)
setPlayerStorageValue(cid, 2226, npcn)
setPlayerStorageValue(cid, 55413, mpn)
if getPlayerStorageValue(cid, 55413) < getPlayerStorageValue(cid, 2226)then
selfSay('Seu número: '..getPlayerStorageValue(cid, 55413)..'. Meu número: '..getPlayerStorageValue(cid, 2226)..'. Você Perdeu!',cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, 55413) == getPlayerStorageValue(cid, 2226) then
selfSay('Seu número: '..getPlayerStorageValue(cid, 55413)..'. Meu número: '..getPlayerStorageValue(cid, 2226)..'. Deu Empate!',cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, 55413) > getPlayerStorageValue(cid, 2226) then
selfSay('Seu número: '..getPlayerStorageValue(cid, 55413)..'. Meu número: '..getPlayerStorageValue(cid, 2226)..'. Você Venceu!',cid)
doPlayerRemoveItem(cid,2160,100)
doPlayerAddMoney(cid, premio3)
talkState[talkUser] = 1
else
selfSay('Desculpe, mais você não possui dinheiro está aposta',cid)
end end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Editado por damiaotorres (veja o histórico de edições)

  • Respostas 9
  • Visualizações 304
  • Created
  • Última resposta

Top Posters In This Topic

Postado
local tab = {
aposta1 = {1000000, 2000000}, -- apostaN = {custo, premio},
aposta2 = {1000000, 2000000},
aposta3 = {100000000, 200000000}
}

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

function thinkCallback(cid)
	local rand = math.random(1,100)
		if rand == 1 then
			selfSay('Oi! Ganhe dinheiro com sua sorte!')
		end
			if rand == 2 then
				selfSay ('Só entendo português, diga oi.')
			end
		if rand == 3 then
			selfSay ('Posso te ajudar?')
		end
	return true
end

function greetCallback(cid)
	return true
end

	local mpn = math.random(1,10)
	local npcn = math.random(1,10)
	local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
		if(msgcontains(msg, 'jogar')) then
			selfSay('O jogo é bem simples, você só precisa decidir se quer apostar 1 crystal coin, 10 crystal coins ou 100 crystal coins. Após decidir sua aposta, será sorteado um número entre 1 e 10 para mim e para você, vence quem sortear o maior número. Se der empate, você recebe o dinheiro da aposta de volta, se você ganhar receberá o dobro do valor da aposta e se perder eu fico com o seu dinheiro da aposta. Diga {1 crystal coin}, {10 crystal coins} ou {100 crystal coins} para começar o jogo.', cid)
			talkState[talkUser] = 1
		elseif(msgcontains(msg, '1 crystal coin') and talkState[talkUser] == 1) then
			selfSay('Você tem certeza que quer apostar 1 crystal coin?', cid)
			talkState[talkUser] = 0
		elseif(msgcontains(msg, 'sim') and talkState[talkUser] == 1) then
			if getPlayerMoney(cid) >= tab.aposta1[1] then
				doPlayerRemoveMoney(cid, tab.aposta1[1])
				setPlayerStorageValue(cid, 2224, npcn)
				setPlayerStorageValue(cid, 55411, mpn)
				talkState[talkUser] = 0
				if getPlayerStorageValue(cid, 55411) < getPlayerStorageValue(cid, 2224)then
					selfSay('Seu número: '..getPlayerStorageValue(cid, 55411)..'. Meu número: '..getPlayerStorageValue(cid, 2224)..'. Você Perdeu!',cid)
					talkState[talkUser] = 1
				elseif getPlayerStorageValue(cid, 55411) == getPlayerStorageValue(cid, 2224) then
					selfSay('Seu número: '..getPlayerStorageValue(cid, 55411)..'. Meu número: '..getPlayerStorageValue(cid, 2224)..'. Deu Empate!',cid)
					talkState[talkUser] = 1
				elseif getPlayerStorageValue(cid, 55411) > getPlayerStorageValue(cid, 2224) then
					selfSay('Seu número: '..getPlayerStorageValue(cid, 55411)..'. Meu número: '..getPlayerStorageValue(cid, 2224)..'. Você Venceu!',cid)
					doPlayerAddMoney(cid, tab.aposta1[2])
					talkState[talkUser] = 1
				end
			else
				selfSay('Desculpe, mas você não possui dinheiro para esta aposta',cid)
			end
		elseif(msgcontains(msg, '10 crystal coin') and talkState[talkUser] == 1) then
			selfSay('Você tem certeza que quer apostar 10 crystal coin?', cid)
			talkState[talkUser] = 1
		elseif(msgcontains(msg, 'sim') and talkState[talkUser] == 1) then
			if getPlayerMoney(cid) >= tab.aposta2[1] then
				doPlayerRemoveMoney(cid, tab.aposta2[1])
				setPlayerStorageValue(cid, 2225, npcn)
				setPlayerStorageValue(cid, 55412, mpn)
				if getPlayerStorageValue(cid, 55412) < getPlayerStorageValue(cid, 2225)then
					selfSay('Seu número: '..getPlayerStorageValue(cid, 55412)..'. Meu número: '..getPlayerStorageValue(cid, 2225)..'. Você Perdeu!',cid)
					talkState[talkUser] = 1
				elseif getPlayerStorageValue(cid, 55412) == getPlayerStorageValue(cid, 2225) then
					selfSay('Seu número: '..getPlayerStorageValue(cid, 55412)..'. Meu número: '..getPlayerStorageValue(cid, 2225)..'. Deu Empate!',cid)
					talkState[talkUser] = 1
				elseif getPlayerStorageValue(cid, 55412) > getPlayerStorageValue(cid, 2225) then
					selfSay('Seu número: '..getPlayerStorageValue(cid, 55412)..'. Meu número: '..getPlayerStorageValue(cid, 2225)..'. Você Venceu!',cid)
					doPlayerAddMoney(cid, tab.aposta2[2])
					talkState[talkUser] = 1
				end
			else
				selfSay('Desculpe, mas você não possui dinheiro para esta aposta',cid)
			end
		elseif(msgcontains(msg, '100 crystal coin') and talkState[talkUser] == 1) then
			selfSay('Você tem certeza que quer apostar 100 crystal coin?', cid)
			talkState[talkUser] = 1
		elseif(msgcontains(msg, 'sim') and talkState[talkUser] == 1) then
			if getPlayerMoney(cid) >= tab.aposta3[1] then
				doPlayerRemoveMoney(cid, tab.aposta3[1])
				setPlayerStorageValue(cid, 2226, npcn)
				setPlayerStorageValue(cid, 55413, mpn)
				if getPlayerStorageValue(cid, 55413) < getPlayerStorageValue(cid, 2226)then
					selfSay('Seu número: '..getPlayerStorageValue(cid, 55413)..'. Meu número: '..getPlayerStorageValue(cid, 2226)..'. Você Perdeu!',cid)
					talkState[talkUser] = 1
				elseif getPlayerStorageValue(cid, 55413) == getPlayerStorageValue(cid, 2226) then
					selfSay('Seu número: '..getPlayerStorageValue(cid, 55413)..'. Meu número: '..getPlayerStorageValue(cid, 2226)..'. Deu Empate!',cid)
					talkState[talkUser] = 1
				elseif getPlayerStorageValue(cid, 55413) > getPlayerStorageValue(cid, 2226) then
					selfSay('Seu número: '..getPlayerStorageValue(cid, 55413)..'. Meu número: '..getPlayerStorageValue(cid, 2226)..'. Você Venceu!',cid)
					doPlayerAddMoney(cid, tab.aposta3[2])
					talkState[talkUser] = 1
				end
			else
				selfSay('Desculpe, mas você não possui dinheiro para esta aposta',cid)
			end
		end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Editado por Suicide (veja o histórico de edições)

The corrupt fear us.

The honest support us.

The heroic join us.

Postado

Só fiz a tabela como exemplificação, configura aqui brother:

local tab = {
aposta1 = {1000000, 2000000}, -- apostaN = {custo, premio},
aposta2 = {1000000, 2000000},
aposta3 = {100000000, 200000000}
}

Caso tenha dificuldade em configurar:
1k = 1000
10k = 10000
100k = 100000
1000k (1kk) = 1000000

The corrupt fear us.

The honest support us.

The heroic join us.

Postado
  • Autor

Eu configurei mais mesmo assim tira 1kk do mesmo jeito foi algo em 

 

if getPlayerMoney(cid) >= tab.aposta1[1] then

doPlayerRemoveMoney(cid, tab.aposta1)

 

teste ae e tente ajeitar pf,ver se arruma o de 1 crystal coin que não ta prestando pf ae

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.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo