• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[8.0] Santa -TFS-

EvulMastah

๏̯͡๏﴿
Premium User
Joined
Aug 19, 2007
Messages
4,940
Solutions
11
Reaction score
354
Since it is Christmas time, I've decided to make Santa script :).
He is giving away those presents:

Teddy Bear (very rare ;p),
Oranges,
Apples,
Ginger Bread Man,
Candy Canes.

Your presents depends on random.

Here it is:

Santa.xml

PHP:
<npc name="Santa" script="data/npc/scripts/santa.lua" autowalk="25" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="160" head="0" body="94" legs="0" feet="94"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|!"/>
		<parameter key="message_farewell" value="Merry Christmas." />
		<parameter key="message_placedinqueue" value="Your time will come |PLAYERNAME|, ho ho ho." />
		<parameter key="message_walkaway" value="Merry Christmas." />
		<parameter key="message_idletimeout" value="Merry Christmas." />
		<parameter key="message_walkaway" value="Merry Christmas!" />
	</parameters>
</npc>

santa.lua

PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so 

you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

	present = getPlayerStorageValue(cid, 67872)
	random = math.random(1, 40)

	if msgcontains(msg, 'present') then
	if present == -1 then

	if (random >= 1 and random <= 3) then
	doPlayerAddItem(cid, 2112, 1)
	setPlayerStorageValue(cid, 67872, 1)
	selfSay('You were very lucky! Here is your present.')

	elseif (random >= 4 and random <= 12) then
	doPlayerAddItem(cid, 2675, 15)
	setPlayerStorageValue(cid, 67872, 1)
	selfSay('Merry Christmas! Ho Ho Ho!')

	elseif (random >= 13 and random <= 20) then
	doPlayerAddItem(cid, 2688, 10)
	setPlayerStorageValue(cid, 67872, 1)
	selfSay('Merry Christmas! Ho Ho Ho!')

	elseif (random >= 21 and random <= 30) then
	doPlayerAddItem(cid, 6501, 3)
	setPlayerStorageValue(cid, 67872, 1)
	selfSay('Merry Christmas! Ho Ho Ho!')

	elseif (random >= 31 and random <= 40) then
	doPlayerAddItem(cid, 2674, 5)
	setPlayerStorageValue(cid, 67872, 1)
	selfSay('Merry Christmas! Ho Ho Ho!')
end

	else
	selfSay('You already have your present, ho ho ho!')
end
end
return 1
end	

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Enjoy the Christmas time!
 
Nice, but can you add for only lvl 50+ get present?

PHP:
 local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so 

you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end

    level = getPlayerLevel(cid)
    present = getPlayerStorageValue(cid, 67872)
    random = math.random(1, 40)

    if msgcontains(msg, 'present') then
    if level >= 50 then
    if present == -1 then

    if (random >= 1 and random <= 3) then
    doPlayerAddItem(cid, 2112, 1)
    setPlayerStorageValue(cid, 67872, 1)
    selfSay('You were very lucky! Here is your present.')

    elseif (random >= 4 and random <= 12) then
    doPlayerAddItem(cid, 2675, 15)
    setPlayerStorageValue(cid, 67872, 1)
    selfSay('Merry Christmas! Ho Ho Ho!')

    elseif (random >= 13 and random <= 20) then
    doPlayerAddItem(cid, 2688, 10)
    setPlayerStorageValue(cid, 67872, 1)
    selfSay('Merry Christmas! Ho Ho Ho!')

    elseif (random >= 21 and random <= 30) then
    doPlayerAddItem(cid, 6501, 3)
    setPlayerStorageValue(cid, 67872, 1)
    selfSay('Merry Christmas! Ho Ho Ho!')

    elseif (random >= 31 and random <= 40) then
    doPlayerAddItem(cid, 2674, 5)
    setPlayerStorageValue(cid, 67872, 1)
    selfSay('Merry Christmas! Ho Ho Ho!')
end

    else
    selfSay('You already have your present, ho ho ho!')
end
    else
    selfSay('Only players of level 50 or higher can get presents, sorry! Ho Ho Ho!')
end
end
return 1
end    

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Can Santa give (randomly) PACC instead of items?

Or stampped letter with text in it? (for example, letter with custom text which player can exchange for house (via GM))
 
Yes, I will make you one tomorrow after school, I dont feel like doing it now.

Just post here what would have to be in letter and how many days it would give.
 
5 days

"This document allows you to rent a house not bigger than 100sqm. To do it - contact with Gamemaster."

And it would be great if letter could have UID.
Otherwise I'll search for another document-type item which doesn't exist on map.

Dzięki ;) (thanks)
 
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so 

you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

	local present = getPlayerStorageValue(cid, 67875)
	local random = math.random(1, 14)

	if msgcontains(msg, 'present') then
	if present == -1 then

	if (random >= 1 and random <= 6) then
	doPlayerAddPremiumDays(cid, 5)
	setPlayerStorageValue(cid, 67875, 1)
	doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_GREEN)
	selfSay('Merry Christmas! Ho Ho Ho!')

	elseif (random >= 7 and random <= 14) then
	doSetItemText(doPlayerAddItem(cid, 2598, 1), 'It is said that you can trade one for a house not bigger than 100 sqm.\nCall a Gm.')
	setPlayerStorageValue(cid, 67875, 1)
	selfSay('Merry Christmas! Ho Ho Ho!')
end

	else
	selfSay('You already have your present, ho ho ho!')
end
end
return 1
end	

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

It doesnt have the Action/Unique IDs, but u cant edit the text in it, so thats how u can check if its real or faked one.
Hope its enough :P
 
Last edited:
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so 

you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end

    local present = getPlayerStorageValue(cid, 67875)
    local random = math.random(1, 14)
    local level = getPlayerLevel(cid)

    if msgcontains(msg, 'present') then
    if level >= 30 then
    if present == -1 then

    if (random >= 1 and random <= 6) then
    doPlayerAddPremiumDays(cid, 5)
    setPlayerStorageValue(cid, 67875, 1)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_GREEN)
    selfSay('Merry Christmas! Ho Ho Ho!')

    elseif (random >= 7 and random <= 14) then
    doSetItemText(doPlayerAddItem(cid, 2598, 1), 'It is said that you can trade one for a house not bigger than 100 sqm.\nCall a Gm.')
    setPlayerStorageValue(cid, 67875, 1)
    selfSay('Merry Christmas! Ho Ho Ho!')
end

    else
    selfSay('You already have your present, ho ho ho!')
    end
    else
    selfSay('You must be at least level 30 to get present.')
    end
end
return 1
end    

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
hello, can you maker a npc, first he remove 50 surpreise bag item id(6497)

after he add your present using random
 
hello, can you maker a npc, first he remove 50 surpreise bag item id(6497)

after he add your present using random

PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so 

you do not have to take care of that yourself.
    if(npcHandler.focus ~= cid) then
        return false
    end

    local present = getPlayerStorageValue(cid, 67875)
    local random = math.random(1, 14)
    local level = getPlayerLevel(cid)

    if msgcontains(msg, 'present') then
    if doPlayerTakeItem(cid, 6497, 50) == 1 then
    if present == -1 then

    if (random >= 1 and random <= 6) then
    doPlayerAddPremiumDays(cid, 5)
    setPlayerStorageValue(cid, 67875, 1)
    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_GREEN)
    selfSay('Merry Christmas! Ho Ho Ho!')

    elseif (random >= 7 and random <= 14) then
    doSetItemText(doPlayerAddItem(cid, 2598, 1), 'It is said that you can trade one for a house not bigger than 100 sqm.\nCall a Gm.')
    setPlayerStorageValue(cid, 67875, 1)
    selfSay('Merry Christmas! Ho Ho Ho!')
end

    else
    selfSay('You already have your present, ho ho ho!')
    end
    else
    selfSay('Bring me 50 surprise bags to get present.')
    end
end
return 1
end    

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Should be fine, if not change == 1 to == 0.
 
ho ho ho =P

very nice i go use in my server ;P

ty

(Off) you are from what country?

sorry bad English hehe
 
Back
Top