AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help + Request (https://forums.alliedmods.net/showthread.php?t=183135)

bazhenov93 04-17-2012 21:40

Need help + Request
 
I changed some functions on this plugin, is working has I need, but I want to add some new functions..

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <colorchat>

#define Plugin "GuestBook"
#define Version "0.7b"
#define Author "Doombringer"

#define FLAG ADMIN_ALL
//#define GUESTBOOK_FILE "guestbook.htm"

#define TIMESTAMP "%B %Y - %H:%M:%S"

#define BACKGROUND_COLOR "#666666"
#define TEXT_COLOR "#FFFF00"

#define MAX_LEN 132
#define ADMIN ADMIN_BAN
#define VIP ADMIN_RESERVATION

new cvarwaittimepathguestbook_namead_timebool:havetowait[32], filepath[MAX_LEN]; 

public 
plugin_init()
{
    
register_plugin(PluginVersionAuthor);
    
    
cvar register_cvar("GB_enabled","1")
    
waittime register_cvar("GB_waittime","60")
    
path register_cvar("GB_savepath","")
    
guestbook_name register_cvar("GB_filename","guestbook.htm")
    
ad_time register_cvar("GB_ads_time","60")
    
    new 
temp[2][MAX_LEN];
    
    
get_pcvar_string(pathtemp[0], MAX_LEN-1
    
get_pcvar_string(guestbook_nametemp[1], MAX_LEN-1)
    
register_clcmd("gb_write""guestbook_write1"FLAG)
    
register_clcmd("say !gb""guestbook_write"FLAG)
    
register_clcmd("say /gb""show_guestbook"FLAG)
    
    
register_cvar("GB_Version"VersionFCVAR_SERVER|FCVAR_SPONLY);
    
    new 
configsdir[38];
    
get_configsdir(configsdir37);
    
    if(
equal(temp[0], ""))
    
formatex(filepathMAX_LEN-1"%s/%s"configsdirtemp[1]);
    else
    
formatex(filepathMAX_LEN-1"%s/%s"temp[0], temp[1]);

    
    if(!
file_exists(filepath) && cstrike_running()) 
    {
        new 
file fopen(filepath"at"), tempp[64];
        
        
formatex(tempp63,"<body bgcolor=^"%s^" text=^"%s^"><br \>^n"BACKGROUND_COLORTEXT_COLOR); 
        
        
fprintf(filetempp63); 
        
        
fclose(file);
    }
    
    
server_cmd("exec %s/GB_config.cfg"configsdir);
    
set_task(float(get_pcvar_num(ad_time)), "ads");
}

public 
ads()
{
    if(
get_pcvar_num(cvar) < 1)
    return 
PLUGIN_CONTINUE
    
    ColorChat
(0GREY"Write !gb to leave a message on our GuestBook!")    
    
set_task(float(get_pcvar_num(ad_time)), "ads")
    
    return 
PLUGIN_CONTINUE
}

public 
can_write_again(idhavetowait[id] = false;

public 
guestbook_write(idlevelcid)
{
    if ( (!
cmd_access(idlevelcid2)) || id )
    return 
PLUGIN_HANDLED;
    
    else if (
get_pcvar_num(cvar) < 1)
    {
        
client_print(idprint_console,"The plugin is disabled")
        return 
PLUGIN_HANDLED;
    }
    
    else if (
havetowait[id])
    {
        
ColorChat(idRED"You have already written in the GuestBook!")
        
ColorChat(idRED"Wait 30 minutes before leave a new message")
        return 
PLUGIN_HANDLED;
    }
     
    
    
    
client_cmd(id"messagemode gb_write");
    
ColorChat(idGREEN"Type your message or !cancel to exit"// change here
    
}

public 
guestbook_write1(idlevelcid)
{
    new 
file fopen(filepath"at");
     
    new 
text[331], name[32], time[26];
    new 
Arg[65];
     
    
read_args(Arg64);
     
    
get_time(TIMESTAMPtime25);
    
get_user_name(idname31);
     
    if(
cstrike_running())
    
formatex(text330,"%s %s Wrote<br \>^n%s <br \><br \>^n^n"timenameArg);
    else
    
formatex(text330,"%s %s Wrote^n%s^n^n"timenameArg)
    
fprintf(filetext330);
     
    
fclose(file);
    
ColorChat(idGREEN"You just wrote in the GuestBook!")
     
    
havetowait[id] = true;
    
set_task(float(get_pcvar_num(waittime)), "can_write_again"id)
    return 
PLUGIN_HANDLED
}

public 
show_guestbook(idlevelcid)
{
    if(!
cmd_access(idlevelcid1)) 
    return 
PLUGIN_HANDLED
    
    
if(get_pcvar_num(cvar) < 1)
    {
        
client_print(idprint_chat,"The plugin is disabled")
        return 
PLUGIN_CONTINUE;
    }

    
show_motd(idfilepath"GuestBook")
    return 
PLUGIN_CONTINUE;


The help I need:
Where "Type your message or !cancel to exit"
How to check if the player typed !cancel?

The request:
Check if player have vip/admin flag, and for all messages in motd: ADMIN in green colour before the player name

like this: (i edited the html)
http://cs301800.userapi.com/v3018008...Iblt3Qpjgo.jpg


All times are GMT -4. The time now is 07:45.

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