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

C++ TFS 0.4 rev3777 8.60 "Summons"

Addams

OTMadness.com OTSes Services
Staff member
Board Moderator
Joined
Sep 29, 2009
Messages
2,920
Solutions
342
Reaction score
1,688
Location
Egypt
Hi, Can someone tell me which lines/source edits I need to do so its written on the summon like onlook "Summoned by"
I saw it on a few servers and I tried to do it but I always fail..
I don't have any screenshots to provide but I saw it on "Masiyah.se" which is offline now, he was using 0.3.6 I think so.

That is the tfs I am using
Fir3element/3777 (https://github.com/Fir3element/3777)
 
Solution
Obviously not tested :p
This gets saved in creaturescripts/scripts as lookatsummon.lua
Lua:
function onLook(cid, thing, position, lookDistance)
    if isCreature(thing.uid) then   
        local master = getCreatureMaster(thing.uid)
        -- might be redundant to ask if the master is a creature
        if master and isCreature(master) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Summoned by " .. getCreatureName(master) ..".")
        end
    end
    return true
end

This gets saved in creaturescripts.xml
XML:
<event type="look" name="lookAtSummon" event="script" value="lookatsummon.lua"/>

and this gets placed inside of login.lua
Lua:
registerCreatureEvent(cid, "lookAtSummon")
This isn't a source edit its a script.
Lua:
-- this would be a creaturescript
function onLook(cid, thing, position, lookDistance)
    return true
end
 
This isn't a source edit its a script.
Lua:
-- this would be a creaturescript
function onLook(cid, thing, position, lookDistance)
    return true
end

I tried to edit this its from 1.3 but after I am done, I get 0 errors in console and 0 errors when I look at summons but I don't anything when I look on summons.
Lua:
function onLook(cid, thing, position, lookDistance)
    if isCreature(thing) and isMonster(thing) then
        local owner = thing:getMaster()

        if owner ~= nil and owner:isPlayer() and thing:getId() == owner:getSummonUid() then
            local playerName = (owner:getId() == self:getId()) and "you" or owner:getName()
            local description = "You see a ".. getCreatureName(thing) ..", it belongs to "..playerName.."."

            if self:getGroup():getAccess() or playerName == 'you' then
                description = string.format("%s\nHealth: %d / %d", description, thing:getHealth(), thing:getMaxHealth()) .. "."
            end

            if self:getGroup():getAccess() then
                local position = thing:getPosition()
                description = string.format("%s\nPosition: %d, %d, %d", description, position.x, position.y, position.z)
            end
            self:sendTextMessage(MESSAGE_INFO_DESCR, description)
            return false
        end
    end
end
 
Obviously not tested :p
This gets saved in creaturescripts/scripts as lookatsummon.lua
Lua:
function onLook(cid, thing, position, lookDistance)
    if isCreature(thing.uid) then   
        local master = getCreatureMaster(thing.uid)
        -- might be redundant to ask if the master is a creature
        if master and isCreature(master) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Summoned by " .. getCreatureName(master) ..".")
        end
    end
    return true
end

This gets saved in creaturescripts.xml
XML:
<event type="look" name="lookAtSummon" event="script" value="lookatsummon.lua"/>

and this gets placed inside of login.lua
Lua:
registerCreatureEvent(cid, "lookAtSummon")
 
Solution
i think u can use "doPlayerSetSpecialDescription", because if you use, doPlayerSendTextMessage (cid, MESSAGE_INFO_DESCR) ... will only appear the message in the server log, not in the middle of the screen.
because one message would "cap" the other to be seen in the middle of the screen.
 
Obviously not tested :p
This gets saved in creaturescripts/scripts as lookatsummon.lua
Lua:
function onLook(cid, thing, position, lookDistance)
    if isCreature(thing.uid) then  
        local master = getCreatureMaster(thing.uid)
        -- might be redundant to ask if the master is a creature
        if master and isCreature(master) then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Summoned by " .. getCreatureName(master) ..".")
        end
    end
    return true
end

This gets saved in creaturescripts.xml
XML:
<event type="look" name="lookAtSummon" event="script" value="lookatsummon.lua"/>

and this gets placed inside of login.lua
Lua:
registerCreatureEvent(cid, "lookAtSummon")
i think u can use "doPlayerSetSpecialDescription", because if you use, doPlayerSendTextMessage (cid, MESSAGE_INFO_DESCR) ... will only appear the message in the server log, not in the middle of the screen.
because one message would "cap" the other to be seen in the middle of the screen.

it works but as
roriscrave
mentioned it just appear in server log instead of the screen, I also tried to change it to "doPlayerSetSpecialDescription" but it says player not found.
 
i think u can use "doPlayerSetSpecialDescription", because if you use, doPlayerSendTextMessage (cid, MESSAGE_INFO_DESCR) ... will only appear the message in the server log, not in the middle of the screen.
because one message would "cap" the other to be seen in the middle of the screen.
Summons are temporary things they usually disappear either when the player dies or the player moves out of range of the summon. Settting a special description is rather pointless since these entities do not exist if the player does not.

Since you have the perfect setup you can do what you wish from here, replace this line of code with whatever the intended outcome is.
Lua:
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Summoned by " .. getCreatureName(master) ..".")
 
Summons are temporary things they usually disappear either when the player dies or the player moves out of range of the summon. Settting a special description is rather pointless since these entities do not exist if the player does not.

Since you have the perfect setup you can do what you wish from here, replace this line of code with whatever the intended outcome is.
Lua:
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Summoned by " .. getCreatureName(master) ..".")
35326
That's the difference between both, in PVP/quest server logs will be crowded so I think it will be too hard for players to look on it. is it possible to make it shows on screen like the mwall you helped me with?
 

Attachments

View attachment 35326
That's the difference between both, in PVP/quest server logs will be crowded so I think it will be too hard for players to look on it. is it possible to make it shows on screen like the mwall you helped me with?
Yes it's possible but I've done most of the hard work now it's your turn ;) I want you to try after all it is your server and a little change like this is perfect for you to get some experience in scripting :)
 
Yes it's possible but I've done most of the hard work now it's your turn ;) I want you to try after all it is your server and a little change like this is perfect for you to get some experience in scripting :)
I have tried too many things, but I am not getting any errors on console so I can't know what exactly I am doing wrong, Last thing I tried is
Lua:
function onLook(cid, thing, position, lookDistance)
    if isCreature(thing.uid) then
        local master = getCreatureMaster(thing.uid)
        -- might be redundant to ask if the master is a creature
        if master and isCreature(master) and isPlayer(thing.uid) then
        local desc = string.sub(getPlayerNameDescription(cid),1,-2)
           doPlayerSetSpecialDescription(cid, "..desc..", "Summoned by " .. getCreatureName(master) ..".")
        end
    end
    return true
end

Edit ---
I tried other functions, it always say player not found
I tried
getThingPosition
getCreaturePosition
getPlayerPosition
but still failing I think I don't add them to script correctly
 
Last edited:
I have tried too many things, but I am not getting any errors on console so I can't know what exactly I am doing wrong, Last thing I tried is
Lua:
function onLook(cid, thing, position, lookDistance)
    if isCreature(thing.uid) then
        local master = getCreatureMaster(thing.uid)
        -- might be redundant to ask if the master is a creature
        if master and isCreature(master) and isPlayer(thing.uid) then
        local desc = string.sub(getPlayerNameDescription(cid),1,-2)
           doPlayerSetSpecialDescription(cid, "..desc..", "Summoned by " .. getCreatureName(master) ..".")
        end
    end
    return true
end

Edit ---
I tried other functions, it always say player not found
I tried
getThingPosition
getCreaturePosition
getPlayerPosition
but still failing I think I don't add them to script correctly
You asked for a script and I wrote it for you. But I don't want to help you anymore with it. I want you to start thinking like a scripter. I want you to study this simple script and then think about the logic of the script & its execution.

Now if you don't understand the execution of the script then might I suggest that you find a tutorial on lua and start reading that or hit youtube and watch some videos on the subject. This is an important time for you to start learning on your own the language which is more important than the script itself. With the new found knowledge you can write your own scripts & when you get stuck or aren't sure how to go about accomplishing something within your code then you can post your code in the support boards and people will help you fix it so it works but you won't learn anything from copying and pasting.

tldr: you need to learn lua so you can write your own scripts.
 
You asked for a script and I wrote it for you. But I don't want to help you anymore with it. I want you to start thinking like a scripter. I want you to study this simple script and then think about the logic of the script & its execution.

Now if you don't understand the execution of the script then might I suggest that you find a tutorial on lua and start reading that or hit youtube and watch some videos on the subject. This is an important time for you to start learning on your own the language which is more important than the script itself. With the new found knowledge you can write your own scripts & when you get stuck or aren't sure how to go about accomplishing something within your code then you can post your code in the support boards and people will help you fix it so it works but you won't learn anything from copying and pasting.

tldr: you need to learn lua so you can write your own scripts.
k I will just try to learn on this one, and fix it by myself no matter how long it will take (I am already trying since you posted it), and I will follow tutorials to learn lua.
Thanks for your help/time.
 
Back
Top