Jump to content

Recommended Posts

So I have made "script" for myself that I put in the Player Init.

 

This only executes once. But I want it to execute every time I spawn/respawn (so everytime the player starts existing).

 

The script works great if I put it in the Init of the Player. But i wanted to make a .sqf file I could call/execute so I wont have to put everything in every Player. But the scipt is not working/compiling.

 

The code I put in to the Init:

varPlayer=this;

spawnPos=getPos varPlayer;

telePos=getPos varPlayer;

[varPlayer, 3] call BIS_fnc_traceBullets;

varPlayer addAction["<t color='#59b300'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal;}];
varPlayer addAction["<t color='#d9006c'>Go to Spawn</t>", {varPlayer setPos spawnPos;}];
varPlayer addAction["<t color='#bfff00'>Teleport</t>", {varPlayer setPos telePos;}];
varPlayer addAction["<t color='#4cffff'>set Teleport</t>", {telePos=getPos varPlayer;}];
varPlayer addAction["<t color='#0080ff'>Teleport with Map</t>", "teleport.sqf"];



 

The code I put in to the .sqf:

_spawnPos=getPos _this;

_telePos=getPos _this;

[_this, 3] call BIS_fnc_traceBullets;

_this addAction["<t color='#59b300'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal;}];
_this addAction["<t color='#d9006c'>Go to Spawn</t>", {_this setPos _spawnPos;}];
_this addAction["<t color='#bfff00'>Teleport</t>", {_this setPos _telePos;}];
_this addAction["<t color='#4cffff'>set Teleport</t>", {telePos=getPos _this;}];
_this addAction["<t color='#0080ff'>Teleport with Map</t>", "teleport.sqf"];

 

How I called it in the Init:

_nul = []execVM "myFunction.sqf";

 

It wont run, but why?


 

So for short. What i need help with is:

  • finding the problem with the sqf
  • executing the sqf every time the player starts existing

 

 

Thx for reading my crap and I hope you can help me. :)

Share this post


Link to post
Share on other sites

This seems to make the script execute:

 

_spawnPos=getPos player; 
_telePos=getPos player; 
 
[player, 3] call BIS_fnc_traceBullets; 
 
player addAction["<t color='#59b300'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal;}]; 
player addAction["<t color='#d9006c'>Go to Spawn</t>", {player setPos _spawnPos;}]; 
player addAction["<t color='#bfff00'>Teleport</t>", {player setPos _telePos;}]; 
player addAction["<t color='#4cffff'>set Teleport</t>", {telePos=getPos player;}];
player addAction["<t color='#0080ff'>Teleport with Map</t>", "teleport.sqf"];

 

But the teleportation position is not saved in a var. And the traceBullet function doesnt seem to work either.

 

Share this post


Link to post
Share on other sites

Got the fix for teleportation by making local vars.

 

_spawnPos=getPos player; 
_telePos=getPos player; 

profileNamespace setVariable ["spawnPos",_spawnPos];
profileNamespace setVariable ["telePos",_telePos];
saveProfileNamespace;

 
[player, 3] call BIS_fnc_traceBullets;
 
player addAction["<t color='#59b300'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal;}]; 
player addAction["<t color='#d9006c'>Go to Spawn</t>", {_temp = profileNamespace getVariable "spawnPos"; player setPos _temp;}]; 
player addAction["<t color='#bfff00'>Teleport</t>", {_temp = profileNamespace getVariable "telePos"; player setPos _temp;}]; 
player addAction["<t color='#4cffff'>set Teleport</t>", {telePos=getPos player;}];
player addAction["<t color='#0080ff'>Teleport with Map</t>", "teleport.sqf"];

 

The execution at respawn was dealt with after making a "onPlayerRespawn.sqf" with:

_nul = []execVM "myFunction.sqf";

 

The only thing not working is the bullet traces after respawn.

Share this post


Link to post
Share on other sites

Dont go using profileNamespace as a tempory store for variables like that. AddAction already has a parameter for passing in variables to the actions code OR you can save the variables on the player object using setVariable.

_spawnPos = getPosATL player; 

//Store teleport position on player object
player setVariable[ "telePos", getPosATL player ]; 

//Example passing in variable to actions code
player addAction["<t color='#d9006c'>Go to Spawn</t>", {player setPosATL ( _this select 3 );},_spawnPos];

//Retreive value from player object
player addAction["<t color='#bfff00'>Teleport</t>", {player setPosATL ( player getVariable "telePos" );}]; 
player addAction["<t color='#4cffff'>set Teleport</t>", {player setVariable[ "telePos", getPosATL player ];}];

 

Share this post


Link to post
Share on other sites
20 minutes ago, Larrow said:

Dont go using profileNamespace as a tempory store for variables like that. AddAction already has a parameter for passing in variables to the actions code OR you can save the variables on the player object using setVariable.


_spawnPos = getPosATL player; 

//Store teleport position on player object
player setVariable[ "telePos", getPosATL player ]; 

//Example passing in variable to actions code
player addAction["<t color='#d9006c'>Go to Spawn</t>", {player setPosATL ( _this select 3 );},_spawnPos];

//Retreive value from player object
player addAction["<t color='#bfff00'>Teleport</t>", {player setPosATL ( player getVariable "telePos" );}]; 
player addAction["<t color='#4cffff'>set Teleport</t>", {player setVariable[ "telePos", getPosATL player ];}];

 

 

 

Thx. Got it working. :)

 

player setVariable["spawnPos", getPos player]; 
player setVariable["telePos", getPos player]; 
 
 
player addAction["<t color='#59b300'>Arsenal</t>", {["Open",true] spawn BIS_fnc_arsenal;}]; 
player addAction["<t color='#d9006c'>Go to Spawn</t>", {player setPos ( player getVariable "spawnPos" );}]; 
player addAction["<t color='#bfff00'>Teleport</t>", {player setPos ( player getVariable "telePos" );}]; 
player addAction["<t color='#4cffff'>set Teleport</t>", {player setVariable["telePos", getPos player];}];
player addAction["<t color='#0080ff'>Teleport with Map</t>", "teleport.sqf"];

//Enable Bullet Trace
player addAction["<t color='#0080ff'>Enable Bullet Trace</t>", {[player, 3] spawn BIS_fnc_traceBullets;}];
//Disable Bullet Trace (will reduce paths by 1 with every time used)
player addAction["<t color='#0080ff'>Disable Bullet Trace</t>", {BIS_tracedShooter = nil;}];

 

The only thing not working correctly is the Bullet Traces. As i read "Can only be used on one shooter in a single instance.". So I added the function to disable them when you die.

But each time you die and/or disable it, it decreases the Bullet Traces by 1.

Do you have an idea on how to go about that problem?

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

×