• 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 in 2 Scripts

Soul_Bullock

New Member
Joined
May 4, 2011
Messages
53
Reaction score
1
#1
I need a script (NPC) I give him item (id XXXX) and second item (ID YYYY) and he give me new item (ID ZZZZ) [For all professions (all voc have other 1st item and the same 2nd item and ALL VOCATIONS HAVE OTHER NEW ITEM!]


#2
How edit this script to use this rune only Elite Knight?? (Now all voc use this rune)

[
PHP:
local config = {
ile_procent = 30,
storage = 1713,
time = 0.75, -- co ile mozna uzywac
konczy_sie = false -- true / false
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if not exhaustion.check(cid, config.storage) then
exhaustion.set(cid, config.storage, config.time)
doCreatureAddHealth(cid, (getCreatureMaxHealth(cid) / 100) * config.ile_procent)
doSendMagicEffect(getCreaturePosition(cid), 30)
if config.konczy_sie == true then
doRemoveItem(item.uid)
end
else
doPlayerSendCancel(cid, "You are exhausted.")
doSendMagicEffect(getCreaturePosition(cid), 2)
end
return true
end

Sorry for my bad English ;//
 
lib/functions:
Code:
function getItemsFromList(items) -- by vodka
local str = ''
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1])
if i ~= table.maxn(items) then str = str .. ', ' end end end
return str
end
function doRemoveItemsFromList(cid,items) -- by vodka
local count = 0
if table.maxn(items) > 0 then
for i = 1, table.maxn(items) do
if getPlayerItemCount(cid,items[i][1]) >= items[i][2] then
count = count + 1 end  end  end
if count == table.maxn(items) then
for i = 1, table.maxn(items) do doPlayerRemoveItem(cid,items[i][1],items[i][2]) end
else return false end
return true end
npc:
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

local config = {
items = {{XXXX,1},{YYYY,1}},
reward = ZZZZ
}

if (msgcontains(msg, 'trade') or msgcontains(msg, 'trade'))then
npcHandler:say("you want to exchange "..getItemsFromList(config.items).." for 1 "..getItemNameById(config.reward).."? {yes}", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if doRemoveItemsFromList(cid,config.items) then
doPlayerAddItem(cid, config.reward)
npcHandler:say("here is you "..getItemNameById(config.reward), cid)
else
npcHandler:say("You don/t have "..getItemsFromList(config.items), cid)
end
elseif msg == "no" and talkState[talkUser] >= 1 then 
selfSay("then not!", cid) 
talkState[talkUser] = 0 
npcHandler:releaseFocus(cid) 
end
return TRUE 
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

item:
Code:
local config = { 
ile_procent = 30, 
storage = 1713, 
time = 0.75, -- co ile mozna uzywac 
konczy_sie = false, -- true / false 
vocs = {4,8} -- knight and elite knight
} 

function onUse(cid, item, fromPosition, itemEx, toPosition) 
if isInArray(config.vocs, getPlayerVocation(cid)) then
if not exhaustion.check(cid, config.storage) then 
exhaustion.set(cid, config.storage, config.time) 
doCreatureAddHealth(cid, (getCreatureMaxHealth(cid) / 100) * config.ile_procent) 
doSendMagicEffect(getCreaturePosition(cid), 30) 
if config.konczy_sie == true then 
doRemoveItem(item.uid) 
end 
else 
doPlayerSendCancel(cid, "You are exhausted.") 
doSendMagicEffect(getCreaturePosition(cid), 2) 
end
else 
doPlayerSendCancel(cid, "you need to be an knight") 
doSendMagicEffect(getCreaturePosition(cid), 2) 
end 
return true 
end
 
Back
Top