Jump to content
doomnet

How to ad another unit variable name in this respawn script ?

Recommended Posts

Hi, i use a teammate respawn dialogue works great but how to ad in this code another unit variable name?

 

Because this code is for default player, but i have some units with a variable name, thus the respawn dialogue does not work for them!

How to ad other units with variable names in this script below, if its even possible ?!!!

 

my custom unit variable name is CAS1, CAS2, CAS3 etc.....

 

here is the respawn code :

if (!hasInterface) exitWith {};
    params [["_includeAI", false], ["_handleRespawn", false]];
    BFD_includeAI = _includeAI;
    BFD_fnc_refreshList = {
        _grp = [];
        {if (alive _x && vehicle _x isEqualTo _x) then {_grp pushBack _x}} forEach units group player;
        if (!BFD_includeAI) then {{if (!isPlayer _x) then {_grp deleteAt _forEachIndex}} forEach _grp};
        _grp = _grp - [player];
        lbClear 3;
        {
            lbAdd [3, format ["%1 (Grid %2)", name _x, mapGridPosition _x]];
            lbSetData [3, _forEachIndex, netId _x];
        } forEach _grp;
    };
    BFD_fnc_deploy = {
        _unit = objectFromNetId (lbData [3, lbCurSel 3]);
        if (isNull _unit) exitWith {hint "No unit selected!"};
        closeDialog 0;
        switch (stance _unit) do {
            case "STAND" : {player switchMove "amovpercmstpsraswrfldnon"};
            case "CROUCH" : {player switchMove "amovpknlmstpsraswrfldnon"};
            case "PRONE" : {player switchMove "amovppnemstpsraswrfldnon"};
            default {};
        };
        player setPos (getPos _unit);
    };
    BFD_fnc_showDialog = {
        _bool = createDialog "BFD_Dialog";
        if (_bool) then {[] call BFD_fnc_refreshList};
    };
    if (_handleRespawn) then {player addEventHandler ["Respawn", {[] call BFD_fnc_showDialog}]};

I tried many things but i don't understand how this respawn code  works

thanks !

Share this post


Link to post
Share on other sites

Hi,

 

can someone help me with this one ?

Share this post


Link to post
Share on other sites

Its hard to understand what you want to add. If you are thinking about MP and other players,

you need to knew that  the player variable is local for every players.

Share this post


Link to post
Share on other sites

Its hard to understand what you want to add. If you are thinking about MP and other players,

you need to knew that  the player variable is local for every players.

Simply, this respawn script does not work on a unit with a variable name.

Some of the units use a variable name for another script purpose, i have to use that way because cannot touch the script.

So how can i make this script also work for a unit that use in his variable name field: CAS1 ?

I have 12 units which use this variable name:  CAS1, CAS2, CAS3, CAS4, CAS5, CAS6, CAS7, CAS8, CAS9, CAS10, CAS11, CAS12

Because the script above works only on units without variable names !

Share this post


Link to post
Share on other sites

ok stupid question, where are you executing this script from? Is it in an Event script or a unit Initialization?

 

Looking at all the 'player' variable being called I would recommend running it from the initplayerlocal.sqf and/or onPlayerRespawn.sqf if you plan on using it for multiplayer. NFI what your talking about with the CAS1 etc because the only variable mentioned is the player entity. 

 

Event Scripts can be found here. 

 

I think this is what you are after, you need to explain it better if its not.

Share this post


Link to post
Share on other sites

Wait, do you want to convert this code to work on unit names instead of on a player?

Share this post


Link to post
Share on other sites

Well sorry if its not clear enough for you guys but its simple:

 

I have no problem with this script posted above works great with default players placed in the editor

If i place a player in the editor and give it a variable name for example soldier1 the script dialogue does not spawn for that player

So my question is simple how to make this script working for every placed player in the editor with a variable name or not ?

 

the script spawns a dialogue on player respawn.

 

in description.ext

#include "BFD\dialog.hpp"

onPlayerRespawn.sqf or in initPlayerRespawn.sqf i dont remember im not at home today

[includeAI, handleRespawn] execVM "BFD\init.sqf";

Share this post


Link to post
Share on other sites

As far as I can see in that script it makes no difference if a player entity has a variable name or not. The script handles its functionality by the command player which returns the object for the players entity.

I think the reason for your problem is somewhat else but not the variable name.

 

EDIT:

Did you try a more complex variable name? Maybe CAS1 ... is used somwhere else and u override something u shouldnt.

Edited by sarogahtyp
  • Like 1

Share this post


Link to post
Share on other sites

well i dont know the script works not with a variable name placed player but works for the others placed players

i will have a look to check if it could be an other problem causing this

because as you said if the script handles its functionality by the command player which returns the object for the players entity,

then i have no clue.

 

thanks you for your response 

Share this post


Link to post
Share on other sites

Player == a real life person not an AI, If you have multiple people join your game it will execute for them on their PC also. You could try turning it into a function but i don't really see the point of this script because its spawning a dialog and the ai wont do shit with a dialog. 

DoStuff = {
//put this in your init.sqf
//Execute by putting this into the init for the units. "" this call DoStuff;
private ["_x", "_grp", "_unit", "_dude", "_includeAI", "_handleRespawn", "_forEachIndex"];
_dude = _this;

if (!hasInterface) exitWith {};
    params [["_includeAI", false], ["_handleRespawn", false]];
    BFD_includeAI = _includeAI;
    BFD_fnc_refreshList = {
        _grp = [];
        {if (alive _x && vehicle _x isEqualTo _x) then {_grp pushBack _x}} forEach units group _dude;
        if (!BFD_includeAI) then {{if (!isPlayer _x) then {_grp deleteAt _forEachIndex}} forEach _grp};
        _grp = _grp - [_dude];
        lbClear 3;
        {
            lbAdd [3, format ["%1 (Grid %2)", name _x, mapGridPosition _x]];
            lbSetData [3, _forEachIndex, netId _x];
        } forEach _grp;
    };
    BFD_fnc_deploy = {
        _unit = objectFromNetId (lbData [3, lbCurSel 3]);
        if (isNull _unit) exitWith {hint "No unit selected!"};
        closeDialog 0;
        switch (stance _unit) do {
            case "STAND" : {_dude switchMove "amovpercmstpsraswrfldnon"};
            case "CROUCH" : {_dude switchMove "amovpknlmstpsraswrfldnon"};
            case "PRONE" : {_dude switchMove "amovppnemstpsraswrfldnon"};
            default {};
        };
        _dude setPos (getPos _unit);
    };
    BFD_fnc_showDialog = {
        _bool = createDialog "BFD_Dialog";
        if (_bool) then {[] call BFD_fnc_refreshList};
    };
    if (_handleRespawn) then {_dude addEventHandler ["Respawn", {[] call BFD_fnc_showDialog}]};
};

Got a mission we can look at?

Share this post


Link to post
Share on other sites

Player == a real life person not an AI, If you have multiple people join your game it will execute for them on their PC also. You could try turning it into a function but i don't really see the point of this script because its spawning a dialog and the ai wont do shit with a dialog. 

DoStuff = {
//put this in your init.sqf
//Execute by putting this into the init for the units. "" this call DoStuff;
private ["_x", "_grp", "_unit", "_dude", "_includeAI", "_handleRespawn", "_forEachIndex"];
_dude = _this;

if (!hasInterface) exitWith {};
    params [["_includeAI", false], ["_handleRespawn", false]];
    BFD_includeAI = _includeAI;
    BFD_fnc_refreshList = {
        _grp = [];
        {if (alive _x && vehicle _x isEqualTo _x) then {_grp pushBack _x}} forEach units group _dude;
        if (!BFD_includeAI) then {{if (!isPlayer _x) then {_grp deleteAt _forEachIndex}} forEach _grp};
        _grp = _grp - [_dude];
        lbClear 3;
        {
            lbAdd [3, format ["%1 (Grid %2)", name _x, mapGridPosition _x]];
            lbSetData [3, _forEachIndex, netId _x];
        } forEach _grp;
    };
    BFD_fnc_deploy = {
        _unit = objectFromNetId (lbData [3, lbCurSel 3]);
        if (isNull _unit) exitWith {hint "No unit selected!"};
        closeDialog 0;
        switch (stance _unit) do {
            case "STAND" : {_dude switchMove "amovpercmstpsraswrfldnon"};
            case "CROUCH" : {_dude switchMove "amovpknlmstpsraswrfldnon"};
            case "PRONE" : {_dude switchMove "amovppnemstpsraswrfldnon"};
            default {};
        };
        _dude setPos (getPos _unit);
    };
    BFD_fnc_showDialog = {
        _bool = createDialog "BFD_Dialog";
        if (_bool) then {[] call BFD_fnc_refreshList};
    };
    if (_handleRespawn) then {_dude addEventHandler ["Respawn", {[] call BFD_fnc_showDialog}]};
};

Got a mission we can look at?

yes but you are talking about Ai, and i do not use Ai, or never talked about Ai, and have no Ai in my mission.

So i think you misunderstand this topic!!!

 

but anyway i will found another way to make this script working hopefully soon !

 

;)

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

×