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

[Requesting help] Default name kicker


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Comrade Iron Man
Junior Member
Join Date: Jun 2008
Old 06-30-2008 , 11:30   [Requesting help] Default name kicker
Reply With Quote #1

Hi, I'm new here, and I've been having some trouble making a plug-in that checks a client's name when he joins then kicks him if he has the default name.

Code:
#include <sourcemod>

public Plugin:myinfo = 
{
    name = "Default Name Kicker",
    author = "Plague",
    description = "Kicks players with the default name",
    version = "1.0",
    url = "http://www.sourcemod.net/"
}
public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
{
    decl String:name[64]
    GetClientName(client, name, sizeof(name))
    if (StrEqual(name, "Tony Swan"))
    {
        if ( IsClientConnected(client) && !IsFakeClient(client) )
        {
            KickClient(client, "Change your name.")
            return true
        }
        return true
    }
    
    return Plugin_Stop
}
Finished, current version.

Last edited by Comrade Iron Man; 07-20-2008 at 22:47. Reason: Fixed
Comrade Iron Man is offline
raydan
Senior Member
Join Date: Aug 2006
Old 06-30-2008 , 12:04   Re: [Requesting help] Default name kicker
Reply With Quote #2

you miss a stupid "}"


Code:
 
public Plugin:myinfo = 
{
    name = "Default Name Kicker",
    author = "Myself",
    description = "Kicks players with the default name",
    version = "1.0",
    url = http://www.sourcemod.net/
}
raydan is offline
Comrade Iron Man
Junior Member
Join Date: Jun 2008
Old 07-01-2008 , 12:07   Re: [Requesting help] Default name kicker
Reply With Quote #3

I have not yet required the proper level of inebriation to code program properly it seems.
Comrade Iron Man is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 07-01-2008 , 13:55   Re: [Requesting help] Default name kicker
Reply With Quote #4

PHP Code:
public Action:OnClientConnect(client)
{
    new 
String:DefaultName[] = "HAHA"//Whatever you want.
    
new String:name[64];
    
    
GetClientName(clientnamesizeof(name));
    if (
name == DefaultName)
    {
        
KickClient(client,"Change your name.");
    }


If this codes crashes, tell me.
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
Kigen
BANNED
Join Date: Feb 2008
Old 07-01-2008 , 22:24   Re: [Requesting help] Default name kicker
Reply With Quote #5

Code:
#include <sourcemod>

public Plugin:myinfo = 
{
    name = "Default Name Kicker",
    author = "Myself",
    description = "Kicks players with the default name",
    version = "1.0",
    url = "http://www.sourcemod.net/"
}

public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
{
    decl String:name[64]
    GetClientName(client, name, sizeof(name))
    if (StrEqual(name, "unnamed"))
    {
        CreateTimer(0.1, KickThem, client)
        return true
    }
    return true
}

public Action:KickThem(Handle:timer, any:client)
{
    if ( IsClientConnected(client) && !IsFakeClient(client) )
        KickClient(client, "Change your name.")
    return Plugin_Stop
}
Kigen is offline
chundo
Senior Member
Join Date: May 2008
Old 07-02-2008 , 14:14   Re: [Requesting help] Default name kicker
Reply With Quote #6

Nican's won't work because == is not a string comparison operator.

Kigen, you can simplify yours by just returning "false" from OnClientConnect and setting the rejectmsg[] parameter, rather than a timed Kick.

Code:
#include <sourcemod>

public Plugin:myinfo = 
{
    name = "Default Name Kicker",
    author = "Myself",
    description = "Kicks players with the default name",
    version = "1.0",
    url = "http://www.sourcemod.net/"
}

public bool:OnClientConnect(client, String:rejectmsg[], maxlen)
{
    decl String:name[64]
    GetClientName(client, name, sizeof(name))
    if (StrEqual(name, "unnamed"))
    {
        strcopy(rejectmsg, maxlen, "Change your name")
        return false
    }
    return true
}
__________________

Last edited by chundo; 07-02-2008 at 14:17.
chundo is offline
Comrade Iron Man
Junior Member
Join Date: Jun 2008
Old 07-02-2008 , 16:22   Re: [Requesting help] Default name kicker
Reply With Quote #7

Thanks alot. One last question for now: How do you compare mere parts of the name string? (i.e. finding offensive names or specific clan tags)

Would it be StrEqual(name, "offensive word", "other offensive word", "you get the point") ?

Also, Chundo, your code looks like it has alot of argument mismatches. But, then again, maybe I'm just an idiot.

Last edited by Comrade Iron Man; 07-02-2008 at 16:31.
Comrade Iron Man is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-02-2008 , 21:19   Re: [Requesting help] Default name kicker
Reply With Quote #8

If you want to replace words, you can do something like this:
PHP Code:
new String:wordList[2][32] = {"poop""crap""fart"};
for (new 
0<= 2i++)
{
    
ReplaceString(textsizeof(text), wordList[i], "lol");

That would replace poop, crap, and fart with lol.

If you just want to see if the text contains a word, just use the same method but with StrContains.

Last edited by bl4nk; 07-02-2008 at 21:21.
bl4nk 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 15:02.


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