Results 1 to 8 of 8

Thread: Catch what users say

  1. #1
    Private
    Join Date
    Sep 2015
    Posts
    33
    Thanks
    0
    Thanked 21 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,582
    Thanks
    17
    Thanked 931 Times in 580 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 21 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
    233
    Thanks
    62
    Thanked 198 Times in 106 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 17 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
    Apr 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 sizegenetics website https://alvenda.com/sizegenetics-review/ 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.




    Not that i'm aware of (apart from libcod).
    Thanks for the source of the script, stevomitric. Can I use it in a project I'm working on?
    Last edited by JuanAndrews; 23rd April 2019 at 22:16.

  10. #7
    ... connecting
    Join Date
    May 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by croni1012 View Post
    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

    no my friend i dont think so that there could be a possibility

  11. #8
    ... connecting
    Join Date
    May 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by cronis10112 View Post
    Hi,
    Is there a possibility to catch what users say to others? I know i can read phenq blog https://enfinmince.fr/phenq-avis/ the log, but is there any other option? If not, how can I read JUST the last line of a file?
    nyaa
    Now you can use list slices to get first and last lines of the file.
    Last edited by EdwardLopez; 19th May 2019 at 02:02.

Posting Permissions

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