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

[LUA][TFS 1.x] Printer's Free Coding Help and Request Service

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,782
Solutions
31
Reaction score
2,287
Location
Sweden?
Hello,

well i would like to make new thread. To help people make good and readable codes. I can also help you optimize your old codes and explain, if you post them here.

Here is some example of optimizations:

Usually what is see what people do:

Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 2148 then
        print("This is a gold coin.")
    elseif item.itemid == 2152 then
        print("This is a platium coin.")
    elseif item.itemid == 2160 then
        print("This is a crystal coin.")
    end

    return true
end

How i would do:
Code:
local config = {
    [2148] = "This is a gold coin.",
    [2152] = "This is a platium coin.",
    [2160] = "This is a crystal coin."
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    print(config[item.itemid])
end

or

Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    print("This is a ".. ItemType(item.itemid):getName() ..".")
end

Some useful codes:

Cheers everyone!
 
Last edited:
@Printer I use TFS 1.1

1. I'd like that the NPC gives a custom greet depending on the players vocation (that's what the first 'if' in the
creatureSayCallback function is for).
2. If the player doesn't have a vocation that the NPC offers him/her to join the NPC's faction (The Guard in this case)
3. If the player do joins the Guard, the NPC's must ask if the player want's to receive a small tutorial on how to use some custom spells for his/her vocation.

@Printer by any chance, have you been able to work on this one? :p

Thanks!
 
Hello there! First of all, thank you for all your effort trying to help people here in the community! Its awesome.

I don't really know if i'm asking a lot or not but im trying to figure out a specific spell.

For exemple. I want the spell to turn the caster into a wolf and double the attack speed.
For exemple. Turn into a bear and have tons of regen.
For exemple. Turn into a bat and heal % of the dmg done.
After X seconds, they turn to normal.
This are just exemples, i just dont know where to start. I can modify the source if needed given the right directions.

Thank you so much, i really appreciate your help and your efforts.
 
Hi Printer, well can you help me with this system? For TFS 1.2
Is the teckman military ranks, but i need add some attributes to the classes, for example:
when you reach bronze class, you got 10% extraSpeed, +200 Health, and one medal.
when you reach silver class, you got 20% extraSpeed, +250 Health, and one medal.
Etc, etc, all configurable..

And when you look a player or you loot yourself, you can see the class of the player, and how many frags he have.

Code:
<?xml version = "1.0" encoding = "UTF-8"?>
<mod name = "Military Ranks" version = "1.0" author = "Teckman" enabled = "yes">
<config name = "ranks"><![CDATA[
titles = {
[5] = "Bronze Class,
[10] = "Silver Class",
[15] = "Gold Class",
[20] = "Diamond Class"
}
fragsStorage = 600
]]></config>
<event type = "look" name = "ranksLook" event = "script"><![CDATA[
domodlib("ranks")
function onLook(cid, thing, position, lookDistance)
if(isPlayer(thing.uid)) then
local rank = {rank = "Private", frags = 0}
for k, v in pairs(titles) do
if(math.max(0, getPlayerStorageValue(thing.uid, fragsStorage)) > k - 1) then
if(k - 1 > rank.frags) then
rank.rank, rank.frags = v, k - 1
end
end
end
doPlayerSetSpecialDescription(thing.uid, "\n Military rank: " .. rank.rank)
end
return true
end
]]></event>
<event type = "kill" name = "ranksKill" event = "script"><![CDATA[
domodlib("ranks")
function onKill(cid, target)
if(isPlayer(target)) then
setPlayerStorageValue(cid, fragsStorage, math.max(0, getPlayerStorageValue(cid, fragsStorage) + 1))
if(titles[getPlayerStorageValue(cid, fragsStorage)]) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You advanced to military rank: " .. titles[getPlayerStorageValue(cid, fragsStorage)] .. ". Congratulations " .. titles[getPlayerStorageValue(cid, fragsStorage)] .. "!")
end
end
return true
end
]]></event>
<event type = "login" name = "ranksLogin" event = "script"><![CDATA[
function onLogin(cid)
registerCreatureEvent(cid, "ranksKill")
registerCreatureEvent(cid, "ranksLook")
return true
end
]]></event>
</mod>
 
Back
Top