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

[NPC] (easy edit) rep++ // edit npc options

  • Thread starter Thread starter Evil Puncker
  • Start date Start date
E

Evil Puncker

Guest
Hi ppl, can someone rewrite this NPC, so I can choose if I wanna do greenhorn, scrapper or warlord... And so i can do how much times I want :)


IE:

Player: hi
NPC: Want to fight today?
Player: yes
NPC: Greenhorn, Scrapper or Warlord?
Player: Scrapper
(Then set the storages)

And remove the level restriction please ^_^
here goes the script

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

function enterArena(cid, message, keywords, parameters, node)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local cost = 0
	local levelname = ''
	if getPlayerStorageValue(cid, 42355) < 1 then
		cost = 1000
		levelname = 'greenhorn'
		levelneeded = 30
	elseif getPlayerStorageValue(cid, 42355) == 1 then
		cost = 5000
		levelname = 'scrapper'
		levelneeded = 50
	elseif getPlayerStorageValue(cid, 42355) == 2 then
		cost = 10000
		levelname = 'warlord'
		levelneeded = 80
	end
	if string.lower(keywords[1]) == 'yes' and parameters.prepare ~= 1 then
		if(getPlayerLevel(cid) >= levelneeded) then
			if(getPlayerMoney(cid) >= cost) then
				doPlayerRemoveMoney(cid, cost)
				npcHandler:say('Now you can go to test.', cid)
				setPlayerStorageValue(cid, 42351, 1)
			else
				npcHandler:say('You don\'t have ' .. cost .. ' gold coins! Come back when you will be ready!', cid)
		    end
		else
			npcHandler:say('You don\'t have ' .. levelneeded .. ' level! Come back when you will be ready!', cid)
		end
		npcHandler:resetNpc()
	elseif string.lower(keywords[1]) == 'no' then
		npcHandler:say('Come back later then!', cid)
		npcHandler:resetNpc()
	else
		if getPlayerStorageValue(cid, 42355) < 3 then
			npcHandler:say('You test will be ' .. levelname .. ' level. If you want enter you must pay ' .. cost .. ' gp and have ' .. levelneeded .. ' level. Wanna try?', cid)
		else
			npcHandler:say('You did all arena levels.',cid)
		end
	end
	return true
end

npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|! Do you want to make arena?')

local yesNode = KeywordNode:new({'yes'}, enterArena, {})
local noNode = KeywordNode:new({'no'}, enterArena, {})

local node1 = keywordHandler:addKeyword({'arena'}, enterArena, {prepare=1})
	node1:addChildKeywordNode(yesNode)
	node1:addChildKeywordNode(noNode)
	
local node1 = keywordHandler:addKeyword({'fight'}, enterArena, {prepare=1})
	node1:addChildKeywordNode(yesNode)
	node1:addChildKeywordNode(noNode)
local node1 = keywordHandler:addKeyword({'yes'}, enterArena, {prepare=1})
	node1:addChildKeywordNode(yesNode)
	node1:addChildKeywordNode(noNode)
npcHandler:addModule(FocusModule:new())
 
Last edited by a moderator:
PHP:
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
 
function enterArena(cid, message, keywords, parameters, node)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local cost = 0
	local levelname = ''
	npcHandler:say('Greenhorn, Scrapper or Warlord?', cid)
	
	if msgcontains(msg, "greenhorn") and getPlayerStorageValue(cid, 42355) < 1 then
		cost = 1000
		levelname = 'greenhorn'
	local storage = 42355
	npcHandler:say('Are you sure you want to fight Greenhorn?', cid)
	elseif msgcontains(msg, "greenhorn") and getPlayerStorageValue(cid, 42356) < 1 then
		cost = 5000
		levelname = 'scrapper'
	local storage = 42356
	npcHandler:say('Are you sure you want to fight Scrapper?', cid)
	elseif msgcontains(msg, "greenhorn") and getPlayerStorageValue(cid, 42357) < 1 then
		cost = 10000
		levelname = 'warlord'
	local storage = 42357
	npcHandler:say('Are you sure you want to fight Scrapper?', cid)
	end
	if string.lower(keywords[1]) == 'yes' then
			if(getPlayerMoney(cid) >= cost) then
				doPlayerRemoveMoney(cid, cost)
				npcHandler:say('Now you can go to test.', cid)
				setPlayerStorageValue(cid, 42351, 1)
				setPlayerStorageValue(cid, storage, 1)
			else
				npcHandler:say('You don\'t have ' .. cost .. ' gold coins! Come back when you will be ready!', cid)
		    end
		end
		npcHandler:resetNpc()
	elseif string.lower(keywords[1]) == 'no' then
		npcHandler:say('Come back later then!', cid)
		npcHandler:resetNpc()
	else
		if getPlayerStorageValue(cid, 42355) < 1 or getPlayerStorageValue(cid, 42356) < 1 or getPlayerStorageValue(cid, 42357) < 1 then
			npcHandler:say('You test will be ' .. levelname .. ' level. If you want enter you must pay ' .. cost .. ' gp. Wanna try?', cid)
		else
			npcHandler:say('You have already fight agenst all our bosses.',cid)
		end
	end
	return true
end
 
npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|! Want to fight today??')
 
local yesNode = KeywordNode:new({'yes'}, enterArena, {})
local noNode = KeywordNode:new({'no'}, enterArena, {})

npcHandler:addModule(FocusModule:new())

Not sure if it will works, but try it :)
 
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

local arenas = 
{
	["greenhorn"] = {price = 1000, storage = 1000},
	["scrapper"] = {price = 5000, storage = 1001},
	["warlord"] = {price = 10000, sotrage = 1002}
}

local arena = {}

function creatureSayCallback(cid, type, msg)

	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
	if msgcontains(msg, "fight") then
		npcHandler:say("Do you want to fight today?", cid)
		talkState[talkUser] = 1
	elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
		npcHandler:say("Where you can fight, {Greenhorn}, {Scrapper} or {Warlord} arena?", cid)
		talkState[talkUser] = 2
	elseif talkState[talkUser] == 2 then
		if arenas[msg:lower()] then
			if getCreatureStorage(cid, arenas[msg:lower()]) < 1 then
				arena[cid] = msg:lower()
				npcHandler:say("Are you sure that do you want to make the " .. msg:lower() .. " mode for the price of " .. arenas[msg:lower()].price .. " gold coins?", cid)
				talkState[talkUser] = 3
			else
				npcHandler:say("You already started or finished this mode.", cid)
				talkState[talkUser] = 0
			end
		else
			npcHandler:say("Please tell me the mode that do you want to make.", cid)
		end
	elseif msgcontains(msg, "yes") and talkState[talkUser] == 3 then
		if doPlayerRemoveMoney(cid, arenas[arena[cid]]) then
			npcHandler:say("Now you can pass the door. Good Luck!", cid)
			doCreatureSetStorage(cid, arenas[arena[cid]].storage, 1)
			talkState[talkUser] = 0
		else
			npcHandler:say("You do not have enough money.", cid)
			talkState[talkUser] = 0
		end
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Try now
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
 
local arenas = 
{
	["greenhorn"] = {price = 1000},
	["scrapper"] = {price = 5000},
	["warlord"] = {price = 10000}
}
 
local arena = {}
 
function creatureSayCallback(cid, type, msg)
 
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
	if msgcontains(msg, "fight") then
		npcHandler:say("Do you want to fight today?", cid)
		talkState[talkUser] = 1
	elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
		npcHandler:say("Where would you like to fight, {Greenhorn}, {Scrapper} or {Warlord} arena?", cid)
		talkState[talkUser] = 2
	elseif talkState[talkUser] == 2 then
		if arenas[msg:lower()] then
			if getCreatureStorage(cid, arenas[msg:lower()]) < 1 then
				arena[cid] = msg:lower()
				npcHandler:say("Are you sure that do you want to make the " .. msg:lower() .. " mode for the price of " .. arenas[msg:lower()].price .. " gold coins?", cid)
				talkState[talkUser] = 3
			else
				npcHandler:say("You already started or finished this mode.", cid)
				talkState[talkUser] = 0
			end
		else
			npcHandler:say("Please tell me the mode that do you want to make.", cid)
		end
	elseif msgcontains(msg, "yes") and talkState[talkUser] == 3 then
		if doPlayerRemoveMoney(cid, arenas[arena[cid]]) then
			npcHandler:say("Now you can pass the door. Good Luck!", cid)
			talkState[talkUser] = 0
		else
			npcHandler:say("You do not have enough money.", cid)
			talkState[talkUser] = 0
		end
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Removed storages :)
 
Back
Top