Jump to content
Sign in to follow this  
ryansoper

Which player called Action?

Recommended Posts

Hi guys,

In a script I'm writing i have 6 players named 'player1' through to 'player6'.

In some cases the player will be able to call a script though an action listerner, but I need to be able to find out whihc player called the script so I can set the appropriate variables. Any Ideas?

I hope that mad sense, i'm a little tired, so probably prone to mistakes.

Thanks,

Ryan

Share this post


Link to post
Share on other sites

I could be wrong, but try:

switch (player) do 

                                 {

                             case player1: {hint "player1 used the action"};
                             case player2: {hint "player2 used the action"};
                             case player3: {hint "player3 used the action"};
                             case player4: {hint "player4 used the action"};
                             case player5: {hint "player5 used the action"};
                             case player6: {hint "player6 used the action"};

                                 }

Share this post


Link to post
Share on other sites

AddAction.

---------- Post added at 03:33 PM ---------- Previous post was at 03:32 PM ----------

I could be wrong, but try:

switch (player) do 

                                 {

                             case player1: {hint "player1 used the action"};
                             case player2: {hint "player2 used the action"};
                             case player3: {hint "player3 used the action"};
                             case player4: {hint "player4 used the action"};
                             case player5: {hint "player5 used the action"};
                             case player6: {hint "player6 used the action"};

                                 }

Hmm, This looks like it could work actually, let me give it a try.

---------- Post added at 04:52 PM ---------- Previous post was at 03:33 PM ----------

Right, maybe I am doing something wrong, but basically, I have 6 player slots. Their unit names being 'player1', 'player2', 'player3', 'player4', 'player5', 'player6', these each have a money variable assigned to them in the init file. When the player wants to rent a vehicle (Using the action Menu through AddAction on the vehicle in question) I need to be able to detect which unit has called the action so I can deduct the relevant cash amount and give that player the ability to lock/unlock the vehicle.

Thanks Guys.

Share this post


Link to post
Share on other sites

Why would you want to know who called the action? player will always be the caller. Action script will not execute for everyone, just for somebody who called the action, which means player.

Share this post


Link to post
Share on other sites

If you look at the documentation for addAction

http://community.bistudio.com/wiki/addAction

Look at the section where the array is passed to the called script.

The second item in the passed array is the caller or object who exeicuted the addAction.

To refrence this caller, in your script just assign it to a varaible:

_callingunit = _this select 1;

Share this post


Link to post
Share on other sites

Ok, so the way I've assigned my variables is correct if I want to modify them at rental stage?

Share this post


Link to post
Share on other sites
Ok, so the way I've assigned my variables is correct if I want to modify them at rental stage?

I don't know, why don't you post your actual script so we can help you better.

Sumatra is right in a sense, your hard coding stuff, when you don't have to. You. Could write a much more genaric version just by refrencing the player

object.

Please post your script so we can see exactly what your trying to do and we can help more.

Share this post


Link to post
Share on other sites

Put the following in your init.sqf:

"YOUR_PVEH" addPublicVariableEventHandler {hintSilent format ["%1",((_this select 1) select 0)]};

Put the following in script executed by the addaction:

_caller = _this select 0;
hintSilent format ["%1",name _caller];
YOUR_PVEH = [name _caller]; publicvariable "YOUR_PVEH";

Share this post


Link to post
Share on other sites

Since my problem is somewhat related to this.

I have a Rainbow Six'y mission I'm in the process of creating and I'm trying to make this script so that the person who kills an enemy, he initiates the chat (Tango Down, Got Him, etc..).

Currently, the script shows the local player on the client side show that he himself said it, even though someone else killed/triggered the script.

Any help would be greatly appreciated! :)

waitUntil {!(isNil "bis_fnc_init")};
_responses = [["GotHim","Got Him!"],["Contact","Contact!"],["TangoDown","Tango Down!"],["BingoBingo","Bingo Bingo!"],["ThreatNeutralized","Threat Neutralized!"]];
_indx = floor random 3;
playsound ((_responses select _indx) select 0);

Share this post


Link to post
Share on other sites

Hey sem, I'm just curious, do you actually have some RS .ogg sounds? or is it just text? I love the old rainbow sixes.

Share this post


Link to post
Share on other sites

I actually have the .ogg sounds haha. I still have my Rogue Spear+Urban Ops CD :) Don't know what happened to my original R6 though. :(

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  

×