[ANY] Welcome [Final]

Welcome v2.0

Introduction

Welcomes users to your server with; now supports Colors, and hooks!



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/)



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];

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 %N, 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));

        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: sp


Get Plugin or
Get Source (Welcome.sp - 1.1 KB)


File Type: smx


Welcome.smx (5.3 KB)








Orignal From: [ANY] Welcome [Final]

No comments

Not a single link is allowed to submit in comment :o