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

Rank system

zakius

Enter the Ninja!
Joined
Apr 30, 2009
Messages
2,635
Reaction score
65
Location
with Taiga
I want to make rank system like this posted by Gelio,( http://otland.net/f35/level-ranks-23463/) but using additional field in players table instead of level, i tried with this few hours but i dont know how read this field from database.
Im newbie in programming but i posted it here because i have no idea how force this lua version to work
Can anybody help me with this problem?
 
In there post, there is a script made by slawkens! -> http://otland.net/f35/level-ranks-23463/#post238148

Here is (Works with TFS 0.3.4)

Lua:
local ranks =
{
	--fromLevel, rank
	--from hightest rank, to lowest
	{135, "master of life and death"},
	{120, "PK mastah"},
	{105, "general"},
	{90, "experienced guard"},
	{75, "guard"},
	{60, "experienced soldier"},
	{45, "soldier"},
	{40, "newbie"}
}

function onLook(cid, lookThing)
	if(isPlayer(lookThing) == TRUE) then
		local level = getPlayerLevel(lookThing)
		local tmp = "He"
		if(getPlayerSex(lookThing) == PLAYERSEX_FEMALE) then
			tmp = "She"
		end

		for _, t in pairs(ranks) do
			if(level >= t[1]) then
				return "\n" .. tmp .. " is a " .. t[2] .. "."
			end
		end
	end

	return TRUE
end
 
Hemm, ok ill try once more with this, but i wanted to make sth showing ur rank gained during a quest, so i need to replace lvl by sth and i have no idea how... Anyway ill try to modify this script. Thx
 
Aww, i just dont know how to start this script, i have 0.3.4 and it just dont work, without any errors...
Where i have to put it?
 
Change the levels for the storage id, example:

Lua:
local ranks =
{
        --fromLevel, rank
        --from hightest rank, to lowest
        {15000, "master of life and death"},
        {13250, "PK mastah"},
        {11450, "general"},
        {5600, "experienced guard"},
        {25400, "guard"},
        {12655, "experienced soldier"},
        {65535, "soldier"},
        {0, "newbie"}
}

change:
Lua:
local level = getPlayerLevel(lookThing)
To:
Lua:
local storage = getPlayerStorageValue(lookThing, t[1])
and move it after "for _, t in pairs(ranks) do"

Later, change:
Lua:
if(level >= t[1]) then
To:
Lua:
if(storage > 0) then

It would look like this:

Lua:
local ranks =
{
        --fromLevel, rank
        --from hightest rank, to lowest
        {15000, "master of life and death"},
        {13250, "PK mastah"},
        {11450, "general"},
        {5600, "experienced guard"},
        {25400, "guard"},
        {12655, "experienced soldier"},
        {65535, "soldier"},
        {0, "newbie"}
}

function onLook(cid, lookThing)
        if(isPlayer(lookThing) == TRUE) then
                local tmp = "He"
                if(getPlayerSex(lookThing) == PLAYERSEX_FEMALE) then
                        tmp = "She"
                end

                for _, t in pairs(ranks) do
                local storage = getPlayerStorageValue(lookThing, t[1])
                        if(storage > 0) then
                                return "\n" .. tmp .. " is a " .. t[2] .. "."
                        end
                end
        end

        return TRUE
end

Sorry my bad english xD!

SCRIPT NOT TESTED!
 
I dont understand why each rank is in diffirent storage id, i trhought about sth storage value can grow up like lvl, but in diffirent situations

And my biggest problem is i dont know where i have to put this script, i think it should be in function.lua, but im not sure...
and i get no effect when i put it in this file, but i have no idea what else could it be
maybe creaturescript , type sth like look, onlook or i dont know

And i have small question: Can storage values be texts?


Edit:
I tried to just add sth to description of player, without any variables and hemm how to say it in english? ifs xD
no errors, no effects oO
Lua:
function onLook(cid, lookThing)
        if(isPlayer(lookThing) == TRUE) then
		    	setPlayerSpecialDescription(cid, noob)
					end
        return TRUE
end
i tried sth like this
 
Last edited:
slawkens suggested this function so i tried to use it xD
but if it doesnt exist why i get no errors?
anyway it means that its impossible in lua, so ill try once more with sources, if ill got any effects ill post my code
 
Back
Top Bottom