Question / Help (Scripts/Codes)

Topic created · 5 Posts · 60 Views
  • I have a few questions ( all for offline / server owner use )

    • i was wondering if its currently possible to bind a function / dvar to controller input.

    • is it possible to live update scripts while in game? or do i have to restart the game each time for it to update.

    • is it possible teleport players? (have bots/players teleport to certain spots, like a teleport all clients to crosshair / person).
      EDIT: Found Qbots by quaK [https://forum.plutonium.pw/topic/1592/release-qbots]

    • is there any way to give perks? like have quickdraw pro while using overkill?

    Also, since im trying to learn all this. is there a Chaiscript 'variable' / 'code' (idk the word im looking for), list for mw3? it would make things a lot easier to understand.

    Any help is appreciated, thanks.

  • @toasty if you going to use qbots for knife lunges and what not on a public server your going to run into issues and when it comes to saving locations it saves everyone location to where you set and not seperate

  • im currently using it for private match, so i shouldn't have a problem. thanks for letting me know though.

  • To update scripts you just have to restart the map, even a simple fast_restart will do.
    For keybinds:

    def playerConnected(arguments) {
    	var player = arguments[0]
            var thing = "thing"
            //  player.notifyOnPlayerCommand(name, keybind);
            player.notifyOnPlayerCommand("actionslot6", "+actionslot 6")
            // other notifies are for example "spawned_player", "weapon_fired", "death", "killed_enemy"
            player.onNotify("actionslot6", fun[thing/* pass variables here*/](arguments){
                 // do whatever...
                 player.iPrintLn(thing)
            });
    }
    level.onNotify("connected", playerConnected);
    

    To teleport players, for example to yourself (you cannot tp them to where youre aiming unfortunately because the bulletTrace function that should be used for it doesn't work)

    def playerConnected(arguments) {
    	var player = arguments[0]
            player.notifyOnPlayerCommand("actionslot6", "+actionslot 6")
            player.onNotify("actionslot6", fun(arguments){
                for (var i = 0; i < 18; ++i) {
                        // Players are the first 18 entities so you can just use gsc.getEntByNum() to get a player with a given clientslot
                    var playerEnt = gsc.getEntByNum(i);
                    if (playerEnt.getGuid() != player.getGuid()) {
                        playerEnt.setOrigin(player.getOrigin())
                    }
            }
        });
    }
    level.onNotify("connected", playerConnected)
    
    

    To set perks

    // player.setperk(perk, true, true)
    player.setperk("specialty_scavenger", true, true)
    player.setperk("specialty_bulletaccuracy", true, true)
    player.setperk("specialty_fastreload", true, true)
    player.setperk("specialty_quickdraw", true, true)
    // Not sure if they all work at the same time
    

    You can also find the list of functions and other stuff at
    https://github.com/momo5502/open-iw5/blob/master/src/game/scripting/functions.cpp

  • @fed thank you so much. exactly what i needed.

Log in to reply