• 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 to request mission to kill 50 players

changos

Member
Joined
Feb 13, 2012
Messages
75
Solutions
5
Reaction score
22
i need npc of mission you have to say
-Hi
-Mission
-Yes
and asks you to kill 50 players
and at end of mission give away an item (that can be configured)

the outfit of npc is Wizard (2 addons) and color black
and the name of npc is (Dark Skull)

- - - Updated - - -

!UP
 
Creaturescripts.xml
XML:
<event type="kill" name="Darkskull" event="script" value="darkskullkill.lua"/>

Add this to login.lua
Lua:
	registerCreatureEvent(cid, "Darkskull")

darkskullkill.lua
Lua:
local config = {
	npcstorage = 18687,
	killstorage = 19001,
	targetlevel = 30,
	amountkills = 50
}

function onKill(cid, target)

	if not isPlayer(target) then
		return true
	end

	if getPlayerLevel(target) >= config.targetlevel and getPlayerStorageValue(cid, config.npcstorage) == 1 then
		if getPlayerStorageValue(cid, config.killstorage) >= -1 and getPlayerStorageValue(cid, config.killstorage) < config.amountkills then		
			setPlayerStorageValue(cid, config.killstorage, getPlayerStorageValue(cid, config.killstorage) + 1)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Players killed: "..(getPlayerStorageValue(cid, config.killstorage) +1).."/"..config.amountkills..".")
		end
		if (getPlayerStorageValue(cid, config.killstorage) +1) == config.amountkills then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you have killed "..(getPlayerStorageValue(cid, config.killstorage) +1).." players and finished the mission.")
			setPlayerStorageValue(cid, config.killstorage, getPlayerStorageValue(cid, config.killstorage) + 1)
		end
	end
	return true
end

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Dark Skull" script="darkskull.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="130" head="114" body="114" legs="114" feet="114" addons="3"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|, I am Dark Skull, I give a {mission} to the ones who are strong enough to fulfill it."/>
	</parameters>
</npc>

darkskull.lua
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)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local config = {
		npcstorage = 18687,
		killstorage = 19001,
		amountkills = 50,
		rewarditem = 2160,
		rewardexp = 12000
	}

	if(msgcontains(msg, 'mission')) then
		if getPlayerStorageValue(cid, config.npcstorage) == -1 then
			selfSay('So you want to do the mission? I want you to kill 50 players, do you accept?', cid)
			talkState[talkUser] = 1
		elseif getPlayerStorageValue(cid, config.npcstorage) == 1 then
			selfSay('Did you kill 50 players?', cid)
			talkState[talkUser] = 1
		else
			selfSay('You already did your mission.', cid)
		end
	elseif(msgcontains(msg, 'yes')) and talkState[talkUser] == 1 then
		if getPlayerStorageValue(cid, config.npcstorage) == -1 then
			selfSay('Lets see if you can make it!', cid)
			doPlayerSetStorageValue(cid, config.npcstorage, 1)
			talkState[talkUser] = 0
			return true
		end
		if getPlayerStorageValue(cid, config.npcstorage) == 1 and getPlayerStorageValue(cid, config.killstorage) >= config.amountkills then
			selfSay('Well, didn\'t expected it, but well done, here is your reward.', cid)
			doPlayerAddItem(cid, config.rewarditem, 1)
                        doPlayerAddExp(cid, config.rewardexp)
		        doPlayerSetStorageValue(cid, config.npcstorage, 2)
			talkState[talkUser] = 0
		else
		        selfSay('You killed '..(getPlayerStorageValue(cid, config.killstorage) +1)..' players, you need to kill '..config.amountkills..'!', cid)
	                talkState[talkUser] = 0
		end
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
		talkState[talkUser] = 0
		selfSay('I knew you were not strong enough!', cid)
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
@Limos
[07/06/2015 19:03:09] [Error - LuaScriptInterface::loadFile] data/npc/scripts/darkskull.lua:6: function arguments expected near ':'
[07/06/2015 19:03:09] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/darkskull.lua
[07/06/2015 19:03:09] data/npc/scripts/darkskull.lua:6: function arguments expected near ':'

whats error it is this?
 
Read my signature please. :)

Replace

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

with

Code:
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
 
Read my signature please. :)

Replace

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

with

Code:
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
ye it solved there are more problem lolz

when u kill 50 player u got error.

You killed 0 players, you need to kill 50!

not counting players lolz
 
its error because they not count the specific frags try to understand!
If you are going to be rude. I will not answer. Does the console print out anything? Was your kills unjustifed? And that not a error if it doesn't say anthing.
 
Back
Top