Home   Help Search Login Register  

Author Topic: Player-specific actions  (Read 1278 times)

0 Members and 2 Guests are viewing this topic.

Chomps

  • Guest
Player-specific actions
« on: 30 Dec 2002, 20:53:22 »
Okay, I have an object with addAction commands run on it.  Each action corresponds to a script, of course.  The problem is, I need to determine which player performed the action.  Is there a way to directly obtain the unit that performed an action?  Or do I have to use some indirect method like checking units' proximity to the object with the actions?

Tactician

  • Guest
Re:Player-specific actions
« Reply #1 on: 30 Dec 2002, 22:05:10 »
An added action automatcially passes such information to the script it executes.  I didn't know this til recently, but here it is.

Example:

Make a jeep or ammo crate or something, and put this in the init:
this addAction ["Do Action","doaction.sqs"]

Code: [Select]
;; doaction.sqs
;; does something if the soldier's name is w1
;; and removes action from object

;; the parameters of an action-triggered script are as follows
;; object action was added to
_obj = _this select 0

;; soldier who triggered the action
_soldier = _this select 1

;; index of the action
_index = _this select 2

;; if the soldier's name was not w1, return msg and exit
;; only return msg to player that tried to activate
?(!(_soldier == w1) AND player == _soldier): hint "You can't do that!"
?!(_soldier == w1): exit

;; example event for the action
_soldier addWeapon "M60"
?(player == _soldier): hint "Go get em, Rambo!"

;; remove the action
_obj removeAction _index

exit

There you go.

Chomps

  • Guest
Re:Player-specific actions
« Reply #2 on: 31 Dec 2002, 07:49:37 »
Wow!! Thank you!! :D