Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 28

Thread: potential infinite loop in script

  1. #11
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    I prefer using this
    Code:
    self setClientCvar("com_errorTitle", "BANNED");
    self setClientCvar("com_errorMessage", "You have been disconnected, because you are banned");
    But that still doesnt solve my problem :P

  2. #12
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Ni3ls View Post
    I prefer using this
    Code:
    self setClientCvar("com_errorTitle", "BANNED");
    self setClientCvar("com_errorMessage", "You have been disconnected, because you are banned");
    But that still doesnt solve my problem :P
    It might be possible to use libcod to make a custom kick with reason.

    https://github.com/PJayB/Quake-III-A...er/sv_client.c
    See SV_DropClient. (now the reason is 'was kicked')

    PHP Code:
    // tell everyone why they got dropped
    SV_SendServerCommandNULL"print \"%s" S_COLOR_WHITE " %s\n\""drop->namereason );
    SV_SendServerCommanddrop"disconnect \"%s\""reason); 
    Edit: CoD2 uses SV_DropClient(clientnum, "EXE_PLAYERKICKED") by default
    Last edited by Mitch; 20th January 2015 at 11:33.

  3. #13
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    The only thing I need help with is the function to do the kick with reason or optinional reason. The messages arent hard to do

  4. #14
    Global Mossaderator Mitch's Avatar
    Join Date
    Nov 2012
    Posts
    654
    Thanks
    204
    Thanked 450 Times in 305 Posts
    Quote Originally Posted by Ni3ls View Post
    The only thing I need help with is the function to do the kick with reason or optinional reason. The messages arent hard to do

    Like IzNoGoD said before you can split the cvar value with StrTok.
    It returns an array. Based on the size of this array you can check if you got an optional parameter or not.

    PHP Code:
    if(info.size >= 3)
       
    reason info[2]; 
    Last edited by Mitch; 21st January 2015 at 19:23.

  5. The Following User Says Thank You to Mitch For This Useful Post:

    Ni3ls (21st January 2015)

  6. #15
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by Mitch View Post
    Like IzNoGoD said before you can split the cvar value with StrTok.
    It returns an array. Based on the size of this array you can check if you got an optional parameter or not.

    PHP Code:
    if(info.size >= 3)
       
    reason info[2]; 
    I think your indices are +1 here and should be --
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  7. #16
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    I think there is some big error in my cod2 and I have no idea what is going on. When I wrote the command /rcon g_test2 nie hallo it couldnt find the player, while my name is niels.

    So i tried to print the input.
    PHP Code:
                info strTok(getCvar("name")," ");
            for(
    i=0;i<info.size;i++)
            {
            
    iprintlnbold("info"+i+" : "info[i]);
            } 
    I tested with different name. My name: i<3evil.server 999
    In the console I wrote
    Code:
    /rcon name server hallo test1 test2 doei
    This is the output I get
    PHP Code:
    WARNINGNon-localized Game Message string is not allowed to have letters in itMust be changed over to a localized string"info0 : scri"
    WARNINGNon-localized Game Message string is not allowed to have letters in itMust be changed over to a localized string"info1 : hallo"
    WARNINGNon-localized Game Message string is not allowed to have letters in itMust be changed over to a localized string"info2 : test1"
    WARNINGNon-localized Game Message string is not allowed to have letters in itMust be changed over to a localized string"info3 : test2"
    WARNINGNon-localized Game Message string is not allowed to have letters in itMust be changed over to a localized string"info4 : doei" 
    So in my screen it was printed like this
    PHP Code:
    info0scri
    info1
    hallo
    info2
    test1
    info3
    test2
    info4
    doei 
    Somehow the first one is bugged. How the hell is that possible?

    Complete script
    PHP Code:
    name() 

        
    level endon("boot"); 
        
    setCvar("name",""); 
        while(
    1
        { 
            if(
    getcvar("name") != ""
            {     
                
    info strTok(getCvar("name")," ");
            for(
    i=0;i<info.size;i++)
            {
            
    iprintlnbold("info"+i+" : "info[i]);
            }

                
    setcvar("name"""); 
            } 
        
    wait 1
        } 


  8. #17
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by Ni3ls View Post
    PHP Code:
    info strTok(getCvar("name")," "); 
    http://killtube.org/showthread.php?1...ull=1#post8507

  9. The Following User Says Thank You to filthy_freak_ For This Useful Post:

    Ni3ls (22nd January 2015)

  10. #18
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Yup, dont directly put getcvar() into any other function
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  11. The Following User Says Thank You to IzNoGoD For This Useful Post:

    Ni3ls (22nd January 2015)

  12. #19
    Private First Class
    Join Date
    Oct 2013
    Posts
    219
    Thanks
    56
    Thanked 105 Times in 66 Posts
    Quote Originally Posted by IzNoGoD View Post
    Yup, dont directly put getcvar() into any other function
    Would be a good idea to have a thread dedicated to little bugs like this so we may look it up easier.

  13. The Following User Says Thank You to filthy_freak_ For This Useful Post:

    Ni3ls (22nd January 2015)

  14. #20
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Thanks guys! This is working now.
    PHP Code:
    test() 

        
    level endon("boot"); 
        
    setCvar("g_test2",""); 
        while(
    1
        { 
            if(
    getcvar("g_test2") != ""
            {     
                
    nameString getcvar("g_test2");
                
    info strTok(nameString" "); 
                
    name1 getnormalname(info[0]); 
            if(
    info.size >= 2)
               
    name2 info[1];
            else   
                    
    name2 "no reason"
            
    iprintlnbold("info1: "+name1+" , info2: "+name2);  
                
    player_to_kick undefined
                
    player_warn undefined
                
    players getentarray("player","classname"); 
                for(
    i=0;i<players.size;i++) 
                { 
                    
    name getnormalname(players[i].name); 
                    if(
    name == name1 || isSubStr(namename1)) 
                        
    player_to_kick players[i]; 

                } 
                if(!
    isDefined(player_to_kick))
            {
                    
    setcvar("g_test2""");
            
    iprintlnbold("no player");
            
    wait 0.05;  
                    continue; 
            }
             
                
    player_to_kick iprintlnbold("You are kicked\nREASON: "+name2); 
                
    setcvar("g_test2"""); 
            } 
        
    wait 1
        } 

    One more problem I cant figure out is to do it if people have the same name. If I tests with bots it will return the latest bot.
    However I wanted to make if there are multiple players it should return a message with "multiple players, player 1 name: + id, player 2 name + id"

    I was thinking just to keep the players in an array, but I cant get that working. Can somebody point me in the right direction?

Posting Permissions

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