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

[2 Requests] NPC and Item.

mikkas70

Owner and Developer of omegaservers.org
Joined
Jan 6, 2009
Messages
42
Reaction score
8
Here's what I want...
When a player gets killed by someone, the killer will recieve a reward (trophy)...

1) Item part: I would like to get this script, when someone "Uses" that trophy, it will be exchanged automatically to a golden nugget. (Example: I got 2 trophys, "use" on both, and I will get 2 Golden nuggets)

2) NPC part: When you have 50 golden nuggets, you'll be able to exchange them for a ring by talking with 1 NPC...

Can someone please help me with these problems?
Any help will be apreciated!
(Sorry about my bad english)
 
npc:
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 exchange(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
        if getPlayerItemCount(cid,xxx) >= 50 then
        if (doPlayerRemoveItem(cid,xxx,50) == TRUE) then
            npcHandler:say('Here is your ring', cid)
            doPlayerAddItem(cid,xxx,1)
        end
        else
            npcHandler:say('You don\'t have 50 gold nuggets', cid)
    end
end
 
 
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can exchange a ... ring for 50 gold nuggets, just say exchange"})
 
local node1 = keywordHandler:addKeyword({'exchange'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Are you sure you would like to exchange 50 gold nuggets for a ... ring Yes or no??'})
    node1:addChildKeyword({'yes'}, exchange, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got 50 gold nuggets', reset = true})
 
npcHandler:addModule(FocusModule:new()
not sure if this will work, not too good with npcs, just replace the xxx's with the item id's i dont feel like looking them up atm, also fill in the ... for whatever ring u want to use.

Item:
Lua:
 function onUse(cid, item, frompos, item2, topos)  
         if(isPlayer(cid)) then
         doRemoveItem(item.uid, 1)
         doPlayerAddItem(cid, xxx, 1)
end
return true
end

aswell just add the itemids in for the xxx's
 
Last edited:
npc:
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 exchange(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
        if getPlayerItemCount(cid,xxx) >= 50 then
        if (doPlayerRemoveItem(cid,xxx,50) == TRUE) then
            npcHandler:say('Here is your ring', cid)
            doPlayerAddItem(cid,xxx,1)
        end
        else
            npcHandler:say('You don\'t have 50 gold nuggets', cid)
    end
end
 
 
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can exchange a ... ring for 50 gold nuggets, just say exchange"})
 
local node1 = keywordHandler:addKeyword({'exchange'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Are you sure you would like to exchange 50 gold nuggets for a ... ring Yes or no??'})
    node1:addChildKeyword({'yes'}, amulet, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back when you got 50 gold nuggets', reset = true})
 
npcHandler:addModule(FocusModule:new()
not sure if this will work, not too good with npcs, just replace the xxx's with the item id's i dont feel like looking them up atm, also fill in the ... for whatever ring u want to use.

Item:
Lua:
 function onUse(cid, item, frompos, item2, topos)  
         if(isPlayer(cid) then
         doRemoveItem(cid,1)
         doPlayerAddItem(cid, xxx, 1)
end
return true
end

aswell just add the itemids in for the xxx's

there's one missing ) at line 2.
 
Problems with the NPC, when you say "Yes" it won't do nothing, even with 50 gold nuggets in my inventory.
 
Last edited:
There's one problem... When you "use" the trophy it'll give the golden nuggets but it won't disappear. Something's wrong :S
 
Try
Code:
function onUse(cid, item, frompos, item2, topos)
	doRemoveItem(item.uid, 1)
	doPlayerAddItem(cid, 2157, 1)
	return true
end
 
Last edited:
Tested on 3.6, should work now
Code:
function onUse(cid, item, frompos, item2, topos)
	local count = getPlayerItemCount(cid, item.itemid)
	doRemoveItem(item.uid, count)
	doPlayerAddItem(cid, 2157, count)
	return true
end
 
Worked perfectly mate thanks a lot! But can you please add something? When "use" the trophy a message will appear above your character saying "Frags" in orange, can you please do that? I will rep+

BTW NPC is still bugged up... someone?
 
Code:
function onUse(cid, item, frompos, item2, topos)
	local count = getPlayerItemCount(cid, item.itemid)
	doRemoveItem(item.uid, count)
	doPlayerAddItem(cid, 2157, count)
	doCreatureSay(cid, "Frags", TALKTYPE_MONSTER)
	return true
end
 
Back
Top