• logo_cipsoft
    Nowe serwery zostały otwarte 19 Lut 2025:
    Noctalia (Open PvP) Ignitera (Open PvP) us_logo Xybra (Open PvP)

NPC NPC ktory bedzie wymienial kase na itemka xxx ID

Status
Zamknięty.

Hakeq

Banned
Dołączył
Marzec 23, 2013
Posty
103
Liczba reakcji
6
Autor: Elitek
Tak jak w nazwie, NPC ktory bedzie wymienial kase na itemka z podanym ID.

Tworzymy plik xml np. name.xml i wklejamy to:
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Name" script="name.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="128" head="17" body="54" legs="114" feet="0" addons="2"/>
	<parameters>
		<parameter key="message_greet" value="Hi |PLAYERNAME|! Are you sure you want to change 5000gold for 30 Exp Eggs?"/>
	</parameters>
</npc>

Nastepnie tworzymy name.lua w folderze ze skryptami i wklejamy do niego to:
PHP:
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, 'yes') or msgcontains(msg, 'tak'))then
		if(doPlayerRemoveMoney(cid, 5000))then
			doPlayerAddItem(cid, ID, 30, true)
			selfSay('Here you are.', cid)
		else
			selfSay('You don\'t have 5000 gp.', cid)
		end
	else
		selfSay('Ok then.', cid)
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Status
Zamknięty.
Do góry