Raised This Month: $51 Target: $400
 12% 

No prefix with custom plugin?


Post New Thread Reply   
 
Thread Tools Display Modes
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-28-2020 , 13:55   Re: No prefix with custom plugin?
Reply With Quote #21

I really don't understand why it is so difficult for you to copy/paste a single line of code. Where did you see me mention anything about creating a format inside the .sma file? That's not how the function works. It requires a format identifier, not the entire format line inside it.

Code:
#include <amxmodx> #include <chatmanager> public plugin_init() {     register_plugin("CM: Setinfo Prefix", "1.0", "OciXCrom") } public client_putinserver(id) {     cm_on_player_data_updated(id) } public cm_on_player_data_updated(id) {     new szInfo[2]     get_user_info(id, "vip", szInfo, charsmax(szInfo))     if(str_to_num(szInfo) == 1)     {         cm_set_user_say_format(id, "format_admin", "format_admin_team")         cm_set_user_prefix(id, "[YOUR PREFIX HERE]")     } }

Tested and working.
__________________

Last edited by OciXCrom; 05-28-2020 at 13:55.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-29-2020 , 06:11   Re: No prefix with custom plugin?
Reply With Quote #22

Sorry for late update, everything works perfectly, I changed that code a bit, I added adding ADMIN_LEVEL_H flag and added everything in logfile so I can see who is using that free VIP.
supertrio17 is offline
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-30-2020 , 19:14   Re: No prefix with custom plugin?
Reply With Quote #23

Hey OciXCrom, so I added cvars for that plugin, and I wondered, how do I reload my plugin after changing my cvars. So I want to have every time I change my prefix cvar to reload plugin and to everyone who is logged in with prefix to immediatly get new prefix set in cvar.

Is that even posible?
supertrio17 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-30-2020 , 22:20   Re: No prefix with custom plugin?
Reply With Quote #24

It is possible. Show your code. If you're using AMXX 1.9 or 1.10 it's easy to make, else you will need to install a module for hooking cvar changes.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-31-2020 , 08:27   Re: No prefix with custom plugin?
Reply With Quote #25

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <chatmanager>

new g_vipp_on
new g_vipp_prefix
new g_vipp_setinfo

#pragma tabsize 0

#define ADMIN_FLAG ADMIN_LEVEL_H
#define FORMAT_SAY "format_admin"
#define FORMAT_TSAY "format_admin_team"

public plugin_init()
{
    
register_plugin("Setinfo Prefix""3.2""OciXCrom");
    
    
g_vipp_on register_cvar("amx_lprefix_on""1");
    
g_vipp_prefix register_cvar("amx_lprefix_prefix""[VIP]");
    
g_vipp_setinfo register_cvar("amx_lprefix_setinfo""vip");
}

public 
client_putinserver(id)
{
    
cm_on_player_data_updated(id);
}

public 
cm_on_player_data_updated(id)
{
    new 
vipp_on get_pcvar_num(g_vipp_on);

    if(
vipp_on == 1)
    {
        new 
SETINFO_KEY[32], szInfo[32];
        
get_pcvar_string(g_vipp_setinfoSETINFO_KEYcharsmax(SETINFO_KEY));
        
get_user_info(idSETINFO_KEYszInfocharsmax(szInfo));

        if(
str_to_num(szInfo) == 1)
        {
            new 
lpPrefix[32];
            
get_pcvar_string(g_vipp_prefixlpPrefixcharsmax(lpPrefix));
            
set_user_flags(idADMIN_FLAG);
            
cm_set_user_say_format(idFORMAT_SAYFORMAT_TSAY);
            
cm_set_user_prefix(idlpPrefix);

            new 
logfile[120];
            new 
datadir[120];
            new 
text[120];
            
get_datadir(datadircharsmax(datadir));
            
formatex(logfilecharsmax(logfile), "%s/vip_launcher_log.txt"datadir);
            new 
name[32];
            new 
cTimeString[32];
            
get_time"%m/%d/%Y - %H:%M:%S"cTimeString31 );
            
get_user_name(idnamecharsmax(name));
            
formatex(textcharsmax(text), "'%s' Player '%s' connected as VIP. Key: '%s' = '%s'"cTimeStringnameSETINFO_KEYszInfo);
            
write_file(logfiletext);
        }
    }


Last edited by supertrio17; 05-31-2020 at 11:27.
supertrio17 is offline
Old 05-31-2020, 11:26
supertrio17
This message has been deleted by supertrio17.
supertrio17
Senior Member
Join Date: May 2020
Location: Serbia
Old 05-31-2020 , 11:27   Re: No prefix with custom plugin?
Reply With Quote #26

Btw, I'm using version 1.8.2

And can anyone tell me why do I get 2 lines when anyone joins my server with vip, so I do not get one line, but that same line gets printed twice
supertrio17 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 06:21.


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