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

Custom Npc

prav

New Member
Joined
Aug 6, 2014
Messages
61
Reaction score
0
Hey guys im currently trying to make two npcs one that will give you hell promotion and another that will give you heaven promotion however it wont allow me to chose what one i want no matter what npc i talk to it keeps giving me the hell promotion does anyone maybe have a script that allows me to get the correct promotion from the correct npc? Thanks in advance for helping.( Rep++)
 
No one knows what distro your using except maybe Xikini but....You can try this....

Lua:
local focuses = {}
local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end

local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end
end
local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v)) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end

function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
    if(isFocused(cid)) then
        selfSay("Hmph!")
        removeFocus(cid)
        if(isPlayer(cid)) then --Be sure he's online
            closeShopWindow(cid)
        end
    end
end

local vocations =
{
    --[Master sorc] = {Heaven sorc}
    [5] = {new_voc = 13},
    --[Elder Druid] = {Heaven druid}
    [6] = {new_voc = 14},
    --[Royal paladin] = {Heaven paladin}
    [7] = {new_voc = 15},
    --[Elite knight] = {Heaven knight}
    [8] = {new_voc = 16}
}


function onCreatureSay(cid, type, msg)
    if((msg == "hi") and not (isFocused(cid))) then
        selfSay("You can recieve the heaven {promotion} from me.", cid)
        addFocus(cid)
    elseif((isFocused(cid)) and (msg == "promotion" or msg == "Promotion")) then
        if getPlayerVocation(cid) < 8 then
            selfSay("Are you sure you would like the heaven promotion?", cid)
        else
            selfSay("You have already recieved the heaven or hell promotion.", cid)
        end
    elseif((isFocused(cid)) and (msg == "yes" or msg == "Yes")) then
        VOC = vocations[getPlayerVocation(cid)]
        if not VOC then
            selfSay("You cannot recieve this promotion!", cid)
        else
            selfSay("You have recieved the heaven promotion!", cid)
            setPlayerVocation(cid, VOC.new_voc)
        end
    end
end

function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end
 
No one knows what distro your using except maybe Xikini but....You can try this....

Lua:
local focuses = {}
local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end

local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end
end
local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v)) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end

function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
    if(isFocused(cid)) then
        selfSay("Hmph!")
        removeFocus(cid)
        if(isPlayer(cid)) then --Be sure he's online
            closeShopWindow(cid)
        end
    end
end

local vocations =
{
    --[Master sorc] = {Heaven sorc}
    [5] = {new_voc = 13},
    --[Elder Druid] = {Heaven druid}
    [6] = {new_voc = 14},
    --[Royal paladin] = {Heaven paladin}
    [7] = {new_voc = 15},
    --[Elite knight] = {Heaven knight}
    [8] = {new_voc = 16}
}


function onCreatureSay(cid, type, msg)
    if((msg == "hi") and not (isFocused(cid))) then
        selfSay("You can recieve the heaven {promotion} from me.", cid)
        addFocus(cid)
    elseif((isFocused(cid)) and (msg == "promotion" or msg == "Promotion")) then
        if getPlayerVocation(cid) < 8 then
            selfSay("Are you sure you would like the heaven promotion?", cid)
        else
            selfSay("You have already recieved the heaven or hell promotion.", cid)
        end
    elseif((isFocused(cid)) and (msg == "yes" or msg == "Yes")) then
        VOC = vocations[getPlayerVocation(cid)]
        if not VOC then
            selfSay("You cannot recieve this promotion!", cid)
        else
            selfSay("You have recieved the heaven promotion!", cid)
            setPlayerVocation(cid, VOC.new_voc)
        end
    end
end

function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end
Yeah.. looking back, I actually have no idea.
 
Yeah.. looking back, I actually have no idea.
Ye i dont either I got the server from an friend who started working on it a while ago and just gave up on it and left it soI though id start working on it again but is there any way to check cuz there is no way i will be able to get in contact with my friend he's been offline for about a year.
 
Ye i dont either I got the server from an friend who started working on it a while ago and just gave up on it and left it soI though id start working on it again but is there any way to check cuz there is no way i will be able to get in contact with my friend he's been offline for about a year.
When the server starts up, the first or second line will have the server version listed there.
 
No one knows what distro your using except maybe Xikini but....You can try this....

Lua:
local focuses = {}
local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end

local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end
end
local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v)) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end

function onCreatureAppear(cid)
end

function onCreatureDisappear(cid)
    if(isFocused(cid)) then
        selfSay("Hmph!")
        removeFocus(cid)
        if(isPlayer(cid)) then --Be sure he's online
            closeShopWindow(cid)
        end
    end
end

local vocations =
{
    --[Master sorc] = {Heaven sorc}
    [5] = {new_voc = 13},
    --[Elder Druid] = {Heaven druid}
    [6] = {new_voc = 14},
    --[Royal paladin] = {Heaven paladin}
    [7] = {new_voc = 15},
    --[Elite knight] = {Heaven knight}
    [8] = {new_voc = 16}
}


function onCreatureSay(cid, type, msg)
    if((msg == "hi") and not (isFocused(cid))) then
        selfSay("You can recieve the heaven {promotion} from me.", cid)
        addFocus(cid)
    elseif((isFocused(cid)) and (msg == "promotion" or msg == "Promotion")) then
        if getPlayerVocation(cid) < 8 then
            selfSay("Are you sure you would like the heaven promotion?", cid)
        else
            selfSay("You have already recieved the heaven or hell promotion.", cid)
        end
    elseif((isFocused(cid)) and (msg == "yes" or msg == "Yes")) then
        VOC = vocations[getPlayerVocation(cid)]
        if not VOC then
            selfSay("You cannot recieve this promotion!", cid)
        else
            selfSay("You have recieved the heaven promotion!", cid)
            setPlayerVocation(cid, VOC.new_voc)
        end
    end
end

function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end
That script dont work btw it just wont give me the promotion the npc says he has gave me it but it dont show when you click on the char.
 
Soz im going to back out of helping you here. The server you are using is trash and doesn't support any easy scripting methods. Everything you try to do on there is going to be a pain in the ass. It's actually so bad that most people have forgotten how to code it properly and will have to do trial and error with you. TFS is still, by far, the best.
 
For the record, just got home and tried my script I posted here....
It works flawlessy without any errors.
So you must've copy-pasted incorrectly.
You can even see that the post is not edited, so it's not like I changed anything.

aO7g1YE.png
 
For the record, just got home and tried my script I posted here....
It works flawlessy without any errors.
So you must've copy-pasted incorrectly.
You can even see that the post is not edited, so it's not like I changed anything.

aO7g1YE.png
I must have done something wrong then ill try and test it again now making sure that I copy it correctly.

Soz im going to back out of helping you here. The server you are using is trash and doesn't support any easy scripting methods. Everything you try to do on there is going to be a pain in the ass. It's actually so bad that most people have forgotten how to code it properly and will have to do trial and error with you. TFS is still, by far, the best.
Ok i will change the server engine.
 
Last edited by a moderator:
Back
Top