Any way to adminlog?
#1

I have created an admin log for each admincommand

ex: slap, /goto, /getcar etc.


via

PHP код:
mysql_tquery 

But if 5-10 admins would type one cmd, there would be immense spam of mysql_Tquery.

Any ideea how to make logs without lag / spam?
Reply
#2

If you insert the query to the database once an admin uses the commands, I don't think there is a way to reduce the spam.
Reply
#3

Quote:
Originally Posted by willbedie
Посмотреть сообщение
If you insert the query to the database once an admin uses the commands, I don't think there is a way to reduce the spam.
So I should stick with logs to important commands?
Reply
#4

Yeah, like for example /setadmin, /givemoney, /setmoney, /createvehicle etc.. Only for the commands that could be abused.
Reply
#5

Exactly.

P.S Do you mind showing me your full adminlog system? I want to make something similar, i just made server stats for now.
Reply
#6

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Exactly.

P.S Do you mind showing me your full adminlog system? I want to make something similar, i just made server stats for now.
PHP код:
        format(jQueryMAX_QUERY_LENGTH"INSERT INTO `"#adminlog"` (Username, Command, Targetname, Value, Data) VALUES ('%s', 'HEREMODIFYWITHCMDNAME', '%s', '%i', CURRENT_TIMESTAMP)", PlayerName(playerid), PlayerName(targetid), score);
        
mysql_tquery(handlejQuery""""); 
just create a table with those rows and add that php code inside your admin cmd. Change the "heremodify" with CMD: name

good luck
Reply
#7

Got the sql file for the table? Also, wouldn't be better to create a stock instead of pasting that code for every cmd wanted to log?
Reply
#8

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
Got the sql file for the table? Also, wouldn't be better to create a stock instead of pasting that code for every cmd wanted to log?
create

Username (varchar 24)
Command (varchar 24)
Targetname (varchar 24)
Value (varchar 24)
Date (Timestamp)

then alter the table by adding "ID". use the A_I function and it's done

about the stock, it is easier, but sometimes I prefere hard things to complicate myself, idk.


but no, I don't recomand you to use stocks because you need to modify the "command" area. I find it easier to put manually instead of creating stock
Reply
#9

It won't cause you any harm if you run 5-10 queries every second.

Another smart way can be using a 2D array and fill it up with admin log until it gets full. Once the array is full, you save the log from array to database and then empty it and do the process again.

A rough look at what i mean:
PHP код:
#define MAX_ADMIN_LOGS 1000 // how many logs can the array hold
#define MAX_ADMIN_LOG_STRING 144 // max length of log string
new adminLogs[MAX_ADMIN_LOGS][MAX_ADMIN_LOG_STRING];
new 
adminLogCount// this var is to keep track of number of logs
// create a function to write admin log
WriteAdminLog(const text[]) {
    if (
adminLogCount == MAX_ADMIN_LOGS) {
        
// array is full
        // we loop through 1000 logs (or whatever you set the limit) and run 1000 queries to save into database
        
for (new 0MAX_ADMIN_LOGSi++) {
            
// write query to save log for "adminLogs[i]"
        
}
        
// clear the count
        
adminLogCount 0;
    }
   
    
// here we fill the array
    
format(adminLogs[adminLogCount++], MAX_ADMIN_LOG_STRINGtext);

That's all you need for the second method!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)