Is there a hook for a player's first connect?

samvds

Plugin Developer
Plugin Developer
Trusted Member
Jan 10, 2018
68
100
18
26
The Netherlands
I want to develop a plugin that sends the player a message at first connect, therefore I need a hook that refers to the player's first connection made to the server. Like "On_PlayerConnected" but then "On_PlayerFirstConnected" or something like that. Can't seem to find it in the documentation, can anybody help?
 

ice cold

Active Member
Trusted Member
Member
Oct 24, 2016
606
880
43
Canada

samvds

Plugin Developer
Plugin Developer
Trusted Member
Jan 10, 2018
68
100
18
26
The Netherlands
Your Welcome
Tried to just use the script, didn't work:

Screenshot_1.png

Made a few adjustments, hoped it would work then:


Python:
__name__ = 'FirstConnectMSG'
__author__ = 'ice cold'
__version__ = '1.1'

import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite
import re

cyan = "[color#00ffff]"
green = "[color#00ff00]"
sysname = "Server

class FirstJoin:
    def On_PluginInit(self):
        self.Database()
    def Database(self):
        if not Plugin.IniExists("Database"):
            Plugin.CreateIni("Database")
            ini = Plugin.GetIni("Database")
            ini.AddSetting("Joined", "123124151232311", "1")
            ini.Save()
        return Plugin.GetIni("Database")
    def On_PlayerConnected(self, Player):
        db = self.Database()
        if db.GetSetting("Joined", Player.SteamID) is None:
            db.AddSetting("Joined", Player.SteamID, "1")
            db.Save()
            Server.BroadcastFrom(sysname, green + "☢ " + Player.Name + " joined the server for the first time!")
            Player.MessageFrom(sysname, cyan + "☢ Welcome to a server! Show us what you're made of!")
That gave me this error:

Screenshot_2.png


Please help, key to making my server look good!

P.S. I appreciate the work your putting into my mistakes, but try to be constructive!

Kind regards,
Sam
 

salva

Friendly self-taught developer
Administrator
Jan 31, 2016
577
613
63
Tried to just use the script, didn't work:

View attachment 2376

Made a few adjustments, hoped it would work then:


Python:
__name__ = 'FirstConnectMSG'
__author__ = 'ice cold'
__version__ = '1.1'

import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite
import re

cyan = "[color#00ffff]"
green = "[color#00ff00]"
sysname = "Server

class FirstJoin:
    def On_PluginInit(self):
        self.Database()
    def Database(self):
        if not Plugin.IniExists("Database"):
            Plugin.CreateIni("Database")
            ini = Plugin.GetIni("Database")
            ini.AddSetting("Joined", "123124151232311", "1")
            ini.Save()
        return Plugin.GetIni("Database")
    def On_PlayerConnected(self, Player):
        db = self.Database()
        if db.GetSetting("Joined", Player.SteamID) is None:
            db.AddSetting("Joined", Player.SteamID, "1")
            db.Save()
            Server.BroadcastFrom(sysname, green + "☢ " + Player.Name + " joined the server for the first time!")
            Player.MessageFrom(sysname, cyan + "☢ Welcome to a server! Show us what you're made of!")
That gave me this error:

View attachment 2377


Please help, key to making my server look good!

P.S. I appreciate the work your putting into my mistakes, but try to be constructive!

Kind regards,
Sam
@ice cold
 

ice cold

Active Member
Trusted Member
Member
Oct 24, 2016
606
880
43
Canada
Tried to just use the script, didn't work:

View attachment 2376

Made a few adjustments, hoped it would work then:


Python:
__name__ = 'FirstConnectMSG'
__author__ = 'ice cold'
__version__ = '1.1'

import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite
import re

cyan = "[color#00ffff]"
green = "[color#00ff00]"
sysname = "Server

class FirstJoin:
    def On_PluginInit(self):
        self.Database()
    def Database(self):
        if not Plugin.IniExists("Database"):
            Plugin.CreateIni("Database")
            ini = Plugin.GetIni("Database")
            ini.AddSetting("Joined", "123124151232311", "1")
            ini.Save()
        return Plugin.GetIni("Database")
    def On_PlayerConnected(self, Player):
        db = self.Database()
        if db.GetSetting("Joined", Player.SteamID) is None:
            db.AddSetting("Joined", Player.SteamID, "1")
            db.Save()
            Server.BroadcastFrom(sysname, green + "☢ " + Player.Name + " joined the server for the first time!")
            Player.MessageFrom(sysname, cyan + "☢ Welcome to a server! Show us what you're made of!")
That gave me this error:

View attachment 2377


Please help, key to making my server look good!

P.S. I appreciate the work your putting into my mistakes, but try to be constructive!

Kind regards,
Sam
i sended outdated code when i'm home i give good one
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,095
4,815
113
At your house.
github.com
Sounds good! Thanks

Verstuurd vanaf mijn SM-G935F met Tapatalk
Python:
__name__ = 'FirstConnectMSG'
__author__ = 'ice cold'
__version__ = '1.1'

import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite

cyan = "[color#00ffff]"
green = "[color#00ff00]"
sysname = "Server"

class FirstJoin:

    def On_PlayerConnected(self, Player):
        if DataStore.Get("Joined", Player.UID) is None:
            DataStore.Add("Joined", Player.UID, True)
            Server.BroadcastFrom(sysname, green + "☢ " + Player.Name + " joined the server for the first time!")
            Player.MessageFrom(sysname, cyan + "☢ Welcome to a server! Show us what you're made of!")
 

samvds

Plugin Developer
Plugin Developer
Trusted Member
Jan 10, 2018
68
100
18
26
The Netherlands
Python:
__name__ = 'FirstConnectMSG'
__author__ = 'ice cold'
__version__ = '1.1'

import clr
clr.AddReferenceByPartialName("Fougerite")
import Fougerite

cyan = "[color#00ffff]"
green = "[color#00ff00]"
sysname = "Server"

class FirstJoin:

    def On_PlayerConnected(self, Player):
        if DataStore.Get("Joined", Player.UID) is None:
            DataStore.Add("Joined", Player.UID, True)
            Server.BroadcastFrom(sysname, green + "☢ " + Player.Name + " joined the server for the first time!")
            Player.MessageFrom(sysname, cyan + "☢ Welcome to a server! Show us what you're made of!")

http://prntscr.com/i9z8cu

:(