Jump to content
Sign in to follow this  
Michael Marsh

What's wrong with this respawn code?

Recommended Posts

Hello,

 

I am making a sector control game from scratch, and it works very well. I decided to add respawn points to capped sectors, which works when sector capped initially, but there is a problem with the removal when another team caps it.


 

if (respawnalpha != 0) then {respawnalpha call BIS_fnc_removeRespawnPosition};respawnalpha = [west,alpha,"ALPHA"] call BIS_fnc_addRespawnPosition};

if (respawnalpha != 0) then {respawnalpha call BIS_fnc_removeRespawnPosition};respawnalpha = [east,alpha,"ALPHA"] call BIS_fnc_addRespawnPosition};

The above code, checks to see if the spawn point exists, if not then it creates it (which works fine). If it is already created it then should remove it, this is the bit not working.

 

I get the error expected number, string, array not a file and the original respawn point remains.

 

If anyone could help I would be grateful.

Share this post


Link to post
Share on other sites
26 minutes ago, Michael Marsh said:

 


if (respawnalpha != 0) then {respawnalpha call BIS_fnc_removeRespawnPosition};respawnalpha = [west,alpha,"ALPHA"] call BIS_fnc_addRespawnPosition};

if (respawnalpha != 0) then {respawnalpha call BIS_fnc_removeRespawnPosition};respawnalpha = [east,alpha,"ALPHA"] call BIS_fnc_addRespawnPosition};

 

 

Try.

if (respawnalpha != 0) then {respawnalpha call BIS_fnc_removeRespawnPosition;respawnalpha = [west,alpha,"ALPHA"] call BIS_fnc_addRespawnPosition;};

if (respawnalpha != 0) then {respawnalpha call BIS_fnc_removeRespawnPosition;respawnalpha = [east,alpha,"ALPHA"] call BIS_fnc_addRespawnPosition;};

 

Share this post


Link to post
Share on other sites

That cannot work, since a respawn point has not yet been created until addrespawnposition has been run, so respawnalpha will always be 0.

Share this post


Link to post
Share on other sites
27 minutes ago, Michael Marsh said:

That cannot work, since a respawn point has not yet been created until addrespawnposition has been run, so respawnalpha will always be 0.

 

Try this.

if (!isNull respawnalpha && respawnalpha != 0) then {respawnalpha call BIS_fnc_removeRespawnPosition;} else {respawnalpha = [west,alpha,"ALPHA"] call BIS_fnc_addRespawnPosition;};

Or.

if (!isNull respawnalpha && respawnalpha != 0) then {respawnalpha call BIS_fnc_removeRespawnPosition;respawnalpha = [west,alpha,"ALPHA"] call BIS_fnc_addRespawnPosition;};

 

Share this post


Link to post
Share on other sites

Hi thanks for your help, I have been trying everything all day and finally managed to make it work with markers instead.

 

deleteMarker "respawn_east1"; _marker2 = createMarker ["respawn_west1", flagalpha];

 

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  

×