Raised This Month: $32 Target: $400
 8% 

Admin Tag issues


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MaNaReaver
Member
Join Date: Apr 2020
Location: India
Old 06-29-2020 , 13:02   Admin Tag issues
Reply With Quote #1

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); 
MaNaReaver is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-02-2020 , 23:39   Re: Admin Tag issues
Reply With Quote #2

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.
__________________
fysiks is offline
ZaX
Senior Member
Join Date: Jan 2015
Old 07-03-2020 , 01:06   Re: Admin Tag issues
Reply With Quote #3

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);     } }

Last edited by ZaX; 07-03-2020 at 01:07.
ZaX is offline
MaNaReaver
Member
Join Date: Apr 2020
Location: India
Old 07-03-2020 , 16:25   Re: Admin Tag issues
Reply With Quote #4

Thanks everyone, I checked out your plugins, and was able to rectify the issue in my own one
__________________
MaNaReaver is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-04-2020 , 00:16   Re: Admin Tag issues
Reply With Quote #5

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.
__________________
fysiks is offline
MaNaReaver
Member
Join Date: Apr 2020
Location: India
Old 07-04-2020 , 13:41   Re: Admin Tag issues
Reply With Quote #6

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
__________________
MaNaReaver is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-04-2020 , 14:48   Re: Admin Tag issues
Reply With Quote #7

Quote:
Originally Posted by MaNaReaver View Post
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.
__________________
fysiks is offline
MaNaReaver
Member
Join Date: Apr 2020
Location: India
Old 07-05-2020 , 16:49   Re: Admin Tag issues
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
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.
__________________
MaNaReaver 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 01:10.


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