• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Exp for premiums - TFS v0.2.14 (Mystic Spirit)

Darkness2144

New Member
Joined
Dec 27, 2010
Messages
6
Reaction score
0
Hello, OtLand :)

I'm having trouble finding a solution for [9.60/9.61] The Forgotten Server v0.2.14 (Mystic Spirit).
Link: http://otland.net/f18/9-60-9-61-forgotten-server-v0-2-14-mystic-spirit-166619/

What I need is giving Premium members additional experience (50%)

Here was my shot:

XML:
<event type="login" name="PremiumXP" script="premium.lua" />

LUA:
function onLogin(cid)
	
local config = { rate = 1.5 } -- 50% extra experience
local rates = getPlayerRates(cid)

if getPlayerPremiumDays(cid) >= 1 then
doPlayerSetRate(cid, rates[SKILL__LEVEL]*config.rate)
	end
	return TRUE
end

The problem: I couldn't find a proper function to replace getPlayerRates(cid)
Since the version I use (above) does not have it. I'm thinking if I could add a function somehow but need some guidance, Will REP!

LUA FUNCTIONS:
Code:
	//*GET
	
		getPlayerMasterPos(cid)
		getPlayerLossPercent(cid)
		getItemIdByName(name)
		getTownName(townId)
		getTownTemplePosition(townId)
		getPlayersByAccountNumber(accountNumber)
		getAccountNumberByPlayerName(name)
		getIPByPlayerName(name)
		getPlayersByIPAddress(ip[, mask = 0xFFFFFFFF])
		getFluidSourceType(type)
		getItemDescriptions(itemid)
		getItemWeightByUID(uid)
		getContainerCapById(itemid)
		getDepotId(uid)
		getHouseTilesSize(houseid)
		getHighscoreString(skillId)
		getPartyMembers(leaderId)
		getCreatureMaster(cid) - Returns: returns the creature's master or itself if the creature isn't a summon
		getMonsterTargetList(cid)
		getMonsterFriendList(cid)
		getPlayerByName(name)
		getPlayerGUIDByName(name)	
		getPlayerLearnedInstantSpell(cid, name)
		getPlayerInstantSpellCount(cid)
		getPlayerInstantSpellInfo(cid, index)
		getPlayerMount(cid, mountid)
		getWorldType()
		getWorldTime()
		getWorldLight()
		getWorldCreatures(type) - Types: 0 players, 1 monsters, 2 npcs, 3 all Returns: Amount
		getWorldUpTime()
		getGuildId(guild_name)
		getPlayerSex(cid)
		getContainerSize(uid)
		getContainerCap(uid)
		getContainerItem(uid, slot)
		getInstantSpellInfoByName(cid, name)
		getInstantSpellWords(name)
		getGlobalStorageValue(valueid)
		getHouseOwner(houseid)
		getHouseName(houseid)
		getHouseEntry(houseid)
		getHouseRent(houseid)
		getHouseTown(houseid)
		getHouseAccessList(houseid, listid)
		getHouseByPlayerGUID(playerGUID)
		getCreatureOutfit(cid)
		getCreaturePosition(cid)
		getCreatureName(cid)
		getCreatureSpeed(cid)
		getCreatureBaseSpeed(cid)
		getCreatureTarget(cid)
		getTilePzInfo(pos) - Returns: 1 is pz. 0 no pz.
		getTileHouseInfo(pos) - Returns: 0 no house. != 0 house id
		getItemRWInfo(uid)
		getThingfromPos(pos)
		getThing(uid)
		getCreatureCondition(cid, condition)
		getItemName(itemid)
		getItemWeight(itemid, count)
		getPlayerPremiumDays(cid)
		getPlayerSkullType(cid)
		getPromotedVocation(vocation)
		getPlayerBlessing(cid, blessing)
		getTileThingByTopOrder(pos, topOrder)
		getTileItemByType(pos, type)
		getTopCreature(pos)
		getTileThingByPos(pos)
		getTileItemById(pos, itemId, <optional> subType)
		getOnlinePlayers()
		getTileInfo(pos) 
		getThingPos(uid)
		getSpectators(centerPos, rangex, rangey, multifloor)
		getPlayerStorageValue(uid, valueid)
		getPlayerItemById(cid, deepSearch, itemId, <optional> subType)
		getPlayerIp(cid)
		getPlayerGuildLevel(cid)
		getCreatureSummons(cid) - Returns: returns a table with all the summons of the creature
	
	//*DO
	
		doPlayerAddBlessing(cid, blessing)
		doPlayerPopupFYI(cid, message)
		doCombat(cid, combat, param)
		doPlayerRemovePremiumDays(cid, days)
		doPlayerAddPremiumDays(cid, days)
		doPlayerSetSex(cid, newSex)
		doSetCreatureOutfit(cid, outfit, time)
		doSetItemOutfit(cid, item, time)
		doSetMonsterOutfit(cid, name, time)
		doChangeSpeed(cid, delta)
		doAddContainerItem(uid, itemid, <optional> count/subtype)
		doChallengeCreature(cid, target)
		doTargetCombatDispel(cid, target, type, effect)
		doAreaCombatDispel(cid, pos, area, type, effect)
		doTargetCombatCondition(cid, target, condition, effect)
		doAreaCombatCondition(cid, pos, area, condition, effect)
		doTargetCombatMana(cid, target, min, max, effect)
		doAreaCombatMana(cid, pos, area, min, max, effect)
		doTargetCombatHealth(cid, target, type, min, max, effect)
		doAreaCombatHealth(cid, type, pos, area, min, max, effect)
		doSetCreatureDropLoot(cid, doDrop)
		doSetCreatureLight(cid, lightLevel, lightColor, time)
		doPlayerRemoveMount(cid, mountid)
		doPlayerAddMount(cid, mountid)
		doPlayerRemOutfit(cid,looktype,addons)
		doPlayerAddOutfit(cid,looktype,addons)
		doPlayerSetGuildNick(cid, nick)
		doPlayerSetGuildRank(cid, rank)
		doPlayerSetGuildId(cid, id)
		doPlayerAddExp(cid,exp)
		doPlayerRemoveItem(cid,itemid,count)
		doPlayerSetVocation(cid,voc)
		doPlayerSetTown(cid, townid)
		doMoveCreature(cid, direction)
		doRemoveCreature(cid)
		doConvinceCreature(cid, target)
		doSummonCreature(name, pos)
		doCreateTeleport(itemid, topos, createpos)
		doTileAddItemEx(pos, uid)
		doCreateItemEx(itemid, <optional> count/subtype) - Returns: Returns uid of the created item, only works on tiles.
		doCreateItem(itemid, type/count, pos) - Returns: Returns uid of the created item, only works on tiles.
		doDecayItem(uid)
		doShowTextDialog(cid, itemid, text)
		doPlayerRemoveMoney(cid, money)
		doPlayerSendTextMessage(cid, MessageClasses, message)
		doPlayerAddItemEx(cid, uid, <optional: default: 0> useCidPosOnFail)
		doPlayerAddItem(uid, itemid, <optional> count/subtype) - Returns: Returns uid of the created item
		doPlayerAddSoul(cid, soul)
		doPlayerAddManaSpent(cid, mana)
		doPlayerAddMana(cid, mana)
		doCreatureAddHealth(cid, health)
		doPlayerAddSkillTry(cid, skillid, n)
		doSendAnimatedText(pos, text, color)
		doSetItemSpecialDescription(uid, desc)
		doSetItemText(uid, text)
		doSetItemActionId(uid, actionid)
		doChangeTypeItem(uid, newtype)
		doSendDistanceShoot(frompos, topos, type)
		doSendMagicEffect(pos, type)
		doCreatureSay(cid, text, type)
		doTransformItem(uid, toitemid, <optional> count/subtype)
		doTeleportThing(cid, newpos, <optional> pushmove)
		doPlayerSendDefaultCancel(cid, ReturnValue)
		doRemoveCondition(cid, type)
		doAddCondition(cid, condition)
		doMonsterChangeTarget(cid)
		doSetMonsterTarget(cid, target)
		doCreatureChangeOutfit(cid, outfit)
		doCreateNpc(name, pos)
		doRelocate(pos, posTo) - Returns: Moves all moveable objects from pos to posTo
		doAddContainerItemEx(uid, virtuid)
		doSendTutorial(cid, tutorialid)
		doCreatureSetLookDir(cid, direction)		
		doPlayerFeed(cid, food)
		doRemoveItem(uid, <optional> n)
		doAddMapMark(cid, pos, type, <optional> description)    
		doPlayerAddMoney(cid, money)
		doPlayerChangeName(cid, newName) 
		doSetCreatureDirection(cid, direction)
	
	//*SET
	
		setHouseAccessList(houseid, listid, listtext)
		setHouseOwner(houseid, ownerGUID)
		setCombatArea(combat, area)
		setCombatCondition(combat, condition)
		setCombatParam(combat, key, value)
		setConditionParam(condition, key, value)
		setCombatCallBack(combat, key, function_name)
		setCombatFormula(combat, type, mina, minb, maxa, maxb)
		setConditionFormula(combat, mina, minb, maxa, maxb)
		setGlobalStorageValue(valueid, newvalue)
		setPlayerGroupId(cid, newGroupId)
		setPlayerStorageValue(uid, valueid, newvalue)

	
	
	
		
	//*IS
		
		isPlayer(cid)
		isCreature(cid)
		isContainer(uid)
		isMoveable(uid)
		isSightClear(fromPos, toPos, floorCheck)
		isValidUID(uid)
		isPlayerGhost(cid)
		isPlayerPzLocked(cid)
		isDepot(uid)
		isCorpse(uid)
		isMovable(uid)
		isItemMovable(itemid)
		isItemMoveable(itemid)
		isItemStackable(itemid)
		isItemRune(itemid)
		isItemDoor(itemid)
		isItemContainer(itemid)
		isItemFluidContainer(itemid)
		isInArray(array, value)
		
	//*MISC
	
		broadcastMessage(message, type)
		createCombatArea( {area}, <optional> {extArea} )
		canPlayerWearOutfit(cid, looktype, addons)
		hasProperty(uid, prop)
		refreshMap()
		cleanMap()
		createConditionObject(type)
		addDamageCondition(condition, rounds, time, value)
		addOutfitCondition(condition, lookTypeEx, lookType, lookHead, lookBody, lookLegs, lookFeet)
		createCombatObject()
		numberToVariant(number)
		stringToVariant(string)
		positionToVariant(pos)
		targetPositionToVariant(pos)
		variantToNumber(var)
		variantToString(var)
		variantToPosition(var)
		debugPrint(text)
		addEvent(callback, delay, parameter)
		stopEvent(eventid)
		mayNotLogout(cid, value)
		mayNotMove(cid, value)
		saveData()
		saveServer(), does the same thing as saveData()
		escapeString(str)
		registerCreatureEvent(uid, eventName)
		queryTileAddThing(uid, pos, <optional> flags)
		playerLearnInstantSpell(cid, name)
		canPlayerLearnInstantSpell(cid, name)
		
]

EDIT: to clarify it's a creaturescript and I also added console output:

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/premium.lua:onLogin
data/creaturescripts/scripts/premium.lua:4: attempt to call global 'getPlayerRates' <a nil value>
stack traceback: [C]: in function 'getPlayerRates'
data/creaturescripts/scripts/premium.lua:4: in function <data/creaturescripts/scripts/premium.lua:1>
 
Last edited:
Then do a function manually by using the stage values like this:
LUA:
function getPlayerExpRate(cid)
    local lv = getPlayerLevel(cid)
    if lv >= 1 and < 20 then
        return 100
    elseif lv < 50 then
        return 60
    elseif lv < 100 then
        return 30
    else
        return 3
    end
end
 
Expect that my server didn't like it :(

Hmm, I not sure where to put this code, isn't it supposed to load from (lib/creaturescripts.lua)? Or am I completely off-track?

Console output:
Code:
[Warning - BaseEvents::loadFromXml] Can not load creaturescripts lib/creaturescripts.lua
Warning: [Event::checkScript] Can not load creaturescripts lib/creaturescripts.lua
Warning: [Event::checkScript] Can not load creaturescripts lib/creaturescripts.lua
Warning: [Event::checkScript] Can not load creaturescripts lib/creaturescripts.lua
Warning: [Event::checkScript] Can not load creaturescripts lib/creaturescripts.lua
Warning: [Event::checkScript] Can not load creaturescripts lib/creaturescripts.lua

Attempted code (some test values):
LUA:
function getPlayerRates(cid)
local level = getPlayerLevel(cid)
	if level >= 1 and < 8 then
		return 6
	else if level < 24 then
		return 5
	else if level < 36 then
		return 4
	else if level < 50 then
		return 3
	else if level < 65 then
		return 2
	else if level < 70 then
		return 1
	else
		return 0
	end
end

EDIT: Noticed I also am missing the function doPlayerSetRate... sigh if there only could be a simpler way, if anyone could help with on this one that would be great, will REP ofc!
 
Last edited:
How do I integrate a function from 0.3 into 0.2 or do I have to recompile the server?

getPlayerRates from SVN 0.3:

Code:
int32_t LuaInterface::luaGetPlayerRates(lua_State* L)
{
        //getPlayerRates(cid)
        ScriptEnviroment* env = getEnv();

        Player* player = env->getPlayerByUID(popNumber(L));
        if(!player)
        {
                errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
                lua_pushboolean(L, false);
                return 1;
        }

        lua_newtable(L);
        for(uint32_t i = SKILL_FIRST; i <= SKILL__LAST; ++i)
        {
                lua_pushnumber(L, i);
                lua_pushnumber(L, player->rates[(skills_t)i]);
                pushTable(L);
        }

        return 1;
}

Also the infamous doPlayerSetRate from SVN 0.3:

Code:
int32_t LuaInterface::luaDoPlayerSetRate(lua_State* L)
{
        //doPlayerSetRate(cid, type, value)
        float value = popFloatNumber(L);
        uint32_t type = popNumber(L);

        ScriptEnviroment* env = getEnv();
        if(Player* player = env->getPlayerByUID(popNumber(L)))
        {
                if(type <= SKILL__LAST)
                {
                        player->rates[(skills_t)type] = value;
                        lua_pushboolean(L, true);
                }
                else
                        lua_pushboolean(L, false);
        }
        else
        {
                errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
                lua_pushboolean(L, false);
        }

        return 1;
}
Ok, got it all figured out thanks Summ :)

For those wondering same thing as I did: http://otland.net/f16/help-forgotten-server-versions-maybe-some-compiling-172943/
 
Last edited:
Back
Top