1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

KScript - Server Scripting for KAG Classic

Discussion in 'Community Dev Corner' started by master4523, Mar 26, 2013.

Mods: Downburst, Mazey
  1. PainGiver

    PainGiver Arsonist

    Messages:
    78
    100 Percent, I got the ip/port set in the dedicated_autoconfig.gm and the kscript_config.cfg.
     
  2. Mazey

    Mazey Haxor Global Moderator Forum Moderator Staff Alumni Donator Official Server Admin

    Messages:
    1,914
    I had this too, reinstall kscript?
    EDIT: You host paid, press tab in your server and check if the ip and port are same from there
     
  3. PainGiver

    PainGiver Arsonist

    Messages:
    78
    I deleted and uploaded like three times already, and I tabbed and double checked the ip; it's the same. Anyways, here is my config for kscript:

    Code:
    {
        "server":
        {
            "ip": "66.225.195.138",
            "port": 50301,
            "rconPassword": "*********"
        }
    }
     
  4. Mazey

    Mazey Haxor Global Moderator Forum Moderator Staff Alumni Donator Official Server Admin

    Messages:
    1,914
    Go to Online -> Connect to. write 66.225.195.138:50301 and join. click home and write /rcon /login ******
    If all of that works, I have no idea. How are you running /kscript.sh? Just write it in the directory?
     
  5. master4523

    master4523 Masterful KAG Guard Global Moderator Tester
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    378
    Try to use "127.0.0.1" instead of your IP
     
  6. PainGiver

    PainGiver Arsonist

    Messages:
    78

    Yeah I was able to connect like that, and I am running /kscript in putty like: ./kscript.sh in the same directory.
    </br>--- merged: Apr 7, 2013 11:36 AM ---</br>
    Changed the ip to 127.0.0.1, still getting the same error. What does it mean when it says "Socked closed"?
     
  7. SnIcKeRs

    SnIcKeRs Bison Rider

    Messages:
    148
    Show your dedicated_autoconfig.gm file.
    Is sv_rconpassword from dedicated_autoconfig.gm = rconPassword from kscript_config.cfg?
     
  8. PainGiver

    PainGiver Arsonist

    Messages:
    78
    Yup
     
  9. FranticIch

    FranticIch Let me be your tank... Donator

    Messages:
    234
    I´m stuck with
    PHP:
    player.getData();
    I want to make a litle voting system, but I´m able to vote over and over again...
    PHP:
    ks.chat.createCommand('!Vote', function(playermessage) {
        
    player.data.wVoted false//This part works. If I set this to true, the vote fails(if the next one isn´t true)
       
        
    if(player.data.wVoted == false){ //This part works. If I set this to true, the vote fails
                
    curWVotes ++;
                
    player.data.wVote true//But this won´t work. The vote works and works and works... Or what do I need to put here?
                
    ks.server.message(player.getName() + ' voted! ' '(' curWVotes '/' minVotes ')');
               
                if(
    curWVotes minVotes){
                    
    succes true;
                    
    ks.server.message('The vote was succesfull!');
                }
        }
        else{
            
    ks.server.message('You can´t vote again...');
        }
    });
     
  10. master4523

    master4523 Masterful KAG Guard Global Moderator Tester
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    378
    You wrote wVote but it should be wVoted ;)
     
  11. FranticIch

    FranticIch Let me be your tank... Donator

    Messages:
    234
    oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooh.... aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah... FUCK! :p Thanks.
    </br>--- merged: Apr 7, 2013 2:01 PM ---</br>
    But it still won´t work.:QQ:
     
  12. master4523

    master4523 Masterful KAG Guard Global Moderator Tester
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    378
    What your code does is when a playing says !Vote it sets wVoted to false then it check if wVoted is equal to false (which will always be true)
    What I usually do is initialize the variables only if they don't exist. If they do then it means that the player has already voted at least one time.
    PHP:
    ks.chat.createCommand('!Vote', function(playermessage) {
        if (
    typeof(player.data.wVoted) === 'undefined') {
            
    player.data.wVoted false//This part works. If I set this to true, the vote fails(if the next one isn´t true)
        
    }
     
        if(
    player.data.wVoted == false){ //This part works. If I set this to true, the vote fails
                
    curWVotes ++;
                
    player.data.wVote true//But this won´t work. The vote works and works and works... Or what do I need to put here?
                
    ks.server.message(player.getName() + ' voted! ' '(' curWVotes '/' minVotes ')');
             
                if(
    curWVotes minVotes){
                    
    succes true;
                    
    ks.server.message('The vote was succesfull!');
                }
        }
        else{
            
    ks.server.message('You can´t vote again...');
        }
    });
     
  13. FranticIch

    FranticIch Let me be your tank... Donator

    Messages:
    234
    Thanks :)
    </br>--- merged: Apr 10, 2013 4:18 PM ---</br>
    Ok, I´m stuck, again.
    I want to freeze people, after killing while
    PHP:
    ware == false
    , but I can´t get it to work. I did a dumb mistake, but I can´t find it.

    PHP:
    ks.events.on('playerKilled', function(attackermessage) { //does this need player? and is it 'playerKilled' or "playerKilled"? In your scripts its the 2. but the docs say ''.
        
    if ( war == false) {
            if (
    typeof(attacker.data.rk) === 'undefined') {
                    
    attacker.data.rk 0;
            }
        
    attacker.freeze(10 1000);
        
    ks.server.message(attacker.name ' has been frozen for Randomkilling (RKing).' '( ' attacker.data.RK ' / 8) before getting kicked');
        
    attacker.data.rk ++;
     
       
            if(
    attacker.data.rk 7){ playerKick();}
        }
    });
     
  14. Mazey

    Mazey Haxor Global Moderator Forum Moderator Staff Alumni Donator Official Server Admin

    Messages:
    1,914
    Not much time, but rather this:
    PHP:
    var war false
    if( war === false //Changed the while
    ks.events.on('playerKilled', function(victimattackerdeath_type)
        {
        if (
    typeof(attacker.data.rk) === 'undefined')
            {
            
    attacker.data.rk 0;
            
    attacker.freeze(10*1000);
            
    ks.server.message(attacker.getName() + ' has been frozen for Randomkilling (RKing). ( ' attacker.data.RK ' / 8) before getting kicked');
            
    attacker.data.rk ++;
            if(
    attacker.data.rk 7)
                {
                
    attacker.kick();
                }
            }
        }};
     
  15. master4523

    master4523 Masterful KAG Guard Global Moderator Tester
    1. PumpkinStars - [Pk#] - Inactive

    Messages:
    378
    First, never use "while" (as Mazey wrote). It will block the main thread and will prevent the other scripts from executing.
    There's a few mistakes with your script:
    - The arguments for playerKilled are: (victim, attacker, death_type). You can't change their order nor omit one.
    - You must check if attacker is not null. If there's no attacker then it will be null (ie. the victim kills himself or uses cyanide)
    - In ks.server.message, you wrote attacker.data.RK, with RK in uppercase. According to your script it should be rk, in lowercase.
    PHP:
    ks.events.on('playerKilled', function(victimattackertype) {
        if (
    attacker == null) return; // Stops the script 
        
    if (war == false) {
            if (
    typeof(attacker.data.rk) === 'undefined') {
                    
    attacker.data.rk 0;
            }
            
    attacker.freeze(10 1000);
            
    ks.server.message(attacker.name ' has been frozen for Randomkilling (RKing).' '( ' attacker.data.rk ' / 8) before getting kicked');
            
    attacker.data.rk ++;
            if(
    attacker.data.rk 7) {
                
    playerKick();
            }
        }
    });
    You can use either double quotes (") or single quotes ('). Both will work in Javascript.
     
  16. Mazey

    Mazey Haxor Global Moderator Forum Moderator Staff Alumni Donator Official Server Admin

    Messages:
    1,914
    Changed :QQ:
     
  17. FranticIch

    FranticIch Let me be your tank... Donator

    Messages:
    234
    Thanks, but it still does not work for me. I got no errors, but weather the messages appear or the players get frozen.
     
  18. Mazey

    Mazey Haxor Global Moderator Forum Moderator Staff Alumni Donator Official Server Admin

    Messages:
    1,914
    attacker.name should be attacker.getName() and playerKick() should be attacker.kick()
     
  19. FranticIch

    FranticIch Let me be your tank... Donator

    Messages:
    234
    Ok, I will try, thanks, but in Masters 'Killstreaks mod'
    PHP:
    attacker.name 
    works.
     
  20. Mazey

    Mazey Haxor Global Moderator Forum Moderator Staff Alumni Donator Official Server Admin

    Messages:
    1,914
    he probably made a var for it, let me check
     
Mods: Downburst, Mazey