• logo_cipsoft
    Nowe serwery zostały otwarte 19 Lut 2025:
    Noctalia (Open PvP) Ignitera (Open PvP) us_logo Xybra (Open PvP)

-Skrypt Npc Ktory Lossuje

Status
Zamknięty.

Avemajor

Advanced User
Dołączył
Luty 6, 2012
Posty
346
Liczba reakcji
12
Potrzebuje skrypt na npc do kt?rego si? podchodzi podaje liczb? od 1-6. Npc lossuje kostk? je?li wypadnie inny niz podany teleportuje do temple je?li wpadnie podana liczba teleportuje Dalej​
 
Odp: Npc Ktory Lossuje

Numery ma losowa? z kostki z wyznaczonej pozycji czy w jaki spos?b?
 
Odp: Npc Ktory Lossuje

[MENTION=353628]buchaLL[/MENTION]
tak z wyznnaczonej pozycji
 
Ostatnia edycja:
Odp: Npc Ktory Lossuje

@Refrsh , do??czam sie do pro?by :D Buchaal na pewno ogarniesz ! :D
 
Odp: Npc Ktory Lossuje

Bez ?adnych p?tli, jutro skr?c? kod.
[xml]<npc name="Cassino" script="data/npc/scripts/cassino.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="132" head="17" body="54" legs="114" feet="0" addons="3"/>
</npc>[/xml]

[lua]local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local npc = getNpcCid()
local player_pos = {x = 458, y = 501, z = 7}
player_pos.stackpos = STACKPOS_TOP_CREATURE
local player_uid = getThingfromPos(player_pos).uid
local dice_pos = {x = 456, y = 502, z = 7}
local win_teleport_to = {x = 460, y = 501, z = 7}
local ROLL, num1, num2, num3, num4, num5, num6 = 0, 1, 2, 3, 4, 5, 6

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 function rollDice(roll, dice_pos, npc)
local dice_ids = {5792, 5793, 5794, 5795, 5796, 5797}
local random_rollval = math.random(1,6)

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

doCreatureSay(npc, string.format("%s rolled a %d.", getCreatureName(npc), random_rollval), TALKTYPE_ORANGE_1, false, 0, dice_pos)

if (roll == 1 and random_rollval == 1) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 2 and random_rollval == 2) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 3 and random_rollval == 3) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 4 and random_rollval == 4) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 5 and random_rollval == 5) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 6 and random_rollval == 6) then
doTeleportThing(player_uid, win_teleport_to, true)
else
doTeleportThing(player_uid, getTownTemplePosition(getPlayerTown(player_uid)), true)
return true
end
return true
end

function creatureSayCallback(cid, type, msg)

if (player_uid ~= 0) then
if (isPlayer(player_uid) and player_uid == cid) then
if msg == "1" then
ROLL = num1
elseif msg == "2" then
ROLL = num2
elseif msg == "3" then
ROLL = num3
elseif msg == "4" then
ROLL = num4
elseif msg == "5" then
ROLL = num5
elseif msg == "6" then
ROLL = num6
else
return false
end
end
addEvent(rollDice, 500, ROLL, dice_pos, npc)
else
return false
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)[/lua]
 
Ostatnia edycja:
Odp: Npc Ktory Lossuje

[0:2:42.798] [Error - NpcScript Interface]
[0:2:42.798] (Unknown script file)
[0:2:42.798] DescriptionI/O warning : failed to load external entity "data/npc/Cassino.xml"
I/O warning : failed to load external entity "data/npc/Cassino.xml"


Jak robie npc wyskakuje mi ?e nie ma miejsca w tym pokoju

---------- Tre?? dodana o 00:04 ----------
[MENTION=353628]buchaLL[/MENTION]

---------- Tre?? dodana o 00:28 ----------

Dodatkowo testowane ze znajomym niby podchodzi pisze 1 wyrzuca mnie, osobe stoj?ca za npc natomiast go nie rusza wgl

---------- Tre?? dodana o 00:30 ----------

I losuje nawet jak napisze si? "XD" po, trafieniu w liczbe nie teleportuje na dana pozycje :.
 
Odp: Npc Ktory Lossuje

[lua]
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local npc = getNpcCid()
local player_pos = {x = 1050, y = 1445, z = 7}
player_pos.stackpos = STACKPOS_TOP_CREATURE
local player_uid = getThingfromPos(player_pos).uid
local dice_pos = {x = 1050, y = 1443, z = 7}
local win_teleport_to = {x = 1047, y = 1443, z = 7}
local ROLL, num1, num2, num3, num4, num5, num6 = 0, 1, 2, 3, 4, 5, 6


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 function rollDice(roll, dice_pos, npc)
local dice_ids = {5792, 5793, 5794, 5795, 5796, 5797}
local random_rollval = math.random(1,6)

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



doCreatureSay(npc, string.format("Dice Event Losuje" .. random_rollval .. "a"), TALKTYPE_ORANGE_1, false, 0, dice_pos)


if (roll == 1 and random_rollval == 1) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 2 and random_rollval == 2) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 3 and random_rollval == 3) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 4 and random_rollval == 4) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 5 and random_rollval == 5) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 6 and random_rollval == 6) then
doTeleportThing(player_uid, win_teleport_to, true)
else
doTeleportThing(player_uid, getTownTemplePosition(getPlayerTown(player_uid)), true)
return true
end
return true
end

function creatureSayCallback(cid, type, msg)

if (player_uid ~= 0) then
if (isPlayer(player_uid) and player_uid == cid) then
if msg == "1" then
ROLL = num1
elseif msg == "2" then
ROLL = num2
elseif msg == "3" then
ROLL = num3
elseif msg == "4" then
ROLL = num4
elseif msg == "5" then
ROLL = num5
elseif msg == "6" then
ROLL = num6
else
return false
end
end
addEvent(rollDice, 500, ROLL, dice_pos, npc)
else
return false
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
[/lua]
Ja mam tak - lekko zmieniony creature say bo inaczej nie dzialal skrypt ;p >>> tylko jest jeden problem NPC zapisuje tylko 1 osobe ktora do niego napisze, czyli - Jesli ja napisze 3 i mnie kicknie do temple pojde gdzies i ktos inny podejdzie napisze np. 2 i to zn?w zle wylosowane to znow MNIe kicka do temple a on stoi na pozycji dalej i moze tak ciagle pisac liczby a mnie ciagle bedzie tepac ;p

---------- Tre?? dodana o 19:58 ----------
[MENTION=353628]buchaLL[/MENTION] , pomys? jakis ?
 
Odp: Npc Ktory Lossuje

Na chwil? obecn? dzia?aj?cy kod(skr?c? to edytuj? post):
[lua]local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 function rollDice(roll, dice_pos, npc)
local dice_ids = {5792, 5793, 5794, 5795, 5796, 5797}
local random_rollval = math.random(1,6)
local win_teleport_to = {x = 460, y = 501, z = 7}
local npc = getNpcCid()
local player_pos = {x = 458, y = 501, z = 7}
player_pos.stackpos = STACKPOS_TOP_CREATURE
local player_uid = getThingfromPos(player_pos).uid

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

doCreatureSay(npc, string.format("%s rolled a %d.", getCreatureName(npc), random_rollval), TALKTYPE_ORANGE_1, false, 0, dice_pos)

if (roll == 1 and random_rollval == 1) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 2 and random_rollval == 2) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 3 and random_rollval == 3) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 4 and random_rollval == 4) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 5 and random_rollval == 5) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 6 and random_rollval == 6) then
doTeleportThing(player_uid, win_teleport_to, true)
else
doTeleportThing(player_uid, getTownTemplePosition(getPlayerTown(player_uid)), true)
end
return true
end

function creatureSayCallback(cid, type, msg)

local npc = getNpcCid()
local player_pos = {x = 458, y = 501, z = 7}
player_pos.stackpos = STACKPOS_TOP_CREATURE
local player_uid = getThingfromPos(player_pos).uid
local dice_pos = {x = 456, y = 502, z = 7}
local ROLL, num1, num2, num3, num4, num5, num6 = 0, 1, 2, 3, 4, 5, 6

if (player_uid ~= 0) then
if (msg == "1" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num1
elseif (msg == "2" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num2
elseif (msg == "3" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num3
elseif (msg == "4" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num4
elseif (msg == "5" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num5
elseif (msg == "6" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num6
else
return false
end
addEvent(rollDice, 500, ROLL, dice_pos, npc)
else
return false
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)[/lua]
 
Ostatnia edycja:
Odp: Npc Ktory Lossuje

Na chwil? obecn? dzia?aj?cy kod(skr?c? to edytuj? post):
[lua]local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 function rollDice(roll, dice_pos, npc)
local dice_ids = {5792, 5793, 5794, 5795, 5796, 5797}
local random_rollval = math.random(1,6)
local win_teleport_to = {x = 460, y = 501, z = 7}
local npc = getNpcCid()
local player_pos = {x = 458, y = 501, z = 7}
player_pos.stackpos = STACKPOS_TOP_CREATURE
local player_uid = getThingfromPos(player_pos).uid

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

doCreatureSay(npc, string.format("%s rolled a %d.", getCreatureName(npc), random_rollval), TALKTYPE_ORANGE_1, false, 0, dice_pos)

if (roll == 1 and random_rollval == 1) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 2 and random_rollval == 2) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 3 and random_rollval == 3) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 4 and random_rollval == 4) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 5 and random_rollval == 5) then
doTeleportThing(player_uid, win_teleport_to, true)
elseif (roll == 6 and random_rollval == 6) then
doTeleportThing(player_uid, win_teleport_to, true)
else
doTeleportThing(player_uid, getTownTemplePosition(getPlayerTown(player_uid)), true)
end
return true
end

function creatureSayCallback(cid, type, msg)

local npc = getNpcCid()
local player_pos = {x = 458, y = 501, z = 7}
player_pos.stackpos = STACKPOS_TOP_CREATURE
local player_uid = getThingfromPos(player_pos).uid
local dice_pos = {x = 456, y = 502, z = 7}
local ROLL, num1, num2, num3, num4, num5, num6 = 0, 1, 2, 3, 4, 5, 6

if (player_uid ~= 0) then
if (msg == "1" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num1
elseif (msg == "2" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num2
elseif (msg == "3" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num3
elseif (msg == "4" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num4
elseif (msg == "5" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num5
elseif (msg == "6" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num6
else
return false
end
addEvent(rollDice, 500, ROLL, dice_pos, npc)
else
return false
end
return true
end

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

Dzi?ki a da?by? jeszcze rade zrobi? ?e przy
Wygranej Wysy?a wiadomo?c Og?ln? "Gratulacje wylosowa?es "nr" i Wygrales
a jezeli wylosujje inna liczb? to "Niestety tw?j numer nie by? szcz?sliwi
 
Odp: Npc Ktory Lossuje

Prosz?. ;>
[lua]local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 function rollDice(roll, dice_pos, npc)
local dice_ids = {5792, 5793, 5794, 5795, 5796, 5797}
local random_rollval = math.random(1,6)
local win_teleport_to = {x = 460, y = 501, z = 7}
local dice_pos = {x = 456, y = 502, z = 7}
local npc = getNpcCid()
local player_pos = {x = 458, y = 501, z = 7}
player_pos.stackpos = STACKPOS_TOP_CREATURE
local player_uid = getThingfromPos(player_pos).uid

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

doCreatureSay(npc, string.format("%s rolled a %d.", getCreatureName(npc), random_rollval), TALKTYPE_ORANGE_1, false, 0, dice_pos)

if (roll == random_rollval) then
doTeleportThing(player_uid, win_teleport_to, true)
doPlayerSendTextMessage(player_uid, MESSAGE_STATUS_CONSOLE_ORANGE, "Gratulacje numer ".. random_rollval .. " zgadza sie z wylosowanym, wygrywasz!")
else
doTeleportThing(player_uid, getTownTemplePosition(getPlayerTown(player_uid)), true)
doPlayerSendTextMessage(player_uid, MESSAGE_STATUS_CONSOLE_ORANGE, "Niestety numer ".. roll .." nie przyniosl Ci szczescia tym razem.")
end
return true
end

function creatureSayCallback(cid, type, msg)

local player_pos = {x = 458, y = 501, z = 7}
player_pos.stackpos = STACKPOS_TOP_CREATURE
local player_uid = getThingfromPos(player_pos).uid
local ROLL, num1, num2, num3, num4, num5, num6 = 0, 1, 2, 3, 4, 5, 6

if (player_uid ~= 0) then
if (msg == "1" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num1
elseif (msg == "2" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num2
elseif (msg == "3" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num3
elseif (msg == "4" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num4
elseif (msg == "5" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num5
elseif (msg == "6" and (isPlayer(player_uid) and player_uid == cid)) then
ROLL = num6
else
return false
end
addEvent(rollDice, 10, ROLL, dice_pos, npc)
else
return false
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)[/lua]
 
Odp: Npc Ktory Lossuje

[MENTION=353628]buchaLL[/MENTION] Dasz rade zmieni? ?eby tepa?o na dana pozycje jak sie nie uda wylosowac numeu? zamiast temple
 
Odp: Npc Ktory Lossuje

doPlayerSendTextMessage(player_uid, MESSAGE_STATUS_CONSOLE_ORANGE, "Niestety numer ".. roll .." nie przyniosl Ci szczescia tym razem.")
doTeleportThing(player_uid,twoja pozycja, true)
 
Odp: Npc Ktory Lossuje

#Dice_dla_leniwych_adminow XDDDDDDDD
 
Odp: Npc Ktory Lossuje

[MENTION=318377]dzi[/MENTION]?ki za pomoc, no dla leniwych w sumie

---------- Tre?? dodana o 01:00 ----------
[MENTION=318377]dzi[/MENTION]?ki za pomoc, no dla leniwych w sumie
 
Status
Zamknięty.
Do góry