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

Solved [CreatureScripts] Need a little Help. Please

RosOT

Who am i?
Joined
Feb 12, 2013
Messages
714
Reaction score
137
Location
Canada
Well, i Wanted to make my Rebirth/prestige script what ever you guys wana call it tell you if you had Legend aswell. I made it there are no error's just the fact that when you look at someone nothing happends no errors or crashs.

Here is my Version of the script.
Code:
function onLook(cid, thing, position, lookDistance)
    if(isPlayer(thing.uid) and thing.uid ~= cid and getPlayerPrestige(thing.uid) ~= -1 and getPlayerLPrestiges(thing.uid) ~= -1) then
        doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == PLAYERSEX_FEMALE and ".\nShe" or ".\nHe") .. " has " .. getPlayerPrestige(thing.uid) .. " " .. (getPlayerPrestige(thing.uid) == 1 and "Prestiges" or "Prestige") "and has" .. getPlayerLPrestiges(thing.uid) .. " " .. (getPlayerLPrestiges(thing.uid) == 1 and "Legends" or "Legend."))
    elseif(thing.uid == cid and getPlayerPrestige(cid) ~= -1 and getPlayerLPrestiges(cid) ~= -1) then
        local message = "You see yourself."
        if(getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION)) then
            message = message .. " You are " .. getPlayerGroupName(cid) .. "."
        elseif(getPlayerVocation(cid) ~= 0) then
            message = message .. " You are a " .. getPlayerVocationName(cid):lower() .. "."
        else
            message = message .. " You have no vocation."
        end
        if(getPlayerByName(getPlayerPartner(cid), false, false) ~= nil) then
            message = message .. " You are " .. (getPlayerSex(cid) == PLAYERSEX_FEMALE and "wife" or "husband") .. " of " .. getPlayerByName(getPlayerPartner(cid)) .. "."
        end
        if(getPlayerGuildId(cid) > 0) then
            message = message .. " You are " .. (getPlayerGuildRank(cid) == "" and "a member" or getPlayerGuildRank(cid)) .. " of the " .. getPlayerGuildName(cid)
            message = getPlayerGuildNick(cid) ~= "" and message .. " (" .. getPlayerGuildNick(cid) .. ")." or message .. "."
        end
        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS)) then
            message = message .. "\nHealth: [" .. getCreatureHealth(cid) .. " / " .. getCreatureMaxHealth(cid) .. "], Mana: [" .. getCreatureMana(cid) .. " / " .. getCreatureMaxMana(cid) .. "]."
            message = message .. "\nIP: " .. doConvertIntegerToIp(getPlayerIp(cid)) .. "."
        end
        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION)) then
            message = message .. "\nPosition: [X: " .. position.x .. "] [Y: " .. position.y .. "] [Z: " .. position.z .. "]."
        end
        return false, doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, message .. " \nYou have " .. getPlayerPrestige(cid) .. " " .. (getPlayerPrestige(cid) == 1 and "Prestiges." or "Prestige") "and you have " .. getPlayerLPrestiges(cid) .. " " .. (getPlayerLPrestiges(cid) == 1 and "Legends." or "Legend."))
    end
    return true
end

My Legend Prestige Function.
Code:
 -- Legend Prestige --
function getPlayerLPrestiges(cid)
    local Info = db.getResult("SELECT `LPrestiges` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
        if Info:getID() ~= LUA_ERROR then
        local Lpres= Info:getDataInt("LPrestiges")
        Info:free()
        return Lpres
    end
    return LUA_ERROR
end

This is the Original script i had gotten from a fellow otlander.
http://otland.net/threads/best-rebirth-system-mysql-by-mlody-1039-with-gesior-script.186274/
 
Last edited:
Yes thats what it is now but i want it to say

16:45 You see yourself. You are a Assassin.
You have prestiged 10 times.
You have Legend prestiged 65 times.
 
Ok i have it so max rebirth/prestige is 500 so when you get 500 you can go do the legend prestige quest and it takes all ur prestiges away and gives you 1 legend prestige then you need to get another 500 prestiges to get another legend.

Same as getting lvls for reg prestige but you get prestiges instead

I have everything else made 100% Functional I just cant get it to show legend prestige along with Prestige when you look at someone.

Here is my function may help some.
Code:
 -- Legend Prestige --
function getPlayerLPrestiges(cid)
    local Info = db.getResult("SELECT `LPrestiges` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
        if Info:getID() ~= LUA_ERROR then
        local Lpres= Info:getDataInt("LPrestiges")
        Info:free()
        return Lpres
    end
    return LUA_ERROR
end
 
so i can give you basics how can u do it :D
make another copy of your rebirth script
but change prestige to legend prestige
and use another storage

so u have 2 rebirth scripts
1 with storage 1234
2 with storage 1235

:D
and if you need the legend prestige with npc
so make it check if storage 1234 == 500
then update storage 1234 == 0
and storage 1235 == 1 :D

i'm not on pc so i can't write script xD
 
Also if your not busy can you add this into the NPC script so the players get Prestige Points as well would appreciate it :p.
[Put a config if possible :) ]

NPC~
Code:
local config = {
    price = 0, -- Price of first Prestige
    priceIncrease = 10000, -- Works as 'price' + current Prestiges * priceIncrease.
    PrestigeLevel = 500, -- Level for first Prestige.
    PrestigeIncrease = 0, -- Works as 'PrestigeLevel' + current Prestiges * PrestigeIncrease.
    maxPrestiges = 500, -- Number of times a player can Prestige.
    level = 8, -- The level the player is set to apon Prestige.
    healthPercent = 1.00, -- 1.00 = 100%.
    health = 100, -- Only used if 'healthPercent' = 0.
    manaPercent = 1.00, -- 1.00 = 100%.
    mana = 100, -- Only used if 'manaPercent' = 0.
    keepSkills = true, -- Wether players keep skills and level apon Prestige.
    skillLevel = 10, -- Only used if 'keepSkills' = false.
    magicLevel = 0, -- Only used if 'keepSkills' = false.
    capacity = 10000, -- The capacity players are set to apon Prestige.
    templePos = {x = 0, y = 0, z = 0}, -- The place where players reset to should there town id return 0.
    Prestige = 1 -- how many Prestige player will get.
}
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 onCreatureDisappear(cid)
    if(isFocused(cid)) then
        selfSay("Goodbye.")
        removeFocus(cid)
    end
end

 
function onCreatureSay(cid, type, msg)
    if((msg == "hi") and not (isFocused(cid))) then
        selfSay("Welcome, ".. getCreatureName(cid) ..".", cid, true)
        selfSay("Im in charge of the {Prestige} system. If you want to {Prestige} just say {Pres}.", cid)
        addFocus(cid)
        status = 1
    elseif((isFocused(cid)) and (msg == "prestige")  or (msg == "prestige") or (msg == "pres")  and (status == 1)) then
              if(isInArray({1,2,3,4,5, 6, 7, 8,9,10,11,12}, getPlayerVocation(cid))) then
        if (getPlayerPrestige(cid, config.Prestige) < config.maxPrestiges) then
            Prestige = getPlayerPrestige(cid, config.Prestige)
            PrestigeLevel = config.PrestigeLevel + (config.PrestigeIncrease * Prestige)
            if (getPlayerLevel(cid) >= PrestigeLevel) then
                money = config.price + (config.priceIncrease * Prestige)
                if (getPlayerMoney(cid) >= money) then
                    selfSay("Once you Prestige you will have to level up again from the beginning! Are you sure you still want to Prestige?", cid)
                    status = 2
                else
                    selfSay("You need at least " .. money .. " gold before you can Prestige.", cid)
                    status = 1
                end
                else
                    selfSay("You need to be at least level " .. PrestigeLevel .. " before you can Prestige.", cid)
                status = 1
                end
            else
            selfSay("It seems you can not Prestige anymore you are max Prestige .", cid)
            status = 1
            end
        else
            selfSay("Please get promotion first.", cid)
            status = 1
        end
    elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
        selfSay("Ok then i will Prestige you.", cid)
        selfSay("You will now be logged out.", cid)
        doPlayerRemoveMoney(cid, money)
        addEvent(doPrestigePlayer, 0, {cid=cid})
        removeFocus(cid)
    elseif((isFocused(cid)) and (msg == "no") and (status == 2)) then
        selfSay("Maybe one day you will wise up and change your mind!", cid)
        status = 1
    elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
        selfSay("Goodbye!", cid, true)
        removeFocus(cid)
    end
end
function onPlayerCloseChannel(cid)
    if(isFocused(cid)) then
        selfSay("Goodbye.")
        removeFocus(cid)
    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
                selfSay("Goodbye.")
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end
function doPrestigePlayer(cid)
    cid = cid.cid
    if (cid == nil) then
        return true
    end
    local guid = getPlayerGUID(cid)
    if (config.healthPercent > 0) then
        health = getCreatureMaxHealth(cid) * config.healthPercent
    else
        health = config.health
    end
    if (config.manaPercent > 0) then
        mana = getCreatureMaxMana(cid) * config.manaPercent
    else
        mana = config.mana
    end
    if (getPlayerTown(cid) > 0) then
        pos = getTownTemplePosition(getPlayerTown(cid))
    else
        pos = config.templePos
end
    doAddPrestige(cid, config.Prestige, getPlayerPrestige(cid, config.Prestige) + 1)
    doRemoveCreature(cid, true)
    db.executeQuery("UPDATE `players` SET level = " .. config.level .. ", health = " .. health .. ", healthmax = " .. health .. ", mana = " .. mana .. ", manamax = " .. mana .. ", posx = " .. pos.x .. ", posy = " .. pos.y .. ", posz = " .. pos.z .. ", cap = " .. config.capacity .. " WHERE id = " .. guid)
   
    if (not config.keepSkills) then
        db.executeQuery("UPDATE `players` SET maglevel = " .. config.magicLevel .. " WHERE id = " .. guid .. ";")
        db.executeQuery("UPDATE `player_skills` SET value = " .. config.skillLevel .. " WHERE id = " .. guid .. ";")
    end
    return true
end

Points Function~
Code:
function doAddPrestigeP(cid, presp)
    db.executeQuery("UPDATE `players` SET `Prestige Points` = `Prestige Points` + " .. presp .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
end
 
so i can give you basics how can u do it :D
make another copy of your rebirth script
but change prestige to legend prestige
and use another storage

so u have 2 rebirth scripts
1 with storage 1234
2 with storage 1235

:D
and if you need the legend prestige with npc
so make it check if storage 1234 == 500
then update storage 1234 == 0
and storage 1235 == 1 :D

i'm not on pc so i can't write script xD


See that's what i don't wanna do the prestige and legend Prestige go by database, I don't wanna use storage id's
 
Thats why i posted the functions sir :p'
Code:
 -- Prestige --
function getPlayerPrestige(cid)
    local Info = db.getResult("SELECT `Prestige` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
        if Info:getID() ~= LUA_ERROR then
        local pres= Info:getDataInt("Prestige")
        Info:free()
        return pres
    end
    return LUA_ERROR
end
function doAddPrestige(cid, pres)
    db.executeQuery("UPDATE `players` SET `Prestige` = `Prestige` + " .. pres .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
end
function doRemovePrestige(cid, pres)
    db.executeQuery("UPDATE `players` SET `Prestige` = `Prestige` - " .. pres .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
end
Code:
 -- Legend Prestige --
function getPlayerLPrestiges(cid)
    local Info = db.getResult("SELECT `LPrestiges` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
        if Info:getID() ~= LUA_ERROR then
        local Lpres= Info:getDataInt("LPrestiges")
        Info:free()
        return Lpres
    end
    return LUA_ERROR
end
function doAddLPrestiges(cid, Lpres)
    db.executeQuery("UPDATE `players` SET `LPrestiges` = `LPrestiges` + " .. Lpres .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
end
function doRemoveLPrestiges(cid, pres)
    db.executeQuery("UPDATE `players` SET `LPrestiges` = `LPrestiges` - " .. Lpres .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
end
 
The script i posted does not work at all there are no error's When i look at myself or someone ingame it does not say anything there for the script is broken with no error's.
 
the onLook creaturescript comes from my reputation system script, which server are you trying this at?
 
Back
Top