C++ TFS 0.4 rev3777 8.60 "Summons"

Mustafa1337

Î Àm ŁĕğẹňĎ
Joined
Mar 4, 2017
Messages
89
Reaction score
18
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)
 

Steve Albert

Banned User
Joined
Dec 9, 2018
Messages
267
Reaction score
100
This isn't a source edit its a script.
Lua:
-- this would be a creaturescript
function onLook(cid, thing, position, lookDistance)
    return true
end
 
OP
Mustafa1337

Mustafa1337

Î Àm ŁĕğẹňĎ
Joined
Mar 4, 2017
Messages
89
Reaction score
18
Location
Egypt
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
 

Steve Albert

Banned User
Joined
Dec 9, 2018
Messages
267
Reaction score
100
Your on the right track but you don't just pass thing you have to pass it as thing.uid

The rest of that script also needs to be changed
 

Steve Albert

Banned User
Joined
Dec 9, 2018
Messages
267
Reaction score
100
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")
 

roriscrave

Intermediate OT User
Joined
Dec 7, 2011
Messages
357
Reaction score
29
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.
 
OP
Mustafa1337

Mustafa1337

Î Àm ŁĕğẹňĎ
Joined
Mar 4, 2017
Messages
89
Reaction score
18
Location
Egypt
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.
 

Steve Albert

Banned User
Joined
Dec 9, 2018
Messages
267
Reaction score
100
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) ..".")
 
OP
Mustafa1337

Mustafa1337

Î Àm ŁĕğẹňĎ
Joined
Mar 4, 2017
Messages
89
Reaction score
18
Location
Egypt
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

Steve Albert

Banned User
Joined
Dec 9, 2018
Messages
267
Reaction score
100
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 :)
 
OP
Mustafa1337

Mustafa1337

Î Àm ŁĕğẹňĎ
Joined
Mar 4, 2017
Messages
89
Reaction score
18
Location
Egypt
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:

Steve Albert

Banned User
Joined
Dec 9, 2018
Messages
267
Reaction score
100
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.
 
OP
Mustafa1337

Mustafa1337

Î Àm ŁĕğẹňĎ
Joined
Mar 4, 2017
Messages
89
Reaction score
18
Location
Egypt
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.
 
Top