AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plugin autokick players with the nick "Player" (https://forums.alliedmods.net/showthread.php?t=164492)

sysgame 08-12-2011 09:53

Plugin autokick players with the nick "Player"
 
Hi all,

I try to create a plugin that will automatically kick players with the nickname "player" or "Player" but I have a little problem with the script ... Actually I started with programming Amx ..

Can someone help me?

Here is the script :

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Player Auto kick"
#define VERSION "1.0"
#define AUTHOR "SysCorp"

new reason;

reason="Merci de changer de pseudo / Please change nickname";

public 
plugin_init()
{
    
register_concmd("amx_kick""cmdKick"ADMIN_KICK"<name or #userid> [reason]")
    
}

public 
auto_kick(id) {
    
    new 
name[32];
    
get_user_name(idname31)
    
    if(
name == "player")
        {
            
log_amx("Kick: ^"%s<%d><%s><>^" kick ^"%s<%d><%s><>^" (reason ^"%s^")"namereason)
            
server_cmd("kick #%d %s"namereason)
        }
    



xPaw 08-12-2011 11:03

Re: Plugin autokick players with the nick "Player"
 
Code:
#include < amxmodx > public client_putinserver( id ) {     new szName[ 8 ];     get_user_name( id, szName, 7 );         if( equali( szName, "player" ) )     {         emessage_begin( MSG_ONE, SVC_DISCONNECT, _, id );         ewrite_string( "Please change your name." );         emessage_end( );     } }

Desikac 08-12-2011 11:32

Re: Plugin autokick players with the nick "Player"
 
Name is a string, not an integer.

sysgame 08-12-2011 12:07

Re: Plugin autokick players with the nick "Player"
 
oki tyvm for your help

sysgame 08-12-2011 13:09

Re: Plugin autokick players with the nick "Player"
 
Now I have a file that contains all of the nickname and I want to make a loop of this type

This is correct?

PHP Code:

new g_array_created;
// Arrays
new Array:g_spam;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// Create the Array
    
g_spam ArrayCreate(321)
    
g_array_created true
    register_dictionary
("nickname.txt")
}

public 
client_connect(id)
{    
    new 
szName];
    
get_user_nameidszName);
   
   for(new 
0ArraySize(g_spam); i++)
        {
    
ArrayGetString(g_spamibuffer31);
    if( 
equaliszNameg_spam[i] ) )
    {
         
emessage_beginMSG_ONESVC_DISCONNECT_id );
         
ewrite_string"Please change your name." );
         
emessage_end( );
    }
        }
        



Hunter-Digital 08-12-2011 14:51

Re: Plugin autokick players with the nick "Player"
 
You don't understand what each function does it seems... and you didn't apply any logic either, where is the array actually assigned to the contents of the file ?

http://www.amxmodx.org/funcwiki.php < start here, all natives and stocks available are listed and briefly explained there... start by inputing register_dictionary to see what it actually does (which is nothing related to your needs).

For file reading functions there are tutorials you know, it wouldn't hurt to read them instead of blindly trying out stuff :P


All times are GMT -4. The time now is 03:22.

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