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

Lua Item changable to exp by NPC

Lantos

New Member
Joined
Mar 2, 2009
Messages
62
Reaction score
0
I need a script for npc which can change item xxxx for xxxx exp.^ If someone would be so greatful to give me such script I will be really thankful ;> +++
 
Here actions/scripts:
Code:
local cfg = {
        max = 300, -- Maximum Level to Use
	add = 10 -- Levels to Add
    }
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(getPlayerLevel(cid) < cfg.max)then
		doPlayerAddExperience (cid, 10000000)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have recieved 10.000.000 Points of experience.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORKS)
		doRemoveItem(item.uid)
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have exceeeded the max level to use this.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
	end
	return true
end

In actions.xml:
Code:
<action itemid="xxx" event="script" value="scriptname.lua"/>
 
Ah, okey. Try this:
Code:
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
if(msgcontains(msg, 'quest')) then
selfSay('Ok, you can started "mission"?', cid)
end
---------------------------------------------------------
if(msgcontains(msg, 'mission')) then
selfSay('TEXT', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'TEXT HERE') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,1237) > 0) then
else
if(doPlayerRemoveItem(cid, ITEMID, 1) == TRUE) then
setPlayerStorageValue(cid,1237,1)
[B]doPlayerAddExperience (cid, 10000000~~)[/B]
selfSay('YOUR TEXT HERE', cid)
else
selfSay(' YOUR TEXT HERE ', cid)
end
end
return true
end


end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top