AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Admin Tag issues (https://forums.alliedmods.net/showthread.php?t=325615)

MaNaReaver 06-29-2020 14:02

Admin Tag issues
 
Hey AM,

I wrote a small snippet for an old plugin by Bigballer, but I was unable to force tagging admins when they remove their tag. How can I achieve this? Thanks :)

PHP Code:

public client_putinserver(idset_task(3.0,"admin_entered",id)

public 
admin_entered(id)
{
    if(
is_user_admin(id)) force_tag(id);
}

public 
force_tag(id)
{
    
get_user_name(idname31);

    if (
get_pcvar_num(amx_forcetag) && (containi(nametag) == -1))
    {
        
format(name31"%s %s"tagname);
        
set_user_info(id"name"name);
    }
    return 
PLUGIN_CONTINUE;
}

public 
client_infochanged(idadmin_entered(id); 


fysiks 07-03-2020 00:39

Re: Admin Tag issues
 
I did something similar to this a long while back where the requester was asking for a plugin to add points to their name. I can't find it right now but you might be able to find it if you search hard enough (using my name will probably help). If you can't find it I'll see if I can come up with something.

ZaX 07-03-2020 02:06

Re: Admin Tag issues
 
Im not sure if this is the best way, but it should work
Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #define TAG "MyTag" new pCvarForceTag public plugin_init() {     pCvarForceTag = register_cvar("amx_force_tag", "1"); } public client_putinserver(id) {     if(is_user_admin(id))     {         set_task(2.0, "ForceNameChange", id);     } } public client_infochanged(id) {     new szOldName[32], szNewName[32];     get_user_info(id, "name", szNewName, charsmax(szNewName));     get_user_name(id, szOldName, charsmax(szOldName));     if(!equal(szNewName, szOldName))     {         if(is_user_admin(id))         {             set_task(2.0, "ForceNameChange", id);         }     } } public ForceNameChange(id) {     ForceTag(id); } public ForceTag(id) {     new szName[32]; get_user_name(id, szName, charsmax(szName));     new szNewName[32];     if( get_pcvar_num(pCvarForceTag) && (containi(szName, TAG) == -1))     {         formatex(szNewName, charsmax(szNewName), "%s %s", TAG, szName);         set_user_info(id, "name", szNewName);     } }

MaNaReaver 07-03-2020 17:25

Re: Admin Tag issues
 
Thanks everyone, I checked out your plugins, and was able to rectify the issue in my own one :)

fysiks 07-04-2020 01:16

Re: Admin Tag issues
 
That's great to hear. If you post your final working solution, it may come in handy for future requests of a similar nature. That's one of the great things about an open source community.

MaNaReaver 07-04-2020 14:41

Re: Admin Tag issues
 
The issue was majorly because I didn't use a set_task in client_infochanged, and that was messing up the functionality. I wanted to make it a simple plugin with less lines of code and this was the best I could do. I hope this helps others out!

PHP Code:

#include <amxmodx>
#include <amxmisc>

new name[32], tag[12];
new 
amx_forcetagamx_tag;

public 
plugin_init()
{
    
register_plugin("Tags""1.2""BigBaller Edit")
    
amx_forcetag register_cvar("amx_forcetag""1")
    
amx_tag register_cvar("amx_tag""[AlliedModders]");
    
get_pcvar_string(amx_tagtag12);
}

public 
client_putinserver(idset_task(2.0,"admin_entered",id);

public 
admin_entered(id) if(is_user_admin(id)) force_tag(id);

public 
force_tag(id)
{
    
get_user_name(idname31);

    if (
get_pcvar_num(amx_forcetag) && (containi(nametag) == -1))
    {
        
format(name31"%s %s"tagname);
        
set_user_info(id"name"name);
    }
    return 
PLUGIN_CONTINUE;
}

public 
client_infochanged(idset_task(2.0,"admin_entered",id


fysiks 07-04-2020 15:48

Re: Admin Tag issues
 
Quote:

Originally Posted by MaNaReaver (Post 2708622)
I wanted to make it a simple plugin with less lines of code and this was the best I could do.

FYI, the goal of having fewer lines of code is never a goal of any good programmer. Never have that as a goal because it often prevents you from writing code that is actually good.

MaNaReaver 07-05-2020 17:49

Re: Admin Tag issues
 
Quote:

Originally Posted by fysiks (Post 2708634)
FYI, the goal of having fewer lines of code is never a goal of any good programmer. Never have that as a goal because it often prevents you from writing code that is actually good.

Just wanted to optimize an already written plugin, but yeah, I agree with you, and I'll keep this in mind for my future works.


All times are GMT -4. The time now is 16:31.

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