Results 1 to 7 of 7

Thread: Help with IP select CoD2

  1. #1
    Private
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    5
    Thanked 5 Times in 5 Posts

    Exclamation Help with IP select CoD2

    Hello,

    I would like some help. I don't understand much about scripts in cod2, so I've been trying to study and learn more and more. If you can help me, I will be very grateful.

    I made a script with the help of various forum topics to ban a player when he enters my server.

    PHP Code:
    Player_OnConnect()
    {
        
    self thread CheckIp();
    }
    CheckIp()
    {
        
    maps\mp\gametypes\_mysql::asyncQuery("SELECT `ip` FROM `ip` WHERE `ip` = '" self getIP() + "'", ::processKickIp);
    }

    processKickIp(rowsargs)
    {
        
    player_ip self getIP();
        if (
    isDefined(rows) && isDefined(rows[0]))
        {
            
    ip rows;
            for (
    0ip.sizei++)
            {
                if (
    player_ip == ip[i]["ip"])
                {
                    
    username self.name;
                    
    userid self getEntityNumber();
                    
    kick2(userid"- Player banned.");
                    
    sendgameservercommand(-1"h \"console: " username " ^7kicked per banned IP \"");
                    
    printf(username "  kicked per banned IP: " ip[i]["ip"] + "\n");
                    break;
                }
            }
        }

    I call this function in _menus, OnMenuResponse() method:

    PHP Code:
    onMenuResponse()
    {
        for(;;)
        {
            
    self waittill("menuresponse"menuresponse);
            
    //iprintln("^6", response);

            
    if (menu == game["menu_serverinfo"]) {
                
    self thread maps\pam\pzt::Player_OnConnect();
            }
    ... 
    However, while the map is running and if I add an IP to the database during the map, after kicking the player he can still reconnect and play, until the map is finished.

    Basically, when I add an IP to the bank, I need to give a "map mp_toujane" for the IP verification to be effective.

    Can anyone help?

  2. #2
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    426
    Thanks
    78
    Thanked 102 Times in 86 Posts
    need see
    Code:
    maps\mp\gametypes\_mysql::asyncQuery
    bcs
    PHP Code:
    processKickIp(rowsargs
    maybe callback function dont get any object to yourself in "self", maybe some args wrong
    try use printf() to debug: is defined self, args, rows etc?

    maybe the function itself is never called at all, because it is not very good to consider opening some menu (like a first menu for player) as a "connection", you can use the event onPlayerConnect, connected or put this
    PHP Code:
    checkIP() 
    in
    "codecallback_playerConnect()"
    after
    "waittill("connected")"
    Last edited by maxdamage99; 14th August 2020 at 06:57.
    PHP Code:
    class CoronaVirus 
    {
       
    CoronaVirus(int m 1): multi(m) { Peoples.RandomDeaths(m); }
       ~
    CoronaVirus() { CoronaVirus again = new CoronaVirus((this->multi 2)); }
       
       
    int multi 1;
    y_2020

  3. The Following User Says Thank You to maxdamage99 For This Useful Post:

    kung foo man (18th August 2020)

  4. #3
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,626
    Thanks
    17
    Thanked 968 Times in 606 Posts
    1. Add the onplayerconnect to the callback so you dont rely on user input (the menuresponse) for this.

    2. The second part of your script does not know which thing "self" is. I guess you havent run this with developer enabled?

    3. printf is your friend. Print everything that you are not 100% sure has the correct value. Kick/ban yourself to simulate.
    "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.

  5. The Following 2 Users Say Thank You to IzNoGoD For This Useful Post:

    kung foo man (18th August 2020),maxdamage99 (17th August 2020)

  6. #4
    Private
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    5
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by IzNoGoD View Post
    1. Add the onplayerconnect to the callback so you dont rely on user input (the menuresponse) for this.

    2. The second part of your script does not know which thing "self" is. I guess you havent run this with developer enabled?

    3. printf is your friend. Print everything that you are not 100% sure has the correct value. Kick/ban yourself to simulate.
    I may be wrong, but is Callback_PlayerConnect called every time a round is started, or not?

    Because, when I put a method at this level, every time he starts a round (sd), he executes what is there after waittill ("connected") and not only when the player connects to the server.

    My scripts are configured inside a zPAM207.

    Thanks for understanding, I will try to run and return with information.

    Thank you.
    Last edited by caldas; 14th August 2020 at 18:08.

  7. The Following User Says Thank You to caldas For This Useful Post:

    kung foo man (18th August 2020)

  8. #5
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,626
    Thanks
    17
    Thanked 968 Times in 606 Posts
    Save something to player.pers[array]. That does not get reset on round restart.

    PHP Code:
    onplayerconnect()
    {
      if(!
    isDefined(self.pers["connected"]))
      {
        
    self.pers["connected"] = true;
        
    self thread dobancheck();
      }

    "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.

  9. #6
    Private
    Join Date
    Dec 2016
    Posts
    30
    Thanks
    5
    Thanked 5 Times in 5 Posts
    @IzNoGoD

    Quote Originally Posted by IzNoGoD View Post
    Save something to player.pers[array]. That does not get reset on round restart.

    PHP Code:
    onplayerconnect()
    {
      if(!
    isDefined(self.pers["connected"]))
      {
        
    self.pers["connected"] = true;
        
    self thread dobancheck();
      }

    Thank you very much. Its worked.

    Now, when I try to use kick2, the console returns me with a Segmentation fault.

    PHP Code:
    CheckIp()
    {
        
    row maps\mp\gametypes\_mysql::query("SELECT ip FROM ip WHERE ip = '" self getIP() + "'");

        if (
    isDefined(row) && isDefined(row[0]) && isDefined(row[0]["ip"]))
        {
            
    id self getEntityNumber();
            
    name self.name;
            
    sendgameservercommand(-1"h \"console: " name " ^7kicked per banned IP \"");
            
    kick2(id"Player banned.");
        }

    Code:
    ./cod2.sh: line 8:  4682 Segmentation fault      LD_LIBRARY_PATH=. LD_PRELOAD=$PWD/libcod2_1_3.so ./cod2_lnxded +set fs_basepath "/home/cod2-28962" +set fs_homepath "/home/cod2-28962" +set pb_sv_homepath "/home/cod2-28962/pb" +set com_hunkMegs 512 +set net_ip 10.158.0.5 +set net_port 28962 +set sv_maxclients 64 +set developer 1 +set sv_punkbuster 0 +set sv_cracked 1 +set rcon_password "x" +set sv_privatePassword "caldaslindo" +exec x.cfg
    I tried with developer 1/2/0. With kick(id) works perfectly.

    dmesg
    Code:
    [408566.147065] cod2_lnxded[4682]: segfault at c ip 00000000080f6e16 sp 00000000ffd01320 error 4 in cod2_lnxded[8048000+135000]
    [408566.158927] Code: e5 57 56 83 ec 30 8b 45 08 89 c2 69 d2 30 02 00 00 b8 00 64 71 08 01 d0 89 45 f4 8b 45 f4 8b 80 58 01 00 00 89 45 f0 8b 45 f0 <8b> 40 0c 25 00 00 80 00 85 c0 75 09 c7 45 ec 00 00 00 00 eb 69 8b


    -----------------------------------

    FIXED WITH WAIT

    PHP Code:
    CheckIp()
    {
        
    row maps\mp\gametypes\_mysql::query("SELECT ip FROM ip WHERE ip = '" self getIP() + "'");

        if (
    isDefined(row) && isDefined(row[0]) && isDefined(row[0]["ip"]))
        {
            
    wait 1;
            
    kick2(self getEntityNumber(), "Player banned.");
        }

    Last edited by caldas; 16th August 2020 at 18:06.

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

    kung foo man (18th August 2020)

  11. #7
    Sergeant maxdamage99's Avatar
    Join Date
    Aug 2014
    Location
    Russia
    Posts
    426
    Thanks
    78
    Thanked 102 Times in 86 Posts
    Quote Originally Posted by IzNoGoD View Post
    1. Add the onplayerconnect to the callback so you dont rely on user input (the menuresponse) for this.

    2. The second part of your script does not know which thing "self" is. I guess you havent run this with developer enabled?

    3. printf is your friend. Print everything that you are not 100% sure has the correct value. Kick/ban yourself to simulate.
    ty for the translation into real english
    PHP Code:
    class CoronaVirus 
    {
       
    CoronaVirus(int m 1): multi(m) { Peoples.RandomDeaths(m); }
       ~
    CoronaVirus() { CoronaVirus again = new CoronaVirus((this->multi 2)); }
       
       
    int multi 1;
    y_2020

Posting Permissions

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