OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Acecool on 04 Mar 2005, 19:36:21

Title: AddAction - It adds the action to other units if you are too close - how to disa
Post by: Acecool on 04 Mar 2005, 19:36:21
ble?


Basically, _unit Addaction...

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

How can you turn that off?
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: nominesine on 04 Mar 2005, 19:57:02
You cannot turn it off. But there are ways to prevent other units from using it.
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: RujiK on 04 Mar 2005, 20:10:14
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.
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: Acecool on 04 Mar 2005, 22:05:56
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...
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: AK-Chester on 05 Mar 2005, 03:20:02
The action needs to be ADDED locally.
Code: [Select]
? alive _unit && local _unit && _unit == player : _unit addAction ["Blah","blah.sqs"]
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: Acecool on 05 Mar 2005, 03:42:44
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 :-/
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: Garcia on 05 Mar 2005, 12:35:16
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...
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: Acecool on 05 Mar 2005, 14:43:44
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..
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: AK-Chester on 05 Mar 2005, 15:43:11
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.  ;)
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: Acecool on 05 Mar 2005, 16:09:50
Would "player" point to the _unit?

Didnt work, still error in number expression or so...
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: Planck on 05 Mar 2005, 16:15:50
It might help a bit if you posted the exact error, including the '#'.


Planck
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: Acecool on 05 Mar 2005, 16:17:18
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]
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: Planck on 05 Mar 2005, 16:24:16
Despite what Ak-Chester said you are still using '/' instead of '\' for the paths.

you should try his alternate code as well.


Planck
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: AK-Chester on 05 Mar 2005, 16:28:57
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"]
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: Acecool on 05 Mar 2005, 16:54:17
ÃŽ 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"]
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: AK-Chester on 05 Mar 2005, 17:01:06
Well, your _unit_id is a string...  ::)
Title: Re:AddAction - It adds the action to other units if you are too close - how to d
Post by: Acecool on 05 Mar 2005, 21:52:10
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..)