Jump to content

craptakular

BIS_fnc_respawnTickets, how to limit to 3 lives per player

Recommended Posts

When I am the only person testing this, it works perfectly, I cannot spawn after 3 lives. As soon as a friend joins it all went horribly wrong.

My friend team killed me several times and his ticket went to -1 and he spawned 6 times in total.

What am I doing wrong? Here are my files:

init.sqf:

[player,3,false] call BIS_fnc_respawnTickets;

description.ext:

respawnTemplatesWest[] = {"Base","Wave","Tickets","Counter"};

onPlayerRespawn.sqf:

private["_myProfileName","_playerTickets"];
_playerTickets = [player,nil,true] call BIS_fnc_respawnTickets;
_myProfileName = profileName;
if (side player == west) then {hint format ["%2 has %1 of 3 lives left.",_playerTickets, _myProfileName];};

https://community.bistudio.com/wiki/BIS_fnc_respawnTickets

I tried to follow this thread but like most things from BIS, the documentation is pretty poor :(

Can anyone help?

Share this post


Link to post
Share on other sites

your issue is you put BIS_fnc_respawnTickets in your init sqf. every player that joins gets this init sqf. so when you start playing alone then all is good, when another player joins the init.sqf fires again and guess what, it adds another 3 respawns. basically you are adding the limit every time someone joins. very simple solution though...

still in your init.sqf

if (isServer) then {[player,3,false] call BIS_fnc_respawnTickets;};

this way only the server sets the respawn limit and no one else will when they join.

Edited by Nimrod_Z

Share this post


Link to post
Share on other sites

Thanks for posting, I have tried that line and it makes no difference, we have way more than 3 lives, it only seems to work if a single person is on the server.

I wonder if it is another function that BIS has introduced that is totally broken?

Share this post


Link to post
Share on other sites

if you have 2 players on server then you should both get 3 lives. 3 were added when you joined and tickets reset again to 3 when another person joins. I know the "isServer" command works so if you still have way more then 3 lives using it in init sqf the way I have it posted it sounds like you are adding more respawn tickets somewhere else as well. only the server should add tickets as its broadcast thru the function itselt.

Edited by Nimrod_Z
changed wording

Share this post


Link to post
Share on other sites
  Nimrod_Z said:
if you have 2 players on server then you should both get 6 total lives. 3 were added when you joined and 3 more when another joined and so on and so on. I know the "isServer" command works so if you still have way more then 3 lives using it in init sqf the way I have it posted it sounds like you are adding more respawn tickets somewhere else as well. only the server should add tickets as its broadcast thru the function itselt.

The only line I have related to tickets is the line you mentioned in the init.sqf, I think the function is broken. I'm going to change it to 3 tickets for west and see what happens.

Share this post


Link to post
Share on other sites
  craptakular said:
The only line I have related to tickets is the line you mentioned in the init.sqf, I think the function is broken. I'm going to change it to 3 tickets for west and see what happens.

sorry I changed the wording about adding tickets while you were responding. but in your original post it doesn't state that you have that function wrapped in the isServer check that's why I was making sure it was that way. and the function could very well be broken as well, certainly wouldn't be the first time :)

Share this post


Link to post
Share on other sites

Create this file initPlayerServer.sqf:

[_this select 0, 3] call BIS_fnc_respawnTickets;

Share this post


Link to post
Share on other sites

Could someone please reccomend a mission file with a working ticket system?  I have spent the last 2 hours trying to get it to work with no success at all.  There are times I wish BIS would just pump out simple mission samples that have all of this implemented (the entire respawn template thing being one of them).  I am not a coder, or scripter... I am a scavenger.  Not proud of it but it's a fact. Guidance appreciated.

Share this post


Link to post
Share on other sites

Any progress with BIS_fnc_respawnTickets ? still broken? I would like to see example for 3 lives only too.

Share this post


Link to post
Share on other sites

Basic idea: Player have 3 lives. If player run out of tickets (tickets == 0), he will be forced into SpectatorMode.

 

Problems:

1. Player have unlimited respawns

2. Player can't be forced to spectator mode ( MenuPosition overlay SpectatorMode )

 

Mission example: tickets_test.VR.zip

 

Description.ext

//Respawn
respawn = "BASE";
respawnDelay = 5;
respawnTemplates[] = {"MenuPosition", "Tickets", "Counter"};
respawnOnStart = -1;

init.sqf

if (isServer) then 
{
    { [_x, 3, true] call BIS_fnc_respawnTickets; } forEach (playableUnits + switchableUnits);
};

if (hasInterface) then 
{ 
    _player = [] spawn 
    { 
        waitUntil {sleep 0.1; !isNull player};
        player addEventHandler ["HandleRating", {0}];
        
        player addEventHandler ["Killed", 
        {
            params ["_unit", "_killer"];
            _tickets = [_unit] call BIS_fnc_respawnTickets;
            systemChat format ["Killed | _unit: %1 | _tickets: %2", _unit, _tickets];
            if (_tickets < 1) then 
            {
                ["Initialize", [_unit, [], true]] call BIS_fnc_EGSpectator;
            };
        }];
        
        player addEventHandler ["Respawn", 
        {
            params ["_unit", "_corpse"];
            _tickets = [_unit] call BIS_fnc_respawnTickets;
            systemChat format ["Respawn | _unit: %1 | _tickets: %2", _unit, _tickets];
            
            ["Terminate"] call BIS_fnc_EGSpectator;        
        }];
    };
};

@moricky any suggestions ?
 

 

Share this post


Link to post
Share on other sites

I tried something like this before, worth a test if you have time.

multiplayer option in attribute section of the editor settings:

custom respawn, check tickets, check spectator, check menu position 

 

description.ext

//Respawn
respawnOnStart = -1;

class Params {


   class numTicket
	{
		title = "Respawn Ticket";
		values[] = {20,40,60,80};
		texts[] = {"20 Tickets","40 Tickets","60 Tickets","80 Tickets"};
		default = 40;
	};
	
};

initserver.sqf

ticket = paramsArray select 0;

[player, ticket] call BIS_fnc_respawnTickets;

 

Share this post


Link to post
Share on other sites
  On 12/31/2016 at 7:47 AM, Persian MO said:

multiplayer option in attribute section of the editor settings:

custom respawn, check tickets, check spectator, check menu position 

 

This should be editable via description.ext as template (#Respawn_Templates)

 

Description.ext

respawnTemplates[] = {"Tickets", "Spectator", "MenuPosition"};

 

  On 12/31/2016 at 7:47 AM, Persian MO said:

initserver.sqf

ticket = paramsArray select 0;
[player, ticket] call BIS_fnc_respawnTickets;

 

 

So basicly 

if (isServer) then 
{
    [player, 3] call BIS_fnc_respawnTickets;
};

EDIT: this does NOT work either

 

Share this post


Link to post
Share on other sites
  On 12/31/2016 at 8:23 AM, M1ke_SK said:

 

 

So basicly 

if (isServer) then 
{
    [player, 3] call BIS_fnc_respawnTickets;
};

EDIT: this does NOT work either

 

 

if (isServer)... and [player,3]... only works on ServerClients, not on Clients or Dedicated.

Share this post


Link to post
Share on other sites
  On 12/31/2016 at 12:32 PM, Lucullus said:

 

if (isServer)... and [player,3]... only works on ServerClients, not on Clients or Dedicated.

 

I know that, but Persian MO suggested this way. not me.

 

I politely advised that this is not working.

 

@Lucullus: do you have solution?

Share this post


Link to post
Share on other sites

from my last mission:

description.ext

// Respawn
respawn = 3;
respawnButton = 1;
respawnDelay = 6;
respawnDialog = 0;
respawnTemplates[] = {"MenuPosition","Tickets","Spectator"};
respawnOnStart = -1; 

initPlayerLocal.sqf

[player, 11] call BIS_fnc_respawnTickets;

and don't forget the respawn-markers

 

 

Share this post


Link to post
Share on other sites
  On 12/31/2016 at 1:37 PM, Lucullus said:

 

[player, 11] call BIS_fnc_respawnTickets;

 

 

This works

[player, 3] call BIS_fnc_respawnTickets;

but this doesnt

[player, 3, true] call BIS_fnc_respawnTickets;

 

Share this post


Link to post
Share on other sites

Second problem is, when I run out of tickets I am stuck at MenuPosition with respawn DISABLED and 0 tickets and my character is not in Spectator automaticaly.

 

Here is code:

    player addEventHandler ["Killed", 
    {
        params ["_unit", "_killer"];
        _tickets = [_unit] call BIS_fnc_respawnTickets;
        if (_tickets < 1) then 
        {
            ["Initialize", [_unit, [], true]] call BIS_fnc_EGSpectator;
        };
    }];

Share this post


Link to post
Share on other sites

Maybe there is a way to detect if player is in MenuPosition screen and force player to spectator if respawn is disabled.

Share this post


Link to post
Share on other sites

Yes, but i think there's no way, because the player is dead forever.

Solution, when ticket reached 1 instead of 0?

Share this post


Link to post
Share on other sites
  On 12/31/2016 at 3:01 PM, Lucullus said:

Yes, but i think there's no way, because the player is dead forever.

Solution, when ticket reached 1 instead of 0?

 

Even when you be killed and have 1 ticket left, it will force you to MenuPosition screen and overlay enabled Spectator mode

Share this post


Link to post
Share on other sites

Testing a little bit.

in description.ext

respawnTemplates[] = {"MenuPosition","Tickets","Spectator"};

The Spectator-Mode is available after tickets = 0.

In Spectator press <m> for Map and left Mousebutton for Camera on Map.

Another touch on <m> opens the Freecam.

 

Edit:

Only an idea, quick and dirty...

initPlayerLocal.sqf

[player, 3] call BIS_fnc_respawnTickets;

Luc_Spectate_after_Tickets_end =
{	_wait = getMissionConfigValue "respawnDelay";
	waitUntil {[player] call BIS_fnc_respawnTickets < 1};
	sleep _wait + 5;
	["close"] call BIS_fnc_showRespawnMenu;
	sleep 0.2;
	["Initialize", [player, [], true]] call BIS_fnc_EGSpectator;
};
[] spawn Luc_Spectate_after_Tickets_end;

 

Edited by Lucullus
  • Like 1

Share this post


Link to post
Share on other sites

I was looking for this gem! Thanks.

["close"] call BIS_fnc_showRespawnMenu;

Working like charm with Killed EventHandler.

  • Like 1

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

×