Havoc302

Adding an addAction

25 posts in this topic

Posted (edited)

Hey everyone, I've done some reading around the forums and the question has been posted several times about how to do addActions but I'm sorry they weren't really clear enough for me. If I want to call a custom script and have the addActions work what exactly do I need to do in CfgExileCustomCode? Any help would be much appreciated.

 

I did try adding a class and calling the script, that did nothing.

Edited by Havoc302

Share this post


Link to post
Share on other sites

Posted (edited)

depends on where you want to add a action.

if you want to add actions on created vehicles or similar it's enough to enter these class into exile interaction menu config

if you want to go for terrain objects(like wrecks,trash etc.) you gonna need to find a workaround(exile uses cursorTarget, but they are only visible via cursorObject)

 

so if you want to add to all cars some action like scrap

go in config.cpp for class CfgInteractionMenus

search class Car

now go at the end and find

Spoiler

class DrainFuel: ExileAbstractAction
            {
                title = "Drain Fuel";
                condition = "call ExileClient_object_vehicle_interaction_show";
                action = "_this call ExileClient_object_vehicle_drain";
            };

and you could add now here your scrapping after the above lines

Spoiler

class Scrap: ExileAbstractAction
            {
                title = "Scrap";
                condition = "((locked ExileClientInteractionObject) != 2) && !ExilePlayerInSafezone";
                action = "execVM 'custom\interactions\scrap.sqf';";
            };

so this action will now be added if a player is looking at a car and the condition is true(in this case it should not be locked and also not in safezone), if you press the action (scrap in this case) ingame , the scrap.sqf will be executed

Edited by hieve

Share this post


Link to post
Share on other sites
Advertisement

I actually wanted to add an action to the player. Not dependant on an object or location.

Share this post


Link to post
Share on other sites

Posted (edited)

1 hour ago, Havoc302 said:

So nobody can tell me how to do it on a player?

ah this should be the easiest one, but in this case you need to check if the player already has the action attached and moreover remove it after using it(done properly if the action has been triggered)

so quick and dirty it should be something like this..

Spoiler

you could write a file called action.sqf***

while{true} do{                     // dont think this should be used, it will check really often this script!

getact = 0;                 // initializing that no action is appearing right now

if(getact == 1 )then{}else{           // we need to check here that there is not already a action attached

action = player addaction ["Some Action", hint str "I have action !"];   // add the action, look wiki for further info with addaction

getact = 1} // set getact 1 , so there are not 1k actions appearing

};

wrap this file up with your initplayerlocal.sqf , so call it with something like [] execVM "action.sqf;

 

***see the following code pls as some type of pseudo code, it has not been tested exactly

if you now want to check for objects in distance etc. you can use many different ways like nearObjects for example

 

 

still not 100% sure what exactly you want, maybe give some more information which action should be attached to which player(the player itself or another player that is next to you??) and what should be done

Edited by hieve

Share this post


Link to post
Share on other sites

Yeah so I have some addAction scripts already to be done on player. As below, that's not the issue, the issue is Exile requires them to be defined somewhere to work. There is nowhere I can see to define an action on self, there's one for on objects or other players but not on self.

Spoiler

initPIU.sqf

 

if (ExileClientPlayerIsBambi = true) then {
    _weaponoption = player addAction ["<t color='#FF0000'>Take out the gun in your undies!</t>", "custom\PIU\doPIU.sqf"];
    sleep 5;
    };
diag_log ["PIU Loaded"];

 
Spoiler

doPIU.sqf

 

player playActionNow "MountSide";
sleep 15
player addWeaponSecondary "hgun_Pistol_heavy_02_F";
player addMagazine "6Rnd_45ACP_Cylinder";
player addMagazine "6Rnd_45ACP_Cylinder";

 

I'll worry about removing the action if I can get this to at least work, removing it's easy.

Share this post


Link to post
Share on other sites

If you look at the CfgInteractionMenus where it's supposed to be defined before it can be used it only has class Car, class Air, class Safe, class Laptop, class SupplyBox, class Construction, class Container, class Flag, class Boat, class Bikes, class Player and class ATM, that class Player though is for other players you're looking at, not you, so no idea where to define it.

Share this post


Link to post
Share on other sites

Posted (edited)

23 minutes ago, Havoc302 said:

Yeah so I have some addAction scripts already to be done on player. As below, that's not the issue, the issue is Exile requires them to be defined somewhere to work. There is nowhere I can see to define an action on self, there's one for on objects or other players but not on self.

  Hide contents

initPIU.sqf

 

if (ExileClientPlayerIsBambi = true) then {
    _weaponoption = player addAction ["<t color='#FF0000'>Take out the gun in your undies!</t>", "custom\PIU\doPIU.sqf"];
    sleep 5;
    };
diag_log ["PIU Loaded"];

 
  Hide contents

doPIU.sqf

 

player playActionNow "MountSide";
sleep 15
player addWeaponSecondary "hgun_Pistol_heavy_02_F";
player addMagazine "6Rnd_45ACP_Cylinder";
player addMagazine "6Rnd_45ACP_Cylinder";

 

I'll worry about removing the action if I can get this to at least work, removing it's easy.

still not sure what you want todo?  you can holster weapons via pressing the key 5 , and then there is some permanent action menu available.

also if you want to execute some script use some caller like execVM or call and then your script path

 

i had problems using Private variables with addactions , i would recommend using here weaponaction instead of _weaponaction,if you also handover the id number(which is defined in weaponaction after that ) via execVM/call to the executing script you can just say removeAction weaponaction

Edited by hieve

Share this post


Link to post
Share on other sites

If you put an addAction in a script and call it from the init.sqf that addAction won't show up unless it's defined in Exile's config.... I want to know how to define that...

I even made a script which was simply:

 

if (true) then {

player addAction ["tits",""];

}; 

Just to test it, that addAction should have been there in the scroll wheel all the time and done nothing, instead it didn't show up at all.

Share this post


Link to post
Share on other sites

Posted (edited)

11 minutes ago, Havoc302 said:

If you look at the CfgInteractionMenus where it's supposed to be defined before it can be used it only has class Car, class Air, class Safe, class Laptop, class SupplyBox, class Construction, class Container, class Flag, class Boat, class Bikes, class Player and class ATM, that class Player though is for other players you're looking at, not you, so no idea where to define it.

hm ok yeah, not sure if this is possible..

you could try using class player , but I think this will cast it also if another player is near...

 

edit: sry for double post  - had reply and edit open at the same time <.<

Edited by hieve

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.