Results 1 to 7 of 7

Thread: Catch what users say

  1. #1
    Private
    Join Date
    Sep 2015
    Posts
    33
    Thanks
    0
    Thanked 20 Times in 13 Posts

    Catch what users say

    Hi,
    Is there a possibility to catch what users say to others? I know i can read the log, but is there any other option? If not, how can I read JUST the last line of a file?
    nyaa

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,540
    Thanks
    17
    Thanked 905 Times in 562 Posts
    through the callback_playercommand
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

    Sending me a private message makes me want to help you LESS.

  3. #3
    Private
    Join Date
    Sep 2015
    Posts
    33
    Thanks
    0
    Thanked 20 Times in 13 Posts
    But that's libcod function, isnt that?

  4. The Following User Says Thank You to croni1012 For This Useful Post:

    kubislav23 (29th June 2018)

  5. #4
    Private First Class voron00's Avatar
    Join Date
    Nov 2014
    Posts
    215
    Thanks
    59
    Thanked 185 Times in 97 Posts
    Indeed it is.
    sudo apt-get rekt

  6. The Following User Says Thank You to voron00 For This Useful Post:

    kubislav23 (29th June 2018)

  7. #5
    Private
    Join Date
    Nov 2013
    Posts
    16
    Thanks
    2
    Thanked 16 Times in 6 Posts
    Quote Originally Posted by croni1012 View Post
    how can I read JUST the last line of a file?
    With the built-in functions you cant. You would need to read the whole file in order to get to the last line. This is very ineffective as log files can get huge (we're talking in MB).
    In my old script i deleted the log every time i read it. Take a look:

    PHP Code:
    // stEvo

    init() {
        
    level.logName "log.log";
        
    level.logTimeRefresh 1;
        
    level.triggerString "!";    // can be any multi-lenght string
        
        
    setCvar("g_log""scriptdata/"+level.logName);    //
        
    setCvar("g_logSync"1);                        // You may need double restart if u havent set the cvars before
        
        
    thread main_loop();
    }

    main_loop() {
        
    wait 10;
        while (
    1) {
            
    clearLog();
            
    wait level.logTimeRefresh;
            
            
    filenum OpenFilelevel.logName"read" );
            if (
    filenum == -1)  continue;
            
            
    commas freadln(filenum);
            while (
    commas 0) {
                for (
    0commasi++) {
                    
    response fgetarg(filenum,i);
                    
    chr 0;

                    
    type "";
                    for (; 
    chr response.sizechr++)
                        if (
    response[chr] != ";"type += response[chr]; else break; chr ++;
                    
                    
    guid "";
                    for (; 
    chr response.sizechr++)
                        if (
    response[chr] != ";"guid += response[chr]; else break; chr ++;
                    
                    
    id "";
                    for (; 
    chr response.sizechr++)
                        if (
    response[chr] != ";"id += response[chr]; else break; chr ++;
                    
                    
    name "";
                    for (; 
    chr response.sizechr++)
                        if (
    response[chr] != ";"name += response[chr]; else break; chr ++;
                        
                    
    message "";
                    for (; 
    chr response.sizechr++)
                        if (
    response[chr] != ";"message += response[chr]; else break; chr ++;
                
                    if (
    validType(type) && validMessage(message))
                        
    thread doMessage(fixMessage(ToLower(message)), guididname);
                }
                
                
    commas freadln(filenum);
            }
            
            
    closeFile(filenum);
        }
    }

    doMessage(messageguididname) {

        if (
    startsWith(message"id"))
            
    getId(idmessage);    

        else if (
    startsWith(message"kick"))
            
    kickPlayer(idmessage);
        
        else
            
    getPlayerByNum(int(id)) iprintlnbold("Invalid Command.");
    }

    //******************************************************************************************************************

    kickPlayer(idmessage) {
        
    player getPlayerByNum(int(id));
        
    //if (isDefined(player.admin) && !player.admin) { player iprintlnbold("You are not admin."); return;} // Uncomment
        
        
    name ""chr 0;
        for (; 
    chr message.sizechr ++) if (message[chr] == " ") break; chr ++;
        for (; 
    chr message.sizechr ++) name += message[chr];

        
    playerToKick getPlayerByName(name);
        if (!
    isPlayer(playerToKick)) { player iprintlnbold("To many or no matches: " name); return;}
        
    player SayAll("[^1BOT^7]: Kicked player: " playerToKick.name ); wait 2;
        
    kick(playerToKick getEntityNumber());
    }

    getId(idmessage) {
        
    player getPlayerByNum(int(id));
        
    //if (isDefined(player.admin) && !player.admin) { player iprintlnbold("You are not admin."); return;} // Uncomment 
        
        
    name ""chr 0;
        for (; 
    chr message.sizechr ++) if (message[chr] == " ") break; chr ++;
        for (; 
    chr message.sizechr ++) name += message[chr];
        
        
    players getEntArray"player""classname" );
        for (
    0players.sizei++)
            if (
    IsSubStr(ToLower(players[i].name), name) ) {
                
    player SayAll("[^1BOT^7]: " players[i].name " ^7 - ID: ^1#" players[igetEntityNumber() );
                
    wait 1;
            }
    }

    //******************************************************************************************************************

    clearLog() {
        
    filenum OpenFilelevel.logName"write" );
        
    closeFile(filenum);
    }

    validMessage(message) {
        if (
    message.size 3) return 0;
        return (
    GetSubStr(message0level.triggerString.size)  == level.triggerString || GetSubStr(message1level.triggerString.size+1)  == level.triggerString);
    }

    validType(type) {
        return (
    type.size && IsSubStr(type"say") );
    }

    fixMessage(message) {
        if (
    GetSubStr(message0level.triggerString.size) == level.triggerString) return GetSubStr(messagelevel.triggerString.sizemessage.size);
        if (
    GetSubStr(message1level.triggerString.size+1) == level.triggerString) return GetSubStr(messagelevel.triggerString.size+1message.size);
        return 
    "";
    }

    getPlayerByNum(num) {
        
    players getentarray("player""classname");
        for(
    0players.sizei++)
            if (
    players[igetEntityNumber() == num)
                return 
    players[i];
    }

    getPlayerByName(name) {
        
    // -2 - Invalid parameter
        // -1 - No player found by that name
        //  0 - More then 1 player found
        
        
    if (name.size == || name == " ") return -2;
        if (
    name[0] == "#") {
            
    name GetSubStr(name1name.size);
            
    id int(name);
            
    player getPlayerByNum(id);
            if (
    IsPlayer(player)) return player; return -1
        }
        
        
    players getentarray("player""classname");
        
    player = -1;
        
        for(
    0players.sizei++)
            if (
    IsSubStr(ToLower(players[i].name), name))
                if (
    player != -1) return 0;
                else 
    player players[i];
        return 
    player;
    }

    startsWith(strstart) {
        if (
    start.size str.size) return 0;
        for (
    0start.sizei++)
            if (
    str[i] != start[i]) return 0;
        return 
    1;

    Its far from perfect but it gets the job done.


    Quote Originally Posted by croni1012 View Post
    I know i can read the log, but is there any other option?
    Not that i'm aware of (apart from libcod).

  8. The Following 3 Users Say Thank You to stevomitric For This Useful Post:

    kung foo man (7th June 2017),maxdamage99 (7th June 2017),Ni3ls (7th June 2017)

  9. #6
    ... connecting
    Join Date
    Jun 2017
    Posts
    1
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by cronei1012 View Post
    But that's libcod pedigest penomet results isnt that?
    Thanks Stevo.
    Last edited by JaredJer; 23rd November 2017 at 13:11.

  10. The Following User Says Thank You to JaredJer For This Useful Post:

    kubislav23 (29th June 2018)

  11. #7
    ... connecting
    Join Date
    Jun 2018
    Posts
    1
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by stevomitric View Post
    With the built-in functions you cant. You would need to read the whole file in order to get to the last line. This is very ineffective as log files can get huge (we're talking in MB).
    In my old script used with phenq and i deleted the log every time i read it. Take a look:

    Its far from perfect but it gets the job done.


    Not that i'm aware of (apart from libcod).
    Hey,it might not be perfect for you but it is perfect for me as I was looking for a script like this and it works for me. Thank you so much.
    Last edited by DavidOwens; 30th June 2018 at 10:21.

  12. The Following User Says Thank You to DavidOwens For This Useful Post:

    kubislav23 (29th June 2018)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •