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

    jammer312 Bison Rider Tester

    Messages:
    46
    Code:
    ks.events.on('playerChat', function(player, message, time){
        if(message.indexOf('<F') != -1){
            if(message.indexOf('>') != -1){
                playerString = message.slice(message.indexOf('<F') + 2,message.indexOf('>'))
                log(playerString)
                playertofreeze = ks.server.getPlayerByName(playerString)
                if(player.getData().points != -1){
                    playertofreeze.freeze(10000)
                    ks.server.message("Player " + player.getName() + " casts freezing spell on player " + player_to_freeze.getName() + " .");
    }
    else
    {
    ks.server.message("You need few more mana points")
    }
    }
    }
    });
    error:

    Code:
    /home/grigoriy/Kscript/temp/shamanmod.js:78
    playertofreeze.freeze(10000)
                  ^
    TypeError: Cannot call method 'freeze' of null
        at EventEmitter.<anonymous> (/home/grigoriy/Kscript/temp/shamanmod.js:78:20)
        at EventEmitter.emit (events.js:115:20)
        at TcprWrapper.parser.parseData (/home/grigoriy/Kscript/data/kscript_tcpr_wrapper.js:332:24)
        at Socket.TcprWrapper.rcon.startInterval (/home/grigoriy/Kscript/data/kscript_tcpr_wrapper.js:100:23)
        at Socket.EventEmitter.emit (events.js:88:17)
        at TCP.onread (net.js:392:31)
    if(player.getData().points != -1) is for testing purposes, l will change it later
     
  2. master4523

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

    Messages:
    378
    Your script worked for me, but I had to replace player_to_freeze.getName() by playertofreeze.getName()
    Also you should add if (playertofreeze != null) to check if they player exists.
     
    Domis likes this.
  3. Mazey

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

    Messages:
    1,914
    kaizokuroof and master4523 like this.
  4. Zer0Striker

    Zer0Striker Shipwright

    Messages:
    139
  5. Mazey

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

    Messages:
    1,914
    Google for 'debian on virtual box' and look here https://wiki.kag2d.com/wiki/Server#Linux_Install for installing the server
    </br>--- merged: Mar 31, 2013 11:01 AM ---</br>
    A slap command
    PHP:
    ks.chat.createCommand('!slap', function(playermessagetime)
        {
        var 
    args message.split(' ');
        if (!
    args[1]) return;
        var 
    target ks.server.getPlayerByName(args[1]);
        if (
    target == null) return;
        
    Slaps = [ "fishbot!""penis!""flower!""warhammer!"" and heavy, black box!""speaker!" ]
        var 
    slaps Slaps[Math.floor(Math.random()*Slaps.length)]
        
    ks.server.messageplayer.getName() + ' slaps ' target.getName() + ' with a large ' slaps );
        });
    You do
    Code:
    !slap Mazey
    And it sais
    Code:
    * Mazey slaps Mazey with a large xxx
    xxx is fishbot! or penis! or flower! or warhammer! or and heavy, black box! or speaker!
     
    SlyStalker and Ruleral like this.
  6. Good work Mazey. Keep up the good work.

    I will be making some video tutorials and upgrading the documentation so that it will be more easier for everyone to code and underastastand.
     
  7. Zer0Striker

    Zer0Striker Shipwright

    Messages:
    139
    Where do I type the commands it says in the wiki?
     
  8. Mazey

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

    Messages:
    1,914
    left control + left alt + F1
    write:
    su -
    fill in you password, after fill in:
    apt-get install screen
    when you're done with that:
    cd /home/YourUserName/
    after, install kag linux like on the wiki:
    wget blablabla
    To download, after:
    tar blablabla
    (too lazy to write full)
    After press:
    left alt * F7
    Go to your user map (you're smart enough to find it.
    Make ready your server and start the command prompt again.
    write cd /home/yourusername/kag[TAB] (tab will finish it for you)
    write:
    screen ./KAGdedi
    Your server is running, press control A+D to go out of 'screen' and if you ever want to shut down server write:
    screen -ls
    You'll see something like 'number.pt.yourUserName', then do:
    screen -x number (the number screen -ls gave you)
    Now you're in your server, write ctrl + C and the process stops.
    Want to turn server up again? Repeat from:
    cd /home/yourusername/kag[TAB]
     
    Zer0Striker likes this.
  9. Zer0Striker

    Zer0Striker Shipwright

    Messages:
    139
    Wow linux is so complicated, thanks for the help though.
     
  10. Mazey

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

    Messages:
    1,914
    Linux is easier than windows, but windows users don't use command prompt so often
     
  11. miniu

    miniu Haxor

    Messages:
    765
  12. Miniu:

    Make sure you've got the required TCP ports open for KScript to communicate to KAG with (port 50301, sometimes port 50311).
     
  13. miniu

    miniu Haxor

    Messages:
    765
    I think , they are opened.
     
  14. Mazey

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

    Messages:
    1,914
    Also sure the server is running on linux and the configs are good in kscript_config.cfg ?
     
  15. There is something wrong in your confg.
    Either ip, port or rcon password are wrong.
    Or your server has sv_tcpr set to 0, or you haven't restarted your server after you set it to 1.
    And yeah, that port which tcpr uses for communication has to be opened / exposed.
     
  16. miniu

    miniu Haxor

    Messages:
    765
    sv_tcpr - i not can find it in my dedicated_autoconfig , i dont know why . I have to write it then ?In kscript config i writed ip from hamachi.
     
  17. Mazey

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

    Messages:
    1,914
     
  18. I've been thinking a long time about creating extension + mod to enable SMS donations.
    In Estonia, we have this company called Fortumo, but they have global service.

    Basically what they are offering is SMS API which allows people to create SMS services and automate the response.
    This service is very popular amongs Counter-Strike community. Server admins are selling VIP / Admin privileges / Reservation slots automatically. So when someone sens SMS that costs for example 5 euros, gets his service within seconds.
    This is great way for server hosters (who are doing it for free) to get some money to covert the costs of the server.

    This will of course would create a situation where people would start creating servers with sole purpose: Money. But this is generally a good thing because players would only be interested in buying "reservation slots (forexample)" in high quality servers. So even if server is hosted only to earn money, it is kept as high-quality server.

    This ended up being much more difficult task to accomplish than i had anticipated so i am asking, do you guys think it would be worth to create SMS extension + mods?

    Eg: You could sell reservation slots for your server for 5 euros per sms. Players would get their service immediatly and everyone are happy. (Or some uber-overpowered class premissions...but who would play in a server where one player can slaughter a whole team.)
     
  19. miniu

    miniu Haxor

    Messages:
    765
    runing on windows
     
  20. Mazey

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

    Messages:
    1,914
    If it's running on windows kscript is not possible for you.
     
    miniu likes this.
Mods: Downburst, Mazey