Raised This Month: $ Target: $400
 0% 

Need Some Help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
dRk13
New Member
Join Date: Aug 2008
Location: Bucharest
Old 06-05-2009 , 10:07   Need Some Help
Reply With Quote #1

the ideea is that if a player connects with a name like: server.ro to my server i want to make his name: unnamed and disconnect him and after disconnect him, to print in client console a message asking him to connect after he changes his name... ( and also if the word "server" is part of his name it would react the same...) also i want the plugin to see if the player changes his name in game, search thru the list of restricted names and if is the same as with one of the restricted names turn it back to the old one...

here is what i made until now..
and pelase don`t tell me not to reinvent a plugin... i just want to learn and this i can learn only redoing some plugins...[yeah, i know a lot of plugins that do almost the same thing.. but i want to know what i`m doing wrong... here ]

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Name Restriction"
#define VERSION "0.1"
#define AUTHOR "DarKMaN"
//---------DEFINES------------

//Define max names from file.
#define MAXNAMES 60
new NumberOfNamesFromFile 0
//Rember names from file to compare with players.
new names[MAXNAMES][]
//If user is with name from list, change it to:
#define SETNAME "unnamed"
//---------END OF DEFINES ----


public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
LoadNameRestFile()
    
}

stock LoadNameRestFile()
{
    new 
filepath[64]
    
get_configsdir(filepath63);
    
format(filepath63"%s/namerestriction.ini"filepath);
    if(
file_exists(filepath))
    {
        new 
name[32];
        
        
//Open file
        
new fHandle fopen(filepath"rt");
        
        
//Checks for failure
        
if(!fHandle)
            return 
PLUGIN_HANDLED;
        
//LOOP THRU LINES
        
for(new 0MAXNAMES && !feof(fHandle); a++)
        {
            
//Get line
            
fgets(fHandlename31);
            
            
//Work away comments
            
if(name[0] == ';' || !name[0] || name[0] == ' ' || name[0] == 10
            {
                
//Line is not counted
                
a--;
                continue;
            }
            
copy(names[a], 31name)    
            
NumberOfNamesFromFile++;    
        }
        
    }
    return 
PLUGIN_CONTINUE;

}

public 
client_connects(id)
{
    if(
NumberOfNamesFromFile == )
        return 
PLUGIN_HANDLED
    
else
    {
        new 
playerconnects[32]
        
get_user_info(id"name"playerconnects31)
        for(new 
i=0NumberOfNamesFromFile i++)
            if(
equali(playerconnectsnames[i][]))
                
changeName(id)
            else
            {
            
checkIFnameISpartial(names[i], playerconnectsid)
            }
    }
    return 
PLUGIN_HANDLED
}

public 
client_infochanged(id)
{

    new 
newname[32],oldname[32]
    
get_user_info(id"name"newname,31)
    
get_user_name(idoldname31)
    if(
equali(newname,oldname))
        return 
PLUGIN_HANDLED;
    else
    {
        for(new 
0NumberOfNamesFromFile i++ )
        if(
equali(names[i],newname))
         
changeNameInGame(idoldname)
        else
         
checkIFnameISpartialINGAME(names[i], newnameidoldname)
    }
    return 
PLUGIN_HANDLED
}

stock changeName(id)
{
        
client_cmd(id"name %s"SETNAME)
        
client_cmd(id"echo [DNK BOT] Kicked because:")
        
client_cmd(id"echo [DNK BOT] Numele tau a fost schimbat in ^"%s^". Te rog conecteaza-te dupa ce ti-ai schimbat numele."SETNAME)
        
client_cmd(id"disconnect")
        return 
PLUGIN_HANDLED
}

stock changeNameInGame(idChangeNameTo[])
{
        
client_cmd(id"name %s"ChangeNameTo)
        
client_print(idprint_chat,"[DNK BOT] Nume interzis! Numele tau a fost schimbat in ^"%s^"."ChangeNameTo)
        return 
PLUGIN_HANDLED
}

stock checkIFnameISpartial(Vector1[], Vector2[], id)
{
            new 
pcnum charsmaxVector2 )
            new 
numb charsmaxVector1 )
            new 
OK 0
            
new 0
            
for(new 0pcnumi++)
            {
            if(
equali(Vector2[i], Vector1[k]))
            
k++
            
OK++
            }
            if(
equali(OK,numb))
            
changeName(id)
            return 
PLUGIN_CONTINUE;
}
         
stock checkIFnameISpartialINGAME(Vector1[], Vector2[], idoldname2[])
{
            new 
pcnum charsmaxVector2 )
            new 
numb charsmaxVector1 )
            new 
OK 0
            
new 0
            
for(new 0pcnumi++)
            {
            if(
equali(Vector2[i], Vector1[k])
            
k++
            
OK++
            }
            if(
equali(OK,numb))
            
changeNameInGame(idoldname2)
            return 
PLUGIN_CONTINUE;

dRk13 is offline
 



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


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