• 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!

Summon Npc script

Dyker

New Member
Joined
Sep 12, 2008
Messages
97
Reaction score
1
Hi friends i need a summon npc.

He have to say that:
Player: Hi
Npc: Hello |PLAYERNAME| I can obtain you a trainer for 300 gold pieces.
Player: Yes

And then the npc summon a Training Monk next to player and take 300 gold pieces of the player, can it be posible?
 
Thread moved to requests.
By the way, tompan, I think he doesn't have any script, so hes requesting one o.o
 
restrictions? mmmm maybe just for 1 vocation.. But trains will not have 2500000 hp they just will have 400 hp so its not much and they will have to get careful to dont kill them. This is for an RPG otserv so 300 gps is not very cheap. I think it's ok my description.
 
It does need restrictions i put a few in to stop abuse.

Lua:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Trainer seller" script="trainer.lua" walkinterval="0" floorchange="0">
	<health now="150" max="150"/>
	<look type="115" corpse="2212"/>
    <parameters>
	<parameter key="message_greet" value="Hello, I sell you {trainer}'s. Also, i can provide {help} if you need it."/>
    </parameters>
</npc>


Lua:
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)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	
	local pos = getPlayerPosition(cid) 
	local monster = "Monk"
	local cost = 300 
	local summonPos = {x=pos+1, y=pos.y, z=pos.z}
	local target = getPlayerName(cid)
	local summons = getCreatureSummons(cid)
-- script begins	
	if(msgcontains(msg, 'help') or msgcontains(msg, 'support')) then
			npcHandler:say("Hello, I can sell you a trainer for 300 gold pieces for you to personally!", cid)
		elseif(msgcontains(msg, 'trainer') or msgcontains(msg, 'training monk')) then
			npcHandler:say("Would you like to buy 1 personal trainer for 300 gold pieces", cid)
			talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if 	getTilePzInfo(pos) == true then
			npcHandler:say("You are in PZ...How do you expect to train...", cid)
		elseif getTilePzInfo(pos) == false and doPlayerRemoveMoney(cid, cost) == true then
			npcHandler:say("Here you are, your own personal trainer.", cid)
			doSummonCreature(monster, summonPos)
			doMonsterSetTarget(cid, target)
			talkState[talkUser] = 0
		elseif (table.maxn(summons) >= 2) then
			npcHandler:say("You already have enough personal trainers.", cid)
		end
		elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
		npcHandler:say("Then not.", cid)
		talkState[talkUser] = 0
	end
	return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
You used doSummonCreature, which creates a 'wild' monster and not a player summon so getCreatureSummons won't return the correct number
 
nono summon a wild monster is right. appears that in console when i say "trainer"

Code:
[05/09/2011 12:30:30] [Error - Npc interface] 
[05/09/2011 12:30:30] data/npc/scripts/monk.lua:onCreatureSay
[05/09/2011 12:30:30] Description: 
[05/09/2011 12:30:30] data/npc/scripts/monk.lua:15: attempt to perform arithmetic on local 'pos' (a table value)
[05/09/2011 12:30:30] stack traceback:
[05/09/2011 12:30:30] 	data/npc/scripts/monk.lua:15: in function 'callback'
[05/09/2011 12:30:30] 	data/lib/npcsystem.lua:390: in function 'onCreatureSay'
[05/09/2011 12:30:30] 	data/npc/scripts/monk.lua:7: in function <data/npc/scripts/monk.lua:7>
 
Back
Top