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

Help! Warmaster Addon!

Aklovo

Enjoy It
Joined
Dec 30, 2009
Messages
453
Reaction score
12
Location
México
Hi, I want a script for a warmaster addon! Can anyine help me?
Well, i want that this script give the warmaster addon with kills!
For example 50 kills and the addon will give it to the player!

Any idea? Thanks
 
Do you want an NPC to give the player the addon, or do you want it to be given to them automatically?

Here's the CreatureEvent for automatically adding it:
Lua:
local storage, kills, reward = 6435, getPlayerStorageValue(cid, storage), 50
local maleoutfit, femaleoutfit = 336, 337
function onKill(cid, target, lastHit)
	if(isPlayer(target) && kills > reward) then
                return FALSE
        elseif(isPlayer(target) && kills < reward) then
		setPlayerStorageValue(cid, storage, kills+1)
	elseif(isPlayer(target) && kills == reward) then
                if(getPlayerSex(cid) == male) then
                       doPlayerAddOutfit(cid, maleoutfit, 2)
                else
                       doPlayerAddOutfit(cid, femaleoutfit, 2)
                end
                setPlayerStorageValue(cid, storage, kills+1)
                doPlayerSendTextMessage(cid, 19, "Congratulations! You have just recieved both Warmaster Addons.")
        end
	return TRUE
end

Here's the NPC code:
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

local storage, kills, reward = 6435, getPlayerStorageValue(cid, storage), 50
local maleoutfit, femaleoutfit = 336, 337

function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if (msgcontains(msg, "hello") or msgcontains(msg, "hi")) and not npcHandler:isFocused(cid) then
		npcHandler:say("Hello, "..getCreatureName(cid)..". Are you here to recieve your {addon}?", cid, TRUE)
		npcHandler:addFocus(cid)
		return true
	end
	
	if(not npcHandler:isFocused(cid)) then
		return false
	elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
		npcHandler:say("Farewell, " .. getCreatureName(cid) .. "!", cid, TRUE)
		npcHandler:releaseFocus(cid)
	end
	
	
	if(not npcHandler:isFocused(cid)) then
		return false
	elseif msgcontains(msg, "addon") then
                if getPlayerStorageValue(cid, storage) < reward then
		      npcHandler:say("You still need ".. reward - getPlayerStorageValue(cid, storage) .." to recieve your addon.", cid, TRUE)
	        elseif getPlayerStorageValue(cid, storage) == reward then
                      npcHandler:say("Congratulations, here are your Warmaster Addons!", cid, TRUE)
                      if(getPlayerSex(cid) == male) then
                             doPlayerAddOutfit(cid, maleoutfit, 2)
                      else
                             doPlayerAddOutfit(cid, femaleoutfit, 2)
                      end
                      setPlayerStorageValue(cid, storage, kills+1)
                else
                      npcHandler:say("You have already recieved your Addons!", cid, TRUE)
                end
        return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Ya. Bye.", cid, TRUE)

With the NPC script, you will need this revised version of the CreatureEvent:
Lua:
local storage, kills, reward = 6435, getPlayerStorageValue(cid, storage), 50
local maleoutfit, femaleoutfit = 336, 337
function onKill(cid, target, lastHit)
	if(isPlayer(target) && kills >= reward) then
                return FALSE
        elseif(isPlayer(target) && kills < reward) then
		setPlayerStorageValue(cid, storage, kills+1)
	return TRUE
end

To use either of the CreatureEvents you will need to register them at login and add them to CreatureEvents.xml

To use the NPC script, you will just have to save it as a .lua in your NPC scripts folder, and create an NPC for them like this one:

Lua:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Warmaster NPC" script="warmasternpc.lua" walkinterval="0" floorchange="0" speed="900">
	<health now="150" max="150"/>
	<look type="336" head="19" body="19" legs="19" feet="19" addons="2"/>
</npc>

I hope that helped.
 
Last edited:
And how can i put it? In creaturescript right?
But how can i put in creaturescript.xml?
What event type is?
 
Last edited:
And how can i put it? In creaturescript right?
But how can i put in creaturescript.xml?
What event type is?

Lua:
<event type="kill" name="WarMaster" event="script" value="warmaster.lua"/>

and at the Login script:
Lua:
registerCreatureEvent(cid, "WarMaster")

Remember, a lil rep wouldn't hurt. :3
 
[18/04/2011 15:06:38] [Error - LuaScriptInterface::loadFile] data/npc/scripts/warmasternpc.lua:49: 'end' expected (to close 'function' at line 13) near '<eof>'
[18/04/2011 15:06:38] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/warmasternpc.lua
[18/04/2011 15:06:38] data/npc/scripts/warmasternpc.lua:49: 'end' expected (to close 'function' at line 13) near '<eof>'
[18/04/2011 15:06:53] [Warning - Npc::loadFromXml] Cannot load npc file (data/npc/warmasternpc.xml).
[18/04/2011 15:06:53] Info: failed to load external entity "data/npc/warmasternpc.xml"

how can i fix this problem?
 
Back
Top