Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
OmniMax

Addaction\remove action

Recommended Posts

I searched on the forums for "removeAction", because the way I was removing the actions was by ID (mind you, each time you add a new action, the id increases by one) so this did not work. So I gave the action a name.

I have a jeep MG with the folowing:

name: benz

init: fire = benz addaction ["FIRE OUR SHIT!!!!","drop.sqs"]

and the script, drop.sqs...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

#main

benz removeaction fire

BOOOM = "CoC_ShkvalNucP" camcreate [(getpos player select 0), (getpos player select 1), (getpos player select 2) + 3]

dir=getDir(player)

BOOOM setdir dir

v0=200; v0 = v0/3.6;vBase = [sin(dir),cos(dir), 0];BOOOM setVelocity [(vBase select 0)*v0,(vBase select 1) * v0, 5]

~2.5

v0=400; v0 = v0/3.6;vBase = [sin(dir),cos(dir), 0];BOOOM setVelocity [(vBase select 0)*v0,(vBase select 1) * v0, 2]

~30

benz addaction fire

end

the error I get is for addaction fire, type NUMBER expected ARRAY.

I don't understand because this works for BOOOM (in terms of camCreating a new BOOOM everytime, setVelocity-ing it, et cetra)

Whats the problem here?

crazy_o.gifcrazy_o.gifcrazy_o.gif

Thanks in advance, people helping my question...

Share this post


Link to post
Share on other sites

Hm, I think it says exactly what you put.

It removes the action fine and everything. The nuclear torpedo gets spawned and launched, it just doesn't like adding the action again...

Thats an awful fast responce too, bloody hell, thanks.

Share this post


Link to post
Share on other sites

Your problem is that the "addaction" command returns a number. So the line:

fire = benz addaction ["FIRE OUR SHIT!!!!","drop.sqs"]

sets the variable "fire" equal to some number, like 0 or 1. Your last line should be:

fire = benz addaction ["FIRE OUR SHIT!!!!","drop.sqs"]

instead of

benz addaction fire

Another note: scripts that are called from an action are actually passed parameters in _this. You get the following values in an array, but I can't remember the exact order:

[unit who used the action, unit that the action was added to, action ID]

So the best way to do it would be to say something like:

(_this select 1) removeaction (this select 2)

...Insert code here.....

(_this select 1) addaction "fire.sqs"

This will avoid errors if you try to add more custom actions later, plus you can now add the same script/action to other units with no fiddling.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×