Advertisement

Author Topic: AddAction - It adds the action to other units if you are too close - how to disa  (Read 1072 times)

0 Members and 1 Guest are viewing this topic.

Acecool

  • Guest
ble?


Basically, _unit Addaction...

If you get too close to that unit it gives you the action too..

How can you turn that off?

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
You cannot turn it off. But there are ways to prevent other units from using it.
OFPEC | Intel Depot
RETARDED Ooops... Retired!

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
well, I'm sure that was helpful...
One way to do it is all units are going to be able to see the action however you can make it so only one person can use it.
Like one way you could do this is a simple check, such as:
Code: [Select]
_unit = _this select 0
?(_unit != name_with_action):hint"Ha! you cant do that!";exit
;then put whatever you want to happen here.
I like your approach, lets see your departure.
Download the New Flashlight Script!

Acecool

  • Guest
This works:
? _this select 0 != _this select 1 : exit

But I am pretty sure I have seen it done somewhere...


Crime City 1.30 has it, cant find out how he did it though...
« Last Edit: 04 Mar 2005, 22:08:13 by Acecool »

AK-Chester

  • Guest
The action needs to be ADDED locally.
Code: [Select]
? alive _unit && local _unit && _unit == player : _unit addAction ["Blah","blah.sqs"]

Acecool

  • Guest
Cool, thanks :-)

I think its working :-)))))

---

Formatting question now :-)

call format [{? alive _unit && local _unit && _unit == player : %1 addAction ["Statistics","Scripts/Stats.sqs"]}, _unit_id]

Doesnt wotrk :-/
« Last Edit: 05 Mar 2005, 04:05:05 by Acecool »

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
The way I've done it is having 3 scripts

script 1:

Quote
? (unitname != player) : exit
#loop1
unitname removeaction actionname
#loop
? (something) : exit
?(unitname distance object1 <= 10): goto "start"
~2
goto "loop"

#start
actionname = unitname addaction ["Something","script2.sqs"]
#dcheck
? (something) : exit
?(unitname distance object1 > 10): goto "loop1"
~2
goto "dcheck"

script 2:

Quote
_unit = _this select 1
_unit removeaction spawnaction
something = true
publicvariable "something"
exit

script 3:

Quote
#loop
?(something): goto "start"
~5
goto "loop"

#start
~4
;what you want to happen here


exit

Script 1 first checks if the unit that you want to have the action is player on the computer, if not it exits. That way only the player you want to get the action gets it.
It then adds the action when the unit is within 10 m from a object (object1), and removes it when the unit is more than 10 m away. When the unit calls the action, he executes script2.sqs, which only removes the action and sets a variable to true and public variables it. You then have script3 that is running on every computer. It checks every 5 seconds if the variable is true, and when it is, it moves on in the script, where you add what you want to happen when the player uses the action ;)

That should work...worked for me ;)

Oh, and yes...you have to execute script1 and script2 in the init.sqs, and set the variable (something) to false in the init too...
« Last Edit: 05 Mar 2005, 12:41:52 by Garcia »

Acecool

  • Guest
Hi, thanks for that post, but its a loop that just keeps going and going or?

? alive _unit && local _unit && _unit == player : _unit addAction ["Blah","blah.sqs"] -- works perfectly..


Just when I use this for respawn:
call format [{? alive _unit && local _unit && _unit == player : %1 addAction ["Statistics","Scripts/Stats.sqs"]}, _unit_id]

It doesnt work, formatting error..

AK-Chester

  • Guest
call format [{? alive _unit && local _unit && _unit == player : %1 addAction ["Statistics","Scripts/Stats.sqs"]}, _unit_id]

It doesnt work, formatting error..

This might work (not tested):
Code: [Select]
call format [{? alive _unit && local _unit && _unit == player : %1 addAction ["Statistics","Scripts\Stats.sqs"]}, _unit_id]But... I don't really see the need for the call/formatting thingy here anyway. Instead, you should be able to do it like this:
Code: [Select]
? alive _unit && local _unit && _unit == player : player addAction ["Statistics","Scripts\Stats.sqs"]In any case... make sure you use \ instead of / for path names.  ;)
« Last Edit: 05 Mar 2005, 15:43:29 by AK-Chester »

Acecool

  • Guest
Would "player" point to the _unit?

Didnt work, still error in number expression or so...

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
It might help a bit if you posted the exact error, including the '#'.


Planck
I know a little about a lot, and a lot about a little.

Acecool

  • Guest
Error, invalid number in expression - is all I see

call format [{? alive _unit && local _unit && _unit == player : %1 addAction ["Statistics","Scripts/Player/Stats.sqs"]}, _unit_id]

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Despite what Ak-Chester said you are still using '/' instead of '\' for the paths.

you should try his alternate code as well.


Planck
I know a little about a lot, and a lot about a little.

AK-Chester

  • Guest
Would "player" point to the _unit?
Yup, since this only adds the action to a player unit, and only if _unit == player. So, in this case, it makes no difference if you add the action to "player" or "_unit" - they're the same here.
Code: [Select]
? alive _unit && local _unit && _unit == player : player addAction ["Statistics","Scripts\Stats.sqs"]
« Last Edit: 05 Mar 2005, 16:29:24 by AK-Chester »

Acecool

  • Guest
ÃŽ tried that..

With the alternate code...

? alive _unit_id && local _unit_id && _unit_id == player : player addAction ["Statistics","Scripts\Stats.sqs"] - Error expected object - returned string...


#############


_unit = _this select 0

? _unit == p1 : _unit_id = "p1"
? _unit == p2 : _unit_id = "p2"
? _unit == p3 : _unit_id = "p3"
? _unit == p4 : _unit_id = "p4"
? _unit == p5 : _unit_id = "p5"
? _unit == c1 : _unit_id = "c1"
? _unit == c2 : _unit_id = "c2"
? _unit == c3 : _unit_id = "c3"
? _unit == c4 : _unit_id = "c4"
? _unit == c5 : _unit_id = "c5"
? _unit == c6 : _unit_id = "c6"
? _unit == c7 : _unit_id = "c7"
? _unit == c8 : _unit_id = "c8"
? _unit == c9 : _unit_id = "c9"
? _unit == c10 : _unit_id = "c10"

_unit removealleventhandlers "Killed"
_unit removealleventhandlers "Fired"

_msg = Format["%1 you died and will respawn in 1 Minute!", name _unit]
_unit groupchat _msg

~61
deletevehicle _unit
call format [{removeallweapons %1}, _unit_id]
? alive _unit_id && local _unit_id && _unit_id == player : player addAction ["Statistics","Scripts\Stats.sqs"]

AK-Chester

  • Guest
Well, your _unit_id is a string...  ::)

Acecool

  • Guest
Works here:
? alive _unit && local _unit && _unit == player : _unit addAction ["Statistics","Scripts/Player/Stats.sqs"]

Not _unit_id, I know, but I need to get it to work (Respawn script, Cant add to _unit as that is the dead body..)