Raised This Month: $32 Target: $400
 8% 

How to make a custom plugin like !donate!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheMinecraftPoke
Junior Member
Join Date: Jul 2016
Old 07-22-2016 , 13:13   How to make a custom plugin like !donate!
Reply With Quote #1

I would like to know how you make a custom plugin like !donate which takes you to a page. I am a new server host so I don't know much about Source Mod.

Last edited by TheMinecraftPoke; 07-22-2016 at 13:13.
TheMinecraftPoke is offline
TheMinecraftPoke
Junior Member
Join Date: Jul 2016
Old 07-22-2016 , 13:52   Re: How to make a custom plugin like !donate!
Reply With Quote #2

Anyone?
TheMinecraftPoke is offline
sneaK
SourceMod Moderator
Join Date: Feb 2015
Location: USA
Old 07-22-2016 , 14:02   Re: How to make a custom plugin like !donate!
Reply With Quote #3

Holy crap, relax, you just posted just over a half hour ago, answers aren't given immediately. Have you tried searching?

Please be aware of the forum rules

Quote:
Do not "bump" your threads. Bumping is posting simply to make the thread higher in the forum sort order.
To help us answer your question, you also need to give us more information, more specifically what game you're trying to run, as far as I'm concerned you're working with Call of Duty.
sneaK is offline
TheMinecraftPoke
Junior Member
Join Date: Jul 2016
Old 07-22-2016 , 14:11   Re: How to make a custom plugin like !donate!
Reply With Quote #4

The game I am working with is TF2 and I have searched
TheMinecraftPoke is offline
xfusionlockx
AlliedModders Donor
Join Date: Aug 2014
Old 07-22-2016 , 14:23   Re: How to make a custom plugin like !donate!
Reply With Quote #5

Code:
#include <sourcemod>

#pragma newdecls required

#define VERSION "1.0.0"

public Plugin myinfo = 
{
    name = "!donate Page Opener",
    author = "FusionLock",
    description = "Opens a page when '!donate' is said in chat.",
    version = VERSION,
    url = "http://steamcommunity.com/profiles/76561198054654475"
}

public void OnPluginStart()
{
    CreateConVar("donateurl_version", VERSION, "The version of the plugin the server is running", FCVAR_NOTIFY);

    AddCommandListener(Command_Say, "say");
    AddCommandListener(Command_Say, "say_team");
}

//Hooks chat so we can detect if someone uses the !donate command
public Action Command_Say(int iClient, char[] sCommand, int iArgs)
{
    char sCmd[64];

    GetCmdArg(1, sCmd, sizeof(sCmd));

    StripQuotes(sCmd);

    if(StrContains(sCmd, "!donate") != -1 || StrContains(sCmd, "/donate") != -1)
    {
        ShowMOTDPanel(iClient, "Donate", "http://google.com/", MOTDPANEL_TYPE_URL);
        return Plugin_Handled;
    }

    return Plugin_Continue;
}
That should work for you. Just replace the google url with your donate url. Always have http:// or https:// in front or it wont open.

Last edited by xfusionlockx; 07-22-2016 at 14:24.
xfusionlockx is offline
Aymeric VII
BANNED
Join Date: Jun 2016
Location: Hiding under my sheets
Old 07-22-2016 , 14:41   Re: How to make a custom plugin like !donate!
Reply With Quote #6

Or just install this plugin and add your urls accordingly through webshortcuts.txt? https://forums.alliedmods.net/showthread.php?p=2166996

Last edited by Aymeric VII; 07-22-2016 at 14:42.
Aymeric VII is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-22-2016 , 18:00   Re: How to make a custom plugin like !donate!
Reply With Quote #7

Quote:
Originally Posted by xfusionlockx View Post
Code:
#include <sourcemod>

#pragma newdecls required

#define VERSION "1.0.0"

public Plugin myinfo = 
{
    name = "!donate Page Opener",
    author = "FusionLock",
    description = "Opens a page when '!donate' is said in chat.",
    version = VERSION,
    url = "http://steamcommunity.com/profiles/76561198054654475"
}

public void OnPluginStart()
{
    CreateConVar("donateurl_version", VERSION, "The version of the plugin the server is running", FCVAR_NOTIFY);

    AddCommandListener(Command_Say, "say");
    AddCommandListener(Command_Say, "say_team");
}

//Hooks chat so we can detect if someone uses the !donate command
public Action Command_Say(int iClient, char[] sCommand, int iArgs)
{
    char sCmd[64];

    GetCmdArg(1, sCmd, sizeof(sCmd));

    StripQuotes(sCmd);

    if(StrContains(sCmd, "!donate") != -1 || StrContains(sCmd, "/donate") != -1)
    {
        ShowMOTDPanel(iClient, "Donate", "http://google.com/", MOTDPANEL_TYPE_URL);
        return Plugin_Handled;
    }

    return Plugin_Continue;
}
That should work for you. Just replace the google url with your donate url. Always have http:// or https:// in front or it wont open.
Side note: Hooking say or say_text is bad coding style.

Using RegConsoleCmd on "donate" will create hooks for /donate and !donate for you.

If you *really* want to hook arbitrary text in chat, use the OnClientSayCommand callback.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 07-22-2016 at 18:01.
Powerlord is offline
Reply


Thread Tools
Display Modes

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 02:13.


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