ChaiScript Question,
-
Hi All! This is my save/load script that a buddy wrote awhile back, he has since disappeared. This was written when chaiscript was still just recently released.
i remember him saying there was a reason i could not set save to justmeleebuttonpressed
and load tousebuttonpressed
. i was wondering if this is now possible.
also he said something about needed a 2 arg's to make this work. thats apparently why he added 2 arg's for each function.if anyone knows any way i can change this to just meleebuttonpressed and usebuttonpressed please let me know!!
and like always, i appreciate any help you can give. Thanks!!
global coordinates = Vector(); for(var i = 0; i < 18; ++i){ coordinates.push_back([0, 0, 0]); } global angles = Vector(); for(var i = 0; i < 18; ++i){ angles.push_back([0, 0, 0]); } level.onNotify("connected", fun(arguments) { var player = arguments[0]; manage_location(player); player.onNotify("grenade_fire", fun[player](arguments){ arguments[0].delete(); }); player.onNotify("spawned_player", fun[player](arguments){ refill_ammo(player); }); player.onNotify("weapon_fired", fun[player](arguments){ refill_ammo(player); }); }); def manage_location(player) { var ID = player.getEntityNumber(); player.onNotify("weapon_switch_started", fun[player, ID](arguments) { if(player.getStance() == "prone" && player.isOnGround() == 1){ var origin = player.getOrigin(); origin[2] += 800; player.setOrigin(origin); } }); player.onNotify("weapon_switch_started", fun[player, ID](arguments) { if(player.getStance() == "crouch" && player.isOnGround() == 1){ coordinates[ID] = player.getOrigin(); angles[ID] = player.getPlayerAngles(); player.iPrintLn("^3> ^7Your spawnpoint has been set^7!"); } }); player.onNotify("weapon_fired", fun[player, coordinates, angles, ID](arguments) { if(player.getStance() == "crouch" && coordinates[ID][0] != 0){ player.setOrigin(coordinates[ID]); player.setPlayerAngles(angles[ID]); } }); player.onNotify("weapon_fired", fun[player, coordinates, angles, ID](arguments) { if(player.getStance() == "prone"){ player.suicide(); } }); } def refill_ammo(player) { player.giveMaxAmmo(player.getCurrentWeapon()); } def onPlayerDamage(ePlayer, eInflictor, eAttacker, iDamage, iDflags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitloc, iTimeOffset) { if(sMeansOfDeath != "MOD_TRIGGER_HURT" && sMeansOfDeath != "MOD_SUICIDE" && sMeansOfDeath != "MOD_FALLING"){ iDamage = 0; } return iDamage; } add_callback_player_damage(onPlayerDamage);
-
player.meleeButtonPressed() == 1 player.adsButtonPressed() == 1 player.fragButtonPressed() == 1 player.secondaryOffhandButtonPressed() == 1 player.useButtonPressed() == 1
as far as I know, then these functions check for pressing at a given time, and for checking you need to use a timer
setInterval(fun[player]() { if (player.useButtonPressed() == 1) { /* magic */ } }, 10);
I think I understood the question correctly and was able to answer it