What's new

Sms shop npc

Status
Not open for further replies.

Tlos

User
Joined
May 3, 2010
Messages
15
Reaction score
0
Witam
Potrzebuje npc kt?ry za 1 premium coin (id.6527) wyda pacc rune 7 days (id. 2292)
Potrzebuje tego skrypcika do wielu itemek ale mysle ze jak dostane pierwowzor to sobie poradze.
 

andy1995

Senior User
Joined
Apr 12, 2009
Messages
602
Reaction score
100
Odp: Sms shop npc

Actions.xml
<action itemid="2292" event="script" value="paccruna.lua"/>

paccruna.lua
local ITEM = 2292
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == ITEM then
doPlayerSendTextMessage(cid, 25, 'Added 7 days premium account!')
doPlayerAddPremiumDays(cid, 7)
doPlayerRemoveItem(cid, ITEM, 1)
doSendMagicEffect(getPlayerPosition(cid),14,cid)
end
return TRUE
end

Npc.lua
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() 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, 'pacc')) then
selfSay('Do you want change my pacc rune for your 1 premium coin?', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(doPlayerRemoveItem(cid, 6527, 1) == TRUE) then
doPlayerAddItem(cid,2292,1)
selfSay('Thanks you.', cid)
else
selfSay('Sorry, you don/t have enough item!', cid)
return TRUE
end
end
---------------------------------------------------------
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 

Tlos

User
Joined
May 3, 2010
Messages
15
Reaction score
0
Odp: Sms shop npc

bardziej sie sprecyzuje
pacc runke mam
potrzebuje npc lua i xml
i jest tak idziesz do npc hi on cos ci mowi ty mowisz yes i dostajesz t? runke a tracisz coina

@edit

dzi?ki ziomek
 
Last edited:

andy1995

Senior User
Joined
Apr 12, 2009
Messages
602
Reaction score
100
Odp: Sms shop npc

Ziomus.xml
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Ziomus" script="test.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="129" head="0" body="50" legs="58" feet="116" addons="0"/>
<parameters>
        <parameter key="message_greet" value="Welcome |PLAYERNAME|! Do you want change your 1 premium coint for pacc runa?"/>
    </parameters>
</npc>
Ziomus.lua
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')) then
if(doPlayerRemoveItem(cid, 6527, 1) == TRUE) then
doPlayerAddItem(cid,2292,1)
selfSay('Thanks you.', cid)
else
selfSay('Sorry, you don/t have enough item!', cid)
return TRUE
end
end
---------------------------------------------------------
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Status
Not open for further replies.
Top