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

[tfs 1.2] Rune add 50 premium points

Szafi

www.rookwar.pl
Joined
Mar 2, 2009
Messages
165
Reaction score
10
Location
Poland
Hello. I have old script

Code:
local cfg = 
{
    points = 100,
    effect = CONST_ME_GIFT_WRAPS
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(not isPlayer(itemEx.uid)) then
        return false
    end

    db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. cfg.points .. " WHERE `name` = '" .. getAccountByName(getCreatureName(itemEx.uid)) .. "' LIMIT 1;")
    doCreatureSay(cid, "You have received " .. cfg.points .. " premium points!", TALKTYPE_ORANGE_1, false, nil, toPosition)
    doSendMagicEffect(toPosition, cfg.effect)
    doRemoveItem(item.uid, 1)
    return true
end

how to convert to tfs 1.2? Where i found functions name etc. Thanks for reply/convert
 
Code:
local cfg =
{
points = 100,
effect = CONST_ME_GIFT_WRAPS
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target or not target:isItem() then
return false
end

db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. cfg.points .. " WHERE `name` = '" .. player:getAccountId() .. "' LIMIT 1;")
toPosition:player:say("You have received " .. cfg.points .. " premium points!", TALKTYPE_MONSTER_SAY)
toPosition:sendMagicEffect(cfg.effect)
player:removeItem(item.uid, 1)
return true
end

I'm on my android, can't remember the function that replaces "getaccountbyname......." but the rest should be converted. The functions can be found in https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua and https://github.com/otland/forgottenserver/blob/master/src/luascript.cpp

edit: nvm, should be converted
 
Last edited:
Code:
local cfg =
{
points = 100,
effect = CONST_ME_GIFT_WRAPS
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target or not target:isItem() then
return false
end

db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. cfg.points .. " WHERE `name` = '" .. player:getAccountId() .. "' LIMIT 1;")
toPosition:player:say("You have received " .. cfg.points .. " premium points!", TALKTYPE_MONSTER_SAY)
toPosition:sendMagicEffect(cfg.effect)
player:removeItem(item.uid, 1)
return true
end

I'm on my android, can't remember the function that replaces "getaccountbyname......." but the rest should be converted. The functions can be found in https://github.com/otland/forgottenserver/blob/master/data/lib/compat/compat.lua and https://github.com/otland/forgottenserver/blob/master/src/luascript.cpp

edit: nvm, should be converted
There is no row `premium_points` in tfs 1.0 + , this is depending on the aac.

Please specify what aac you are using.
 
He asked which aac not tfs :p (Znote/Gesior/Modern/etc)

PS. backward compability is like fastfood for lazy people.
Just learn 1.x code it's much simpler than the older versions and don't try to get too comfortable. Technology is moving forward, drag your feet and you'll be left behind.
Actually there is no such thing as 1.x code, learning how functions work is more important than using metatables, not all procedures require an entire object to perform a simple action especially when these metatables take up much more memory/resources then a simple function.

Just learning the framework of linking objects together isn't learning how to program you really need to understand the underlying structure of the language this way through trial & error (which is an important aspect of learning to code), you find somewhat of a balance of when to use OOP concepts or procedural programming.
 
Back
Top