Raised This Month: $51 Target: $400
 12% 

[ANY] Welcome v2.1


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Hunter S. Thompson
Senior Member
Join Date: Jun 2012
Plugin ID:
3039
Plugin Version:
v2.0
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Welcomes users to your server.
    Old 06-23-2012 , 13:26   [ANY] Welcome v2.1
    Reply With Quote #1

    Welcome v2.1
    Introduction
    Welcomes users to your server with a custom message!

    ConVars
    sm_Join_Message - Sets the message to display when users join the server.


    Requirements

    SourceMod v1.4.3
    Colors.inc (Needed to compile)

    Installation

    Copy the .SMX file into your plugins directory (./addons/sourcemod/plugins/)

    What's new?
    • Now supports Colors
    • Now uses Hooks
    • Now allows for {name}, {steamid}, and {ip}
    • Taking suggestions!


    Source
    I'm providing the source so users can tell me what needs to be fixed/what can be done better.
    Code:
    #pragma semicolon 1
    
    #include <sourcemod>
    #include <colors>
    
    new Handle:sm_Join_Message = INVALID_HANDLE;
    new String:Message[128];
    new String:Name[128];
    new String:SteamID[128];
    new String:IP[128];
    public Plugin:myinfo =
    {
        name = "Welcome",
        author = "Hunter S. Thompson",
        description = "My First Plugin - Displays a welcome message when the user joins.",
        version = "1.0.0.0",
        url = "http://forums.alliedmods.net/showthread.php?t=187975"
    };
    
    public OnPluginStart()
    {
        sm_Join_Message = CreateConVar("sm_join_message", "Welcome {name}[{steamid}], to Conflagration Deathrun!", "Default Join Message", FCVAR_NOTIFY);
        AutoExecConfig(true, "onJoin");
        HookEvent("player_activate", Player_Activated, EventHookMode_Post);
    }
    
    public Action:Player_Activated(Handle:event, const String:name[], bool:dontBroadcast)
    {
        new client = GetClientOfUserId(GetEventInt(event, "userid"));
        CreateTimer(4.0, Timer_Welcome, client, TIMER_FLAG_NO_MAPCHANGE);
    }
    
    public Action:Timer_Welcome(Handle:timer, any:client)
    {
        if (IsClientConnected(client) && IsClientInGame(client))
        {
            GetConVarString(sm_Join_Message, Message, sizeof(Message));
            GetClientName(client, Name, sizeof(Name));
            GetClientAuthString(client, SteamID, sizeof(SteamID));
            GetClientIP(client, IP, sizeof(IP));
            ReplaceString(Message, sizeof(Message), "{name}", Name, false);
            ReplaceString(Message, sizeof(Message), "{steamid}", SteamID, false);
            ReplaceString(Message, sizeof(Message), "{ip}", IP, false);
            CPrintToChat(client, Message, client);
        }
    }
    Credits
    • TheTwistedPanda
    • PowerLord
    • Mitchell
    • Minimoney1


    This is my first plugin, so please feel free to scrutinize, and tell me what needs to be done/what can be done better.
    Attached Files
    File Type: smx Welcome.smx (5.6 KB, 1197 views)
    File Type: sp Get Plugin or Get Source (Welcome.sp - 901 views - 1.5 KB)

    Last edited by Hunter S. Thompson; 06-24-2012 at 18:48.
    Hunter S. Thompson is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 06-23-2012 , 13:42   Re: [ANY] Welcome [Final]
    Reply With Quote #2

    WHy'd you start a new thread?
    Mitchell is offline
    ReFlexPoison
    ☠☠☠
    Join Date: Jul 2011
    Location: ☠☠☠
    Old 06-23-2012 , 15:31   Re: [ANY] Welcome [Final]
    Reply With Quote #3

    - I don't see the necessity of using the colors include, especially when you aren't using and colors. (Unless it is in the CVar)
    - Don't create a new thread every update.
    - There is/was already a welcome message plugin. https://forums.alliedmods.net/showthread.php?p=880791 So, I do suggest adding more optimization to make it less similar if you catch my drift ;)

    Last edited by ReFlexPoison; 06-23-2012 at 15:32.
    ReFlexPoison is offline
    Hunter S. Thompson
    Senior Member
    Join Date: Jun 2012
    Old 06-24-2012 , 04:48   Re: [ANY] Welcome [Final]
    Reply With Quote #4

    Quote:
    Originally Posted by Mitchell View Post
    WHy'd you start a new thread?
    I was no longer allowed to edit the main thread, so I was forced, in order to update, create a new thread.

    Quote:
    Originally Posted by ReFlexPoison View Post
    - I don't see the necessity of using the colors include, especially when you aren't using and colors. (Unless it is in the CVar)
    - Don't create a new thread every update.
    - There is/was already a welcome message plugin. https://forums.alliedmods.net/showthread.php?p=880791 So, I do suggest adding more optimization to make it less similar if you catch my drift ;)
    - What do you mean, not using colors? It's using the colors include file right here: CPrintToChat(client, Message, client);
    - Read above.
    - I didn't see that, actually. Really this is just my introduction into PAWN, so being my first, and albeit simplest plugin, I thought I'd just release it to the community in the hopes that someone else in the position I was in when I first started writing this, can use it to learn from, instead of having an overly-complicated Welcome Message plugin to learn from. There's really no need a plugin should Welcome user, then support 8 other lines, when there's other plugins such as Advertisements, and Advanced Advertisements.

    Last edited by Hunter S. Thompson; 06-24-2012 at 05:18.
    Hunter S. Thompson is offline
    Leonardo
    Veteran Member
    Join Date: Feb 2010
    Location: 90's
    Old 06-24-2012 , 05:30   Re: [ANY] Welcome [Final]
    Reply With Quote #5

    Quote:
    Originally Posted by Hunter S. Thompson View Post
    I was no longer allowed to edit the main thread, so
    what!

    also
    making plugin to see wjhat you can do in SourcePawn - it's okay.
    but it's not required to be posted here~

    Last edited by Leonardo; 06-24-2012 at 05:32.
    Leonardo is offline
    Hunter S. Thompson
    Senior Member
    Join Date: Jun 2012
    Old 06-24-2012 , 06:18   Re: [ANY] Welcome [Final]
    Reply With Quote #6

    Quote:
    Originally Posted by Leonardo View Post
    what!

    also
    making plugin to see wjhat you can do in SourcePawn - it's okay.
    but it's not required to be posted here~
    I never said it was required, I said:
    Quote:
    Really this is just my introduction into PAWN, so being my first, and albeit simplest plugin, I thought I'd just release it to the community in the hopes that someone else in the position I was in when I first started writing this, can use it to learn from, instead of having an overly-complicated Welcome Message plugin to learn from.
    The only reason(s) I posted it was for people new to PAWN to learn from, and for people to give me feed-back about how it can be improved, which is what Mitchell, Mini, Power, and TheTwistedPanda, did and I'm grateful for it, considering it helped improve the code.

    Also, I think what happened was that I opened the old thread in a new tab, and since I don't save my passwords (As a programmer, I've seen first hand, how dangerous 1 simple 10kb executable can be), and it seems that this site doesn't save cookies, so it may have just logged me out, and I didn't notice.

    Last edited by Hunter S. Thompson; 06-24-2012 at 06:19.
    Hunter S. Thompson is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 06-24-2012 , 11:00   Re: [ANY] Welcome [Final]
    Reply With Quote #7

    Quote:
    Originally Posted by Leonardo View Post
    Oh god when i heard that i laughed.


    Anyways! Nice job i will recommend some of my friends trying to learn pawn to this plugin, so they too can learn off of your coding.

    Last edited by Mitchell; 06-24-2012 at 11:00.
    Mitchell is offline
    minimoney1
    SourceMod Donor
    Join Date: Dec 2010
    Old 06-24-2012 , 11:20   Re: [ANY] Welcome [Final]
    Reply With Quote #8

    This is a great plugin, but in order for it to be "better than the others", you're going to need to add more features, and by adding more features you will learn more SourcePawn so it's all for the best. My recommendations would be to not use a convar for the message but to use either a custom config file or a translation file. Also, hardcoding something like %N into a plugin is just not great imo. If I were you, I would add specific tags such as {name}, {steamid}, {ip}, etc. which get replaced by the specific value. Check the documentation of ReplaceString to exactly get how to do that. Other than that, this is a great plugin, especially for a beginner to code, so don't listen to others' negativity and keep on learning SourcePawn!
    minimoney1 is offline
    Hunter S. Thompson
    Senior Member
    Join Date: Jun 2012
    Old 06-24-2012 , 18:31   Re: [ANY] Welcome [Final]
    Reply With Quote #9

    Quote:
    Originally Posted by minimoney1 View Post
    This is a great plugin, but in order for it to be "better than the others", you're going to need to add more features, and by adding more features you will learn more SourcePawn so it's all for the best. My recommendations would be to not use a convar for the message but to use either a custom config file or a translation file. Also, hardcoding something like %N into a plugin is just not great imo. If I were you, I would add specific tags such as {name}, {steamid}, {ip}, etc. which get replaced by the specific value. Check the documentation of ReplaceString to exactly get how to do that. Other than that, this is a great plugin, especially for a beginner to code, so don't listen to others' negativity and keep on learning SourcePawn!
    Easy.

    Got anything else I should try?

    Code:
    #pragma semicolon 1
    
    #include <sourcemod>
    #include <colors>
    
    new Handle:sm_Join_Message = INVALID_HANDLE;
    new String:Message[128];
    new String:Name[128];
    new String:SteamID[128];
    new String:IP[128];
    public Plugin:myinfo =
    {
        name = "Welcome",
        author = "Hunter S. Thompson",
        description = "My First Plugin - Displays a welcome message when the user joins.",
        version = "1.0.0.0",
        url = "http://forums.alliedmods.net/showthread.php?t=187975"
    };
    
    public OnPluginStart()
    {
        sm_Join_Message = CreateConVar("sm_join_message", "Welcome {name}[{steamid}], to Conflagration Deathrun!", "Default Join Message", FCVAR_NOTIFY);
        AutoExecConfig(true, "onJoin");
        HookEvent("player_activate", Player_Activated, EventHookMode_Post);
    }
    
    public Action:Player_Activated(Handle:event, const String:name[], bool:dontBroadcast)
    {
        new client = GetClientOfUserId(GetEventInt(event, "userid"));
        CreateTimer(4.0, Timer_Welcome, client, TIMER_FLAG_NO_MAPCHANGE);
    }
    
    public Action:Timer_Welcome(Handle:timer, any:client)
    {
        if (IsClientConnected(client) && IsClientInGame(client))
        {
            GetConVarString(sm_Join_Message, Message, sizeof(Message));
            GetClientName(client, Name, sizeof(Name));
            GetClientAuthString(client, SteamID, sizeof(SteamID));
            GetClientIP(client, IP, sizeof(IP));
            ReplaceString(Message, sizeof(Message), "{name}", Name, false);
            ReplaceString(Message, sizeof(Message), "{steamid}", SteamID, false);
            ReplaceString(Message, sizeof(Message), "{ip}", IP, false);
            CPrintToChat(client, Message, client);
        }
    }
    Main file updated.

    Edit: I forgot that you suggested I use a config file, could you point me to the direction on how to load one, and use one?

    Last edited by Hunter S. Thompson; 06-24-2012 at 18:36.
    Hunter S. Thompson is offline
    Bibby
    Member
    Join Date: Sep 2012
    Location: Sweden
    Old 11-27-2012 , 15:50   Re: [ANY] Welcome v2.1
    Reply With Quote #10

    -
    -
    Can- you make this so the message comes after 25 sec after you have connect to the server ? think that would be much better !´
    -
    -

    Last edited by Bibby; 11-27-2012 at 15:51.
    Bibby is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 12:23.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode