AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Name assign (https://forums.alliedmods.net/showthread.php?t=57542)

Alka 07-06-2007 17:23

Name assign
 
Hi.I want to make a plugin that assign to a steam id an registerd name ! Blah blah you are on server type /namereg and in a file write
Code:

STEAM_0:0:123456 ; Alka
and i want when connect on server check for steam id and change player name from that line ;)(assigned name).If you enter with that registerd name and don't have that steam id assigned kick!:wink:

Thanks

stupok 07-06-2007 20:15

Re: Name assign
 
I think this will work, I haven't tested it or tried to compile it:

Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <nvault>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "stupok69"

#define VAULT_NAME "alka_name_steamid"

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR)
       
        register_clcmd("say /namereg", "register_name", _, "registers your name with your STEAMID")
}

public client_putinserver(id)
{
        set_task(1.0, "check_name", id)
}

public client_infochanged(id)
{
        set_task(1.0, "check_name", id)
}

public check_name(id)
{
        new name[32], steamid[32]
       
        get_user_name(id, name, 31)
        get_user_authid(id, steamid, 31)
       
        new vault = nvault_open(VAULT_NAME)
        new timestamp
       
        if(!nvault_lookup(vault, name, steamid, 31, timestamp))
        {
                new read_steamid[32]
               
                if(nvault_get(vault, name, read_steamid, 31))
                {
                        if(!equal(read_steamid, steamid))
                        {
                                server_cmd("amx_kick #%i ^"You must change your name to enter this server!^"", get_user_userid(id))
                        }
                }
                else
                {
                        client_print(id, print_chat, "Say '/namereg name' to register your name with your STEAMID!")
                        set_task(30.0, "check_name", id)
                }
        }
       
        nvault_close(VAULT_NAME)
}

public register_name(id)
{
        new name[32], steamid[32]
       
        get_user_name(id, name, 31)
        get_user_authid(id, steamid, 31)
       
        new vault = nvault_open(VAULT_NAME)
        new timestamp
       
        if(!nvault_lookup(vault, name, steamid, 31, timestamp)
        {
                if(!nvault_get(vault, name))
                {
                        nvault_set(vault, steamid, name)
                        client_print(id, print_chat, "Your name has been registered with you STEAMID successfully.")
                }
                else
                {
                        client_print(id, print_chat, "You may not register with this name, it has already been used.")
                }
        }
        else
        {
                client_print(id, print_chat, "You have already registered your name.")
        }
       
        nvault_close(VAULT_NAME)
}


Alka 07-06-2007 20:31

Re: Name assign
 
I think you'r idea is good but!
1.Is spam my chat with messages : "Say '/namereg name' to register your name with your STEAMID!" but i already registerd.
2.I register with Alka and i enter on server with LoL with same steamid and nothing happens!
3.If i type twice with same name "/namereg" is not showing ("You may not register with this name, it has already been used.")

stupok 07-06-2007 21:51

Re: Name assign
 
Well, oops. I just wrote it up real quick, it'll give you an idea of how to do it anyways.

I've never actually used nvault in one of my plugins :D.

I'm pretty sure I'm using nvault_lookup improperly, I don't know for sure though. I'll look at again later and try testing it.

Alka 07-07-2007 04:43

Re: Name assign
 
Yeah...is the same thing! I know how to make "kick thing"...:wink:
Thanks.

@stupok69 you can give a try if you want.I'd like to see you'r version.


All times are GMT -4. The time now is 21:28.

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