REQUEST: register_on_player_join & register_on_player_quit

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

REQUEST: register_on_player_join & register_on_player_quit

by randomproof » Tue Mar 20, 2012 20:07

These would be call backs to LUA for when a player joins and quits a server. It could be used to serve MOTD kind of stuff, server logging, etc.

I have no problem doing the coding, but I don't want to waste by time if it won't be merged. So if someone with some authority to merge code says yes, I will make a pull request.
 

User avatar
LolManKuba
Member
 
Posts: 939
Joined: Fri Feb 10, 2012 22:36

by LolManKuba » Wed Mar 21, 2012 20:36

I might not be a LUA coder or a modder ect. but I +2 this idea/
 

User avatar
RabbiBob
Member
 
Posts: 335
Joined: Sat Jan 28, 2012 22:40

by RabbiBob » Wed Mar 21, 2012 21:27

+1

Could this be leveraged at the point of all of the 'joins\joined' messaging that takes place in server.cpp?

Line 2156 in celeron55-minetest-c053092../src/server.cpp

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all

    if(command == TOSERVER_INIT2)
    {
        verbosestream<<"Server: Got TOSERVER_INIT2 from "
                <<peer_id<<std::endl;


        getClient(peer_id)->serialization_version
                = getClient(peer_id)->pending_serialization_version;

        /*
            Send some initialization data
        */

        infostream<<"Server: Sending content to "
                <<getPlayerName(peer_id)<<std::endl;

        // Send item definitions
        SendItemDef(m_con, peer_id, m_itemdef);
       
        // Send node definitions
        SendNodeDef(m_con, peer_id, m_nodedef);
       
        // Send texture announcement
        SendTextureAnnouncement(peer_id);
       
        // Send player info to all players
        //SendPlayerInfos();

.....etc/etc
 

randomproof
Member
 
Posts: 214
Joined: Thu Nov 17, 2011 06:31

by randomproof » Wed Mar 21, 2012 21:37

RabbiBob wrote:+1

Could this be leveraged at the point of all of the 'joins\joined' messaging that takes place in server.cpp?


Yes. I would want to make sure that the new player is all loaded and in the system. That is that his/her player is registered in minetest.object_refs so that a reference to the player can be sent to the LUA callback.
 

kahrl
Member
 
Posts: 236
Joined: Fri Sep 02, 2011 07:51

by kahrl » Thu Mar 22, 2012 02:46

+1, would be useful for my Away mod too.

It might be a bit tricky to make this work in 100% of all cases ("work" meaning that the object reference passed to the callback is not nil, and the game doesn't crash) because of the way ServerRemotePlayer is derived from Player. (The system also has existing bugs for the same reason, in particular the !m_is_in_environment server crash when somebody reconnects too fast.)

I have written a PlayerSAO class some time ago. Itreplaces ServerRemotePlayer but is not a subclass of Player, that way there can be multiple PlayerSAOs in the environment for any player and those bugs are fixed.

I'll probably add those callbacks to the playersao branch.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Thu Mar 22, 2012 19:21

+1
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
LorenzoVulcan
Member
 
Posts: 437
Joined: Mon Mar 12, 2012 06:46

by LorenzoVulcan » Thu Mar 22, 2012 19:32

Isn't there "register_new_player" ?
Developer of the BlockForge 2# Project!
Official thread: http://minetest.net/forum/viewtopic.php?pid=54290#p54290
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Thu Mar 22, 2012 19:34

LorenzoVulcan wrote:Isn't there "register_new_player" ?

Yep, but thats called if a new player joins
new = never on the server before
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
LorenzoVulcan
Member
 
Posts: 437
Joined: Mon Mar 12, 2012 06:46

by LorenzoVulcan » Thu Mar 22, 2012 19:36

sfan5 wrote:
LorenzoVulcan wrote:Isn't there "register_new_player" ?

Yep, but thats called if a new player joins
new = never on the server before

Uh,Ok.
So there isn't any function like it?
Developer of the BlockForge 2# Project!
Official thread: http://minetest.net/forum/viewtopic.php?pid=54290#p54290
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Thu Mar 22, 2012 19:36

Yep!
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
LorenzoVulcan
Member
 
Posts: 437
Joined: Mon Mar 12, 2012 06:46

by LorenzoVulcan » Thu Mar 22, 2012 19:38

sfan5 wrote:Yep!

Uh,Ok thanks.
So why the "Give Initial Stuff" doesn't give everytime a player re-log on the server those stuff?
Developer of the BlockForge 2# Project!
Official thread: http://minetest.net/forum/viewtopic.php?pid=54290#p54290
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Thu Mar 22, 2012 20:25

LorenzoVulcan wrote:
sfan5 wrote:Yep!

Uh,Ok thanks.
So why the "Give Initial Stuff" doesn't give everytime a player re-log on the server those stuff?

Because the Server knows, that you already have been on the Server (Inventory File, auth.txt Entry)
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 


Return to Minetest Engine

Who is online

Users browsing this forum: No registered users and 4 guests

cron