AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with Chat Logger (https://forums.alliedmods.net/showthread.php?t=157135)

viniref 05-16-2011 20:58

Help with Chat Logger
 
I need help to write the plugin in two places, and are increasing at amxx_logs amxx_site.

Here's the code:

PHP Code:

/* Chat Logger v2.1a
   Author: Jim (jim_yang @ AlliedModders Forum)
   Credit: aligind4h0us3 for the idea, suggestion and test.
           Cheap_Suit
           Amx Mod X Team for Adminchat plugin.
   
   Description: It logs messages of say(@|@@|@@@), say_team(@), amx_say, amx_chat, amx_psay, amx_csay, amx_tsay
   Install: put this plugin above adminchat.amxx in amxxdir\configs\plugins.ini
   Cvar: cl_logmode 0  log chat messages to ChatLog.htm in amxxdir\logs\
                    1  log chat messages(by date)to XXXX.XX.XX.htm in amxxdir\logs\
         XXXX.XX.XX is the date.
                       default is 1.
*/
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#define MAXLEN 511
#define TITLE "<h2 align=center>Chat Logger</h2><hr>"
#define FONT "<font face=^"Verdana^" size=2>"
static FilePath[49]
new 
g_cvarlogmode
new g_adminchatID
new const HUDPOS[4][] = {"""HUDCHAT""HUDCENTER""HUDBOTTOM"}
new const 
TEAMCOLOR[_:CsTeams][] = {"gray""red""blue""gray"}
new const 
TEAMNAME[_:CsTeams][] = {"*DEAD*""(Terrorist) ""(Counter-Terrorist) ""*SPEC*"}
public 
plugin_init()
{
 
register_plugin("Chat Logger""2.1a""Jim")
 
g_cvarlogmode register_cvar("cl_logmode""1")
 
register_clcmd("say""logtext")
 
register_clcmd("say_team""logtext")
 
register_concmd("amx_say""logtext")
 
register_concmd("amx_chat""logtext")
 
register_concmd("amx_psay""logtext")
 
register_concmd("amx_tsay""logtext")
 
register_concmd("amx_csay""logtext")
 
get_localinfo("amxx_logs"FilePath48)
}
public 
plugin_cfg()
{
 
g_adminchatID is_plugin_loaded("Admin Chat")
}
public 
logtext(id)
{
 if(
is_user_bot(id)) return
 
 new 
bool:IsAdminChatRunning false
 
if(g_adminchatID != -1)
 {
  new 
tmp[1], status[2]
  
get_plugin(g_adminchatID,tmp,0,tmp,0,tmp,0,tmp,0,status,1)
  if(
status[0] == 0x72)
   
IsAdminChatRunning true
 
}
  
 static 
datestr[11], LogFile[65]
 new 
timestr[9], authid[32], ip[16], cmd[9], logmsg[MAXLEN 1]
 new 
pos 0ufg get_user_flags(id) & ADMIN_CHAT
 
 get_time
("%d.%m.%Y"datestr10)
 
get_time("%H:%M:%S"timestr8)
 
get_user_authid(idauthid31)
 
get_user_ip(idip151)
 
 if(
get_pcvar_num(g_cvarlogmode))
 {
  
formatex(LogFile64"%s/%s.htm"FilePathdatestr)
  if(!
file_exists(LogFile))
  { 
   new 
title[80]
   
formatex(title79"<title>Chat Logger - %s</title>%s"datestrTITLE)
   
write_file(LogFiletitle)
   
write_file(LogFileFONT)
  }
  
formatex(logmsgMAXLEN"%s &lt;%s&gt;&lt;%s&gt;"timestrauthidip)
 }
 else
 {
  
formatex(LogFile64"%s/ChatLog.htm"FilePath)
  if(!
file_exists(LogFile))
  {
   
write_file(LogFile"<title>Chat Logger</title>")
   
write_file(LogFileTITLE)
   
write_file(LogFileFONT)
  }
  
formatex(logmsgMAXLEN"%s - %s &lt;%s&gt;&lt;%s&gt;"datestrtimestrauthidip)
 }
 
 
read_argv(0cmd8)
 if(
cmd[0] == 0x61)
 {
  if(!
IsAdminChatRunning || !ufg) return
  
  
formatex(logmsgMAXLEN"%s <font color=purple>"logmsg)
  if(
cmd[5] == 0x68)
   
formatex(logmsgMAXLEN"%s(ADMINS) "logmsg)
  else
  {
   switch(
cmd[4])
   {
    case 
0x73formatex(logmsgMAXLEN"%s(ALL) "logmsg)
    case 
0x74formatex(logmsgMAXLEN"%s(HUDCHAT) "logmsg)
    case 
0x63formatex(logmsgMAXLEN"%s(HUDCENTER) "logmsg)
    case 
0x70:
    {
     new 
privpname[32]
     
read_argv(1pname31)
     
pos strlen(pname) + 1
     priv 
cmd_target(idpname0)
     if(!
priv)
      return
     
get_user_name(privpname31)
     
CheckPlayerName(pname)
     
formatex(logmsgMAXLEN"%s(%s) "logmsgpname)
    }
   }
  }
 }
 else
 {
  new 
0at[5]
  
read_argv(1at4)
  while(
at[a] == 0x40)
   
a++
  if(
IsAdminChatRunning && && cmd[3])
  {
   
pos 1
   formatex
(logmsgMAXLEN"%s <font color=teal>(%s) "logmsgis_user_admin(id) ? "ADMIN" "PLAYER")
  }
  else if(
IsAdminChatRunning && && !cmd[3] && ufg)
  { 
   
pos IsColorLetter(at[a]) ? a
   formatex
(logmsgMAXLEN"%s <font color=purple>(%s) "logmsgHUDPOS[a])
  }
  else
  {
   if(!
is_user_connected(id)) return
   new 
CsTeams:team cs_get_user_team(id)
   
formatex(logmsgMAXLEN"%s <font color=%s>"logmsgTEAMCOLOR[_:team])
   switch(
team)
   {
    case 
12
    {
     if(!
is_user_alive(id))
      
formatex(logmsgMAXLEN"%s*DEAD*"logmsg)
     if(
cmd[3])
      
formatex(logmsgMAXLEN"%s%s"logmsgTEAMNAME[_:team])
    }
    case 
03formatex(logmsgMAXLEN"%s%s"logmsgTEAMNAME[_:team])
   }
  }
 }
 
 new 
name[32],  said[192]
 
get_user_name(idname31)
 
CheckPlayerName(name)
 
read_args(said191)
 
remove_quotes(said)
 
replace_all(said191"<""&lt;")
 
replace_all(said191">""&gt;")
 
formatex(logmsgMAXLEN"%s%s</font> : <font color=green>%s</font><br>"logmsgnamesaid[pos])
 
write_file(LogFilelogmsg)
}
CheckPlayerName(name[])
{
 new 
0c
 
while((name[i]))
 {
  switch(
c)
  {
   case 
0x3Cname[i] = 0x5B
   
case 0x3Ename[i] = 0x5D
  
}
  
i++
 }
}
bool:IsColorLetter(c)
{
 switch(
c)
 {
  case 
0x72,0x67,0x62,0x79,0x6D,0x63,0x6F: return true
  
default: return false
 
}
 return 
false



If someone would be grateful to me.

Exolent[jNr] 05-16-2011 21:26

Re: Help with Chat Logger
 
Quote:

Originally Posted by viniref (Post 1470743)
I need help to write the plugin in two places, and are increasing at amxx_logs amxx_site.

What?

ARES[ro] 05-16-2011 22:10

Re: Help with Chat Logger
 
He's just formating a html file with chat logs.
but what I dont understand is, who fixes bugs in google translator???
Quote:

Originally Posted by viniref (Post 1470743)
If someone would be grateful to me.


viniref 05-16-2011 22:49

Re: Help with Chat Logger
 
Quote:

Originally Posted by Exolent[jNr] (Post 1470749)
What?

The plugin saves the history in the / logs which is amxx_logs.

But I would also like to save myself another location, which is another place amxx_site defined by me.

Namely, I want him to save in two places.

Sorry, I'm using google translator.

Exolent[jNr] 05-16-2011 23:06

Re: Help with Chat Logger
 
Quote:

Originally Posted by viniref (Post 1470775)
The plugin saves the history in the / logs which is amxx_logs.

But I would also like to save myself another location, which is another place amxx_site defined by me.

Namely, I want him to save in two places.

Sorry, I'm using google translator.

You want to save it into 2 files, or 1 on the server and another on a website?

ARES[ro] 05-16-2011 23:46

Re: Help with Chat Logger
 
Quote:

Originally Posted by Exolent[jNr] (Post 1470779)
You want to save it into 2 files, or 1 on the server and another on a website?

Let me answer that for you: Yes
But no really the first option por favor.
And I personally dont know how I would do it, I dont like hooking all the messages I think its too messy but it is an option. I would rather see default amxx plugin that does it (if there is one) and use that as reference or create a forward inside it with my own API. Probably.


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

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