What's new

NPC The Gambling Man - Dice NPC!

Status
Not open for further replies.

OldTejdi

Senior User
Joined
Jul 18, 2008
Messages
537
Reaction score
49
[Skrypt nie jest m?j], ale V2 tak.

The Gambling Man - Dice NPC! v2

Zd8aNTo.png


~~Zasady gry:
- Grasz wybieraja low [liczby 1,2,3] lub high [liczby 4,5,6], je?eli trafisz wygrywasz zwrot swoich pieni?dzy + bonus 80% ich warto?ci. [grasz za 10k, wygrywasz 18k]
V2 - Dodana gra w numerki, gdzie gracz wybiera jedn? liczb? z 1/2/3/4/5/6 i wygrywa dodatkowe 400% pieni?dzy.

~~Notatki:
- % wygranej mo?e by? zmieniony w skrypcie wraz ze zmian? stawek minimalnych i maksymalnych.
- Konfiguracja mapy przedstawiona jest na screenie powy?ej, zwr?? szczeg?ln? uwag? na 3 stoliki, kostk? i ?wiec?c? p?ytk?.
- NPC nie uznaje gold coins.

~~Prezentacja video:

~~Skrypt:

1. Stw?rz nowy xml o nazwie the_gambling_man.xml i wklej do niego:
[xml]
<?xml version="1.0" encoding="UTF-8"?>
<npc name="The Gambling Man" script="data/npc/scripts/dice_gamble.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="494" head="38" body="87" legs="46" feet="46" addons="3"/>
</npc>
[/xml]
2a. Stw?rz skrypt do niego o nazwie dice_gamble.lua i wklej do niego je?eli chcesz bez gry na numerki:
[lua]
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end
function onPlayerEndTrade(cid) npcHandler:eek:nPlayerEndTrade(cid) end
function onPlayerCloseChannel(cid) npcHandler:eek:nPlayerCloseChannel(cid) end

local function delayMoneyRemoval(delayRemovedItem)
delayRemovedItem:remove(delayRemovedItem:getCount( ))
end

local function placeMoney(amount, table_middle_pos)
local remain = amount
local crystal_coins = 0
local platinum_coins = 0

if (math.floor(amount / 10000) >= 1) then
crystal_coins = math.floor(amount / 10000)
remain = remain - crystal_coins * 10000
end
if ((remain / 100) >= 1) then
platinum_coins = remain / 100
end
addEvent(doCreateItem, 550, 2152, platinum_coins, table_middle_pos)
addEvent(doCreateItem, 600, 2160, crystal_coins, table_middle_pos)
end

local function rollDice(roll, cc_count, pc_count, table_left_pos, table_middle_pos, npc)
local dice_ids = {5792, 5793, 5794, 5795, 5796, 5797}
local random_rollval = math.random(1,6)
local total_g = (10000 * cc_count) + (100 * pc_count)
local prize_percent = 0.8 -- 80%

if ((total_g) <= 300000 and (total_g) >= 5000) then
table_left_pos:sendMagicEffect(CONST_ME_CRAPS)

for _, itemId in pairs(dice_ids) do
if(getTileItemById(table_left_pos, itemId).uid > 0) then
doTransformItem(getTileItemById(table_left_pos, itemId).uid, dice_ids[random_rollval])
end
end

if (roll == 1 and random_rollval <= 3) then
placeMoney(total_g + (total_g * prize_percent), table_middle_pos)
addEvent(Position.sendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(Position.sendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
elseif (roll == 2 and random_rollval >= 4) then
placeMoney(total_g + (total_g * prize_percent), table_middle_pos)
addEvent(Position.sendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(Position.sendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
else
addEvent(Position.sendMagicEffect, 400, table_left_pos, CONST_ME_BLOCKHIT)
addEvent(Position.sendMagicEffect, 700, table_left_pos, CONST_ME_BLOCKHIT)
end
npc:say(string.format("%s rolled a %d.", npc:getName(), random_rollval), TALKTYPE_ORANGE_1, false, 0, npc:getPosition())
else
addEvent(doCreateItem, 100, 2160, cc_count, table_middle_pos)
addEvent(doCreateItem, 150, 2152, pc_count, table_middle_pos)
npc:say("The minimum wager is 5K and the maximum wager is 300K.", TALKTYPE_SAY, false, 0, npc:getPosition())
end
return true
end

function creatureSayCallback(cid, type, msg)
-- NPC userdata instance
local npc = Npc(getNpcCid())

-- Participating player userdata instance
local position = npc:getPosition() + {x = 2, y = 0, z = 0}
position.stackpos = STACKPOS_TOP_CREATURE
local player_uid = getThingfromPos(position).uid

-- Game table position userdata instances
local table_left_pos = Position(1110, 994, 8)
local table_middle_pos = Position(1111, 994, 8)

-- Search for coins on the left and middle tables and create item userdata instances
local table_left_cc_uid = getTileItemById(table_left_pos, 2160).uid
local table_middle_cc_uid = getTileItemById(table_middle_pos, 2160).uid
local table_left_pc_uid = getTileItemById(table_left_pos, 2152).uid
local table_middle_pc_uid = getTileItemById(table_middle_pos, 2152).uid

-- Other variables
local cc_count = 0
local pc_count = 0
local ROLL, LOW, HIGH = 0, 1, 2

if (player_uid ~= 0) then
player = Player(player_uid)
if ((msgcontains(string.lower(msg), 'high') and (player:isPlayer() and player:getId() == cid)) then
ROLL = HIGH
elseif ((msgcontains(string.lower(msg), 'low') and (player:isPlayer() and player:getId() == cid)) then
ROLL = LOW
else
return false
end
if (table_middle_cc_uid ~= 0) then
table_middle_cc = Item(table_middle_cc_uid)
cc_count = table_middle_cc:getCount()
table_middle_cc:moveTo(table_left_pos)
addEvent(delayMoneyRemoval, 300, table_middle_cc)
end
if (table_middle_pc_uid ~= 0) then
table_middle_pc = Item(table_middle_pc_uid)
pc_count = table_middle_pc:getCount()
table_middle_pc:moveTo(table_left_pos)
addEvent(delayMoneyRemoval, 300, table_middle_pc)
end
addEvent(rollDice, 500, ROLL, cc_count, pc_count, table_left_pos, table_middle_pos, npc)
else
return false
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)[/lua]

2b. Je?eli chcesz z gr? na numerki wklej V2:
[lua]
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

local function delayMoneyRemoval(item, pos)
doRemoveItem(getTileItemById(pos, item).uid)
return true
end

local function placeMoney(amount, table_middle_pos)
local remain = amount
local crystal_coins = 0
local platinum_coins = 0

if (math.floor(amount / 10000) >= 1) then
crystal_coins = math.floor(amount / 10000)
remain = remain - crystal_coins * 10000
end
if ((remain / 100) >= 1) then
platinum_coins = remain / 100
end
addEvent(doCreateItem, 550, 2152, platinum_coins, table_middle_pos)
addEvent(doCreateItem, 600, 2160, crystal_coins, table_middle_pos)
end

local function rollDice(roll, cc_count, pc_count, table_left_pos, table_middle_pos, npc)
local dice_ids = {5792, 5793, 5794, 5795, 5796, 5797}
local random_rollval = math.random(1,6)
local total_g = (10000 * cc_count) + (100 * pc_count)
local prize_percent = 0.8 -- 80%
local prize_percentl = 4.0 -- 400%

if ((total_g) <= 300000 and (total_g) >= 5000) then
doSendMagicEffect(table_left_pos, CONST_ME_CRAPS)

for _, itemId in pairs(dice_ids) do
if(getTileItemById(table_left_pos, itemId).uid > 0) then
doTransformItem(getTileItemById(table_left_pos, itemId).uid, dice_ids[random_rollval])
end
end

if (roll == 1 and random_rollval <= 3) then
placeMoney(total_g + (total_g * prize_percent), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 2 and random_rollval >= 4) then
placeMoney(total_g + (total_g * prize_percent), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 3 and random_rollval == 1) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 4 and random_rollval == 2) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 5 and random_rollval == 3) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 6 and random_rollval == 4) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 7 and random_rollval == 5) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 8 and random_rollval == 6) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
else
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_BLOCKHIT)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_BLOCKHIT)
addEvent(doCreatureSay, 500, npc, "Better luck next time.", TALKTYPE_SAY, false, 0)

end

doCreatureSay(npc, string.format("%s rolled a %d.", getCreatureName(npc), random_rollval), TALKTYPE_ORANGE_1, false, 0, table_left_pos)
else
addEvent(doCreateItem, 100, 2160, cc_count, table_middle_pos)
addEvent(doCreateItem, 150, 2152, pc_count, table_middle_pos)
doCreatureSay(npc, "The minimum wager is 5K and the maximum wager is 300K.", TALKTYPE_SAY, false, 0)
end
return true
end

function creatureSayCallback(cid, type, msg)
-- NPC userdata instance
local npc = getNpcCid()

-- Participating player userdata instance
local position = {x = getNpcPos().x+2, y = getNpcPos().y, z = getNpcPos().z}
position.stackpos = STACKPOS_TOP_CREATURE
local player_uid = getThingfromPos(position).uid

-- Game table position userdata instances
local table_left_pos = {x = 1088, y = 512, z = 7}
local table_middle_pos = {x = 1089, y = 512, z = 7}

-- Search for coins on the left and middle tables and create item userdata instances
local table_middle_cc = getTileItemById(table_middle_pos, 2160)
local table_middle_pc = getTileItemById(table_middle_pos, 2152)

-- Other variables
local cc_count = 0
local pc_count = 0
local ROLL, LOW, HIGH, ROL1, ROL2, ROL3, ROL4, ROL5, ROL6 = 0, 1, 2, 3, 4, 5, 6, 7, 8


if (player_uid ~= 0) then
if ((msgcontains(string.lower(msg), 'high') or msgcontains(string.lower(msg), 'h')) or msgcontains(string.lower(msg), '456') and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = HIGH
elseif ((msgcontains(string.lower(msg), 'low') or msgcontains(string.lower(msg), 'l')) or msgcontains(string.lower(msg), '123') and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = LOW
elseif ((msgcontains(string.lower(msg), '1')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL1
elseif ((msgcontains(string.lower(msg), '2')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL2
elseif ((msgcontains(string.lower(msg), '3')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL3
elseif ((msgcontains(string.lower(msg), '4')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL4
elseif ((msgcontains(string.lower(msg), '5')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL5
elseif ((msgcontains(string.lower(msg), '6')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL6
else
return false
end

if (table_middle_cc.uid ~= 0) then
cc_count = table_middle_cc.type
doTeleportThing(table_middle_cc.uid, table_left_pos)
addEvent(delayMoneyRemoval, 300, 2160, table_left_pos)
end
if (table_middle_pc.uid ~= 0) then
pc_count = table_middle_pc.type
doTeleportThing(table_middle_pc.uid, table_left_pos)
addEvent(delayMoneyRemoval, 300, 2152, table_left_pos)
end
addEvent(rollDice, 500, ROLL, cc_count, pc_count, table_left_pos, table_middle_pos, npc)
else
return false
end
return true
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)[/lua]

~~Dodatkowe funkcje:
-anti-trasher:

1. Do movements.xml dodaj:
[xml]
<!-- Dice trash prevention -->
<movevent event="AddItem" pos="1110;994;8" script="trash_prevent.lua"/> <!-- {x = 1110, y = 994, z = 8} -->
<movevent event="AddItem" pos="1111;994;8" script="trash_prevent.lua"/> <!-- {x = 1111, y = 994, z = 8} -->
<movevent event="AddItem" pos="1112;994;8" script="trash_prevent.lua"/> <!-- {x = 1112, y = 994, z = 8} -->
[/xml]

2. Dodaj skrypt "trash_prevent.lua" i wklej do niego:
[lua]
local item_exceptions = {2152, 2160, 5792, 5793, 5794, 5795, 5796, 5797}

function onAddItem(item, tile, pos)
if not isInArray(item_exceptions, item.itemid) then
doRemoveItem(item.uid)
end
return true
end
[/lua]

LUB

[lua]
local item_exceptions = {2152, 2160, 5792, 5793, 5794, 5795, 5796, 5797}

function onAddItem(item, tile, pos)
if not isInArray(item_exceptions, item.itemid) then
doTeleportThing(item.uid, {x = pos.x + 1, y = pos.y, z = pos.z})
end
return true
end
[/lua]


07.02.2014 - V2 - Dodano gr? na numerki.
 

Wildhells

Senior User
Joined
Feb 4, 2012
Messages
2,346
Reaction score
119
Odp: The Gambling Man - Dice NPC!

Popraw bbcode w ostatnim kodzie, a og?lnie skrypt bardzo przyjemny. Dobra robota, repucik.
 

OldTejdi

Senior User
Joined
Jul 18, 2008
Messages
537
Reaction score
49
Odp: The Gambling Man - Dice NPC!

BumP.
Wysz?o V2.
Kto? czyta lub u?ywa? :c
 

Placek

Blue Waffle
Joined
Sep 30, 2008
Messages
6,793
Reaction score
672
Age
9
Odp: The Gambling Man - Dice NPC!

Lepiej by bylo sklecic te 2 gry i gracz by przy wejsciu wybieral w ktora chce grac. A nie osobne skrypty ;P
Poza tym dosc fajne jesli chodzi o sam skrypt. Ale jak to sie ma nadawac na serwer? Moim zdaniem dosc srednio to wyglada. Tak samo jak te wszystkie kasyna z dzwigniami dziala. Problem taki, ze albo sie traci bo wygrac praktycznie nie mozliwe na dluzsza mete, i stoi puste kasyno. Albo sie zarabia miliony i kolejki sie ustawiaja graczy zeby miec mase kasy. Takze jednym slowem dupa z tego wychodzi a nie cos przydatnego.
Jakiegos konkretnego rozwiazania nie widze. Chyba, ze opcja gracz vs gracz. Ale do tego juz nie potrzeba skryptu, sama kostka starczy. Chyba, ze jako zabezpieczenie, zeby nikt nie oszukiwal...
 

OldTejdi

Senior User
Joined
Jul 18, 2008
Messages
537
Reaction score
49
Odp: The Gambling Man - Dice NPC!

Skrypt ??czy i gr? high/low i 1/2/3/4/5/6 czy?by Kikimora nie przeczyta? skryptu zanim si? udzieli?..?
Gracze nie b?d? oszukiwa?, nie musz? stawia? bot?w. Czy ja wiem czy zarobi? miliony? Raczej osoba wystawiaj?ca kostk? zarabia [przyk?ad shadowcores, 0 wolnych depo w yalahar, thais i venore bo wsz?dzie kostki]
 

Anakonta

Senior User
Joined
Oct 5, 2010
Messages
536
Reaction score
10
Odp: The Gambling Man - Dice NPC!

Intryguj?cy skrypt, z pewno?ci? si? przyda, zapisuje do mojej listy wartych uwagi skrypt?w.
 

Placek

Blue Waffle
Joined
Sep 30, 2008
Messages
6,793
Reaction score
672
Age
9
Odp: The Gambling Man - Dice NPC!

Skrypt ??czy i gr? high/low i 1/2/3/4/5/6 czy?by Kikimora nie przeczyta? skryptu zanim si? udzieli?..?

A po co niby mam czytac skrypt? Jak bym go mial zamiar uzywac, cos w nim zmieniac lub poprawic ewentualne bledy to moge zagladac. A tak to szkoda czasu.
Przeczytalem opis. Ale w sumie tez nie dokladnie, dlatego nie ogarnalem. Przeczytalem, ze pierwszy skrypt to h/l a drugi na numerki. A ten drugi ma obie opcje ;P

Czy ja wiem czy zarobi? miliony? Raczej osoba wystawiaj?ca kostk? zarabia [przyk?ad shadowcores, 0 wolnych depo w yalahar, thais i venore bo wsz?dzie kostki]

A przeczytales chociaz moj post?
Sa 2 opcje. Albo zarobi miliony, albo bedzie tracic, lub zarabiac tak wolno, ze szkoda czasu stac przy takim npcku. Na nie jednym otsie juz kasyno bylo wiec nie jest tajemnica jak to dziala.
Poza tym, tez mowilem o grze gracz vs gracz.

Na takim shadowie ludzie stawiaja boty jak by oni byli tymi npckami i to oni chca zarobic. A jak gracze taka gre uruchamiaja to inni gracze z racji popularnosci czasem rzuca troche grosza liczac na cos... A z npckami bylo by pewnie troche inaczej. Zreszta kurwa, ciezko mi wyjasnic o co mi chodzi, zawsze bylem kiepski w wyjasnianiu.
Poza tym, jak juz by byly npcki np nawet na tym shadowie, to gracze by dali 5% wiecej nagrody i npcki by znow byly puste xd

Zreszta koniec pierdolenia. Byly skrypty na kasyna wszedzie i rozne, z roznymi nagrodami i zawsze wszedzie jest to samo. Albo kolejki bo zarabia sie spamujac dzwinia(w tym wypadku do npc). Albo pustki bo sie nie zarabia albo zarabia marne grosze... I nie wmowisz mi, ze gdzies kasyno sie sprawdzalo na dluzsza mete. ;p
 

OldTejdi

Senior User
Joined
Jul 18, 2008
Messages
537
Reaction score
49
Odp: The Gambling Man - Dice NPC!

Owszem sprawdzi?o si?, m?wi? tutaj o barach nieopodal mojego miejsca zamieszkania.
Ludzie w tibii pragn? tak samo hazardu jak w realnym ?wiecie, spr?buj? raz, raz wygraj?, wi?c id? po wi?cej ; )
 

Kahras

Senior User
Joined
Aug 26, 2011
Messages
2,714
Reaction score
167
Age
25
Odp: The Gambling Man - Dice NPC!

Skrypt mi si? podoba wgl pomys? fajny i oklepany lecz mi si? to nie przyda poniewa? no szkoda mi miejsca na mapie na te kasyna itd.
 

Dantez

Moim sekretem jest ciasto
Joined
May 22, 2008
Messages
1,206
Reaction score
202
Odp: The Gambling Man - Dice NPC!

[LUA]if (roll == 1 and random_rollval <= 3) then
placeMoney(total_g + (total_g * prize_percent), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 2 and random_rollval >= 4) then
placeMoney(total_g + (total_g * prize_percent), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 3 and random_rollval == 1) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 4 and random_rollval == 2) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 5 and random_rollval == 3) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 6 and random_rollval == 4) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 7 and random_rollval == 5) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
elseif (roll == 8 and random_rollval == 6) then
placeMoney(total_g + (total_g * prize_percentl), table_middle_pos)
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_SOUND_GREEN)
addEvent(doCreatureSay, 500, npc, "You win!", TALKTYPE_SAY, false, 0)
else
addEvent(doSendMagicEffect, 400, table_left_pos, CONST_ME_BLOCKHIT)
addEvent(doSendMagicEffect, 700, table_left_pos, CONST_ME_BLOCKHIT)
addEvent(doCreatureSay, 500, npc, "Better luck next time.", TALKTYPE_SAY, false, 0)

end[/LUA]
Tejdiasz... Skr?? ten syf.

[LUA]local ROLL, LOW, HIGH, ROL1, ROL2, ROL3, ROL4, ROL5, ROL6 = 0, 1, 2, 3, 4, 5, 6, 7, 8


if (player_uid ~= 0) then
if ((msgcontains(string.lower(msg), 'high') or msgcontains(string.lower(msg), 'h')) or msgcontains(string.lower(msg), '456') and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = HIGH
elseif ((msgcontains(string.lower(msg), 'low') or msgcontains(string.lower(msg), 'l')) or msgcontains(string.lower(msg), '123') and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = LOW
elseif ((msgcontains(string.lower(msg), '1')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL1
elseif ((msgcontains(string.lower(msg), '2')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL2
elseif ((msgcontains(string.lower(msg), '3')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL3
elseif ((msgcontains(string.lower(msg), '4')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL4
elseif ((msgcontains(string.lower(msg), '5')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL5
elseif ((msgcontains(string.lower(msg), '6')and (isPlayer(player_uid) and player_uid == cid))) then
ROLL = ROL6
else
return false
end[/LUA]
Kolejny syf. Po co string.lower skoro szukasz liczb, wyjmij isPlayer i player_uid przed ca?o??, usu? te ROL1 itd. i wpisuj r?cznie.

Skrypt jest niepraktyczny z jednego podstawowego powodu - pozycj? wpisujemy r?cznie, co uniemo?liwia postawienie jednego ni? 1 NPC o tym samym skrypcie.
 
Last edited:

Skajowski

Senior User
Joined
Jun 11, 2010
Messages
1,160
Reaction score
90
Odp: The Gambling Man - Dice NPC!

M?g?by? zrobi? jeszcze ?eby po jakims czasie dawa?o tp. Og?lnie skrypt zajebisty :)
 

OldTejdi

Senior User
Joined
Jul 18, 2008
Messages
537
Reaction score
49
Odp: The Gambling Man - Dice NPC!

Drogi dantezie, nie znam si? na .lua tak dobrze. By?em w stanie doda? tylko gry na numerki :p.

Btw. npcty mo?na stawia? ile si? chce, to w anty thrash wpisuje si? pozycje ;)
 
Last edited:
Status
Not open for further replies.
Top