What's new

NPC od Spells

Status
Not open for further replies.

Jakkess

Senior User
Joined
Jun 12, 2008
Messages
795
Reaction score
47
M?g?by mi kto? przerobi? ten skrypt tak, aby NPC sprzedawa? tylko czary knightom i na wymagany lvl? Za pomoc reput.

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         
local spells = { 
                [1] = {nazwa_czaru = "Antidote" ,cena = 150, slowa = 'EXANA POX', numer = 1}, 
                [2] = {nazwa_czaru = "Berserk" ,cena = 2500, slowa = 'EXORI', numer = 2}, 
                [3] = {nazwa_czaru = "Blood Rage" ,cena = 8000, slowa = 'UTITO TEMPO', numer = 3}, 
                [4] = {nazwa_czaru = "Challenge" ,cena = 2000, slowa = 'EXETA RES', numer = 4}, 
                [5] = {nazwa_czaru = "Charge" ,cena = 1300, slowa = 'UTANI TEMPO HUR', numer = 5}, 
                [6] = {nazwa_czaru = "Fierce Berserk" ,cena = 5000, slowa = 'EXORI GRAN', numer = 6}, 
                [7] = {nazwa_czaru = "Find Person" ,cena = 80, slowa = 'EXIVA', numer = 7}, 
                [8] = {nazwa_czaru = "Great Light" ,cena = 500, slowa = 'UTEVO GRAN LUX', numer = 8}, 
                [9] = {nazwa_czaru = "Groundshaker" ,cena = 1500, slowa = 'EXORI MAS', numer = 9}, 
                [10] = {nazwa_czaru = "Haste" ,cena = 600, slowa = 'UTANI HUR', numer = 10}, 
                [11] = {nazwa_czaru = "Levitate" ,cena = 500, slowa = 'EXANI HUR', numer = 11}, 
                [12] = {nazwa_czaru = "Light" ,cena = 100, slowa = 'UTEVO LUX', numer = 12}, 
                [13] = {nazwa_czaru = "Light Healing" ,cena = 170, slowa = 'EXURA', numer = 13}, 
                [14] = {nazwa_czaru = "Magic Rope" ,cena = 200, slowa = 'EXANI TERA', numer = 14}, 
                [15] = {nazwa_czaru = "Protector" ,cena = 6000, slowa = 'UTAMO TEMPO', numer = 15}, 
                [16] = {nazwa_czaru = "Train Party" ,cena = 4000, slowa = 'UTITO MAS SIO', numer = 16}, 
                [17] = {nazwa_czaru = "Whirlwind Throw" ,cena = 800, slowa = 'EXORI HUR', numer = 17}, 
                [18] = {nazwa_czaru = "Wound Cleansing" ,cena = 300, slowa = 'EXANA MORT', numer = 18}, 
                }     
for i = 1, #spells do 
    if msgcontains(msg, spells[i].nazwa_czaru) then 
        if getPlayerLearnedInstantSpell(cid, spells[i].nazwa_czaru) == false then 
            npcHandler:say("Would you like to buy "..spells[i].nazwa_czaru.." for "..spells[i].cena.." gold?", cid) 
            talkState[talkUser] = spells[i].numer 
        else 
            npcHandler:say("You already know how to cast this spell.", cid) 
        end 
    elseif msgcontains(msg, 'yes') then 
        if talkState[talkUser] == spells[i].numer then 
            if getPlayerMoney(cid) >= spells[i].cena then 
                doPlayerRemoveMoney(cid, spells[i].cena) 
                npcHandler:say("To cast this spell say {"..spells[i].slowa.."}.", cid) 
                doPlayerLearnInstantSpell(cid, spells[i].nazwa_czaru) 
                doSendMagicEffect(getCreaturePosition(cid), 12) 
            else 
                npcHandler:say("You don\'t have enough money.", cid) 
            end 
        end 
    end 
end 
end 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
Status
Not open for further replies.
Top