What's new

NPC NPC Gwiazdor

Status
Not open for further replies.

Hakeq

Banned
Joined
Mar 23, 2013
Messages
103
Reaction score
6
Autor: By Devoy
Poprawki i spolszczenie: ?abik
Opis: NPC Santa Claus daje jeden losowo wybrany z 5 wypisanych w santa.lua. ID mo?na zmieni? wedle upodoba?. Ka?da posta? mo?e dosta? tylko 1 prezent.

W xxx\data\npc tworzymy nowy plik santa.xml i wklejamy do niego
PHP:
<?xml version="1.0"?>
<npc name="Santa Claus" script="data/npc/scripts/santa.lua" access="3">
    <look type="160" head="0" body="94" legs="0" feet="94"/>  
</npc>

W xxx\data\npc\scripts tworzymy nowy plik santa.lua i wklejamy do niego
PHP:
focus = 0 
talk_start = 0 
target = 0 
following = false 
attacking = false 

function onThingMove(creature, thing, oldpos, oldstackpos) 
end 

function onCreatureAppear(creature) 
end 


function onCreatureDisappear(cid, pos) 
if focus == cid then 
selfSay('Merry Christmas!') 
focus = 0 
talk_start = 0 
end 
end 

function onCreatureTurn(creature) 
end 

function msgcontains(txt, str) 
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)')) 
end 

function onCreatureSay(cid, type, msg) 
msg = string.lower(msg) 

if ((string.find(msg, '(%a*)hi(%a*)')) and (focus == 0)) and getDistanceToCreature(cid) < 4 then 
selfSay('Wesolych Swiat ' .. creatureGetName(cid) .. '!') 
focus = cid 
talk_start = os.clock() 
end 

if string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then 
selfSay(' ' .. creatureGetName(cid) .. 'Mozesz chwilke poczekac') 
end 

if string.find(msg, '(%a*)present(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then 
present = getPlayerStorageValue(cid,1210) 
if present == -1 then 
buy(cid,item,1,0) 
setPlayerStorageValue(cid,1210,1) 
end 

if present == 1 then 
selfSay('Mozesz dostac tylko jeden prezet w kazdym roku.') 
end 
end 

if string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then 
selfSay('Milych Swiat ' .. creatureGetName(cid) .. '!') 
focus = 0 
talk_start = 0 
end 
end 


function onCreatureChangeOutfit(creature) 
end 


function onThink() 
if (os.clock() - talk_start) > 30 then 
if focus > 0 then 
selfSay('Wesolych Swiat!') 
end 
focus = 0 
end 
if focus ~= 0 then 
if getDistanceToCreature(focus) > 3 then 
selfSay('Wesolych Swiat!') 
focus = 0 
end 
end 
if focus == 0 then 
cx, cy, cz = selfGetPosition() 
randmove = math.random(1,25) 
if randmove == 1 then 
nx = cx + 1 
end 
if randmove == 2 then 
nx = cx - 1 
end 
if randmove == 3 then 
ny = cy + 1 
end 
if randmove == 4 then 
ny = cy - 1 
end 
if randmove >= 5 then 
nx = cx 
ny = cy 
end 
moveToPosition(nx, ny, cz) 
--summons = 30 
--summons2 = 30 
end 

if focus > 0 then 
rand = math.random(1,6) 
if rand == 1 then 
item = 2390 
elseif rand == 2 then 
item = 2493
elseif rand == 3 then 
item = 2494 
elseif rand == 4 then 
item = 2495 
elseif rand == 5 then 
item = 2195 
else 
item = 2520 
end 
end 

if focus == 0 then 
randsay = math.random(1,75) 
if randsay == 1 then 
selfSay('h0..ho..H0...') 
end 
if randsay == 2 then 
selfSay('Hoho...') 
end 
end 
end
 
Status
Not open for further replies.
Top