Jump to content
Sign in to follow this  
osu_apoc

Passing Parameters to Server Function via BIS_fnc_MP

Recommended Posts

So, I'm working on my own version of the airdrop script that Creampie had shown (on Wasteland forums), and I wanted to move the creation functions server-side (Creampie's version trigged BE filters).

I'm in the process of testing and figuring out how to use this BIS function further down the road.

So what I've done is add a player action to call a simple vehicle spawn script that spawns an ATV near the player.

However, I'm apparently not passing the player object to the server properly, as the server-side function does not receive the player object and returns an error about undefined variable.

Player Action Code (part of an addaction array in playeractions.sqf)

[format ["<img image='client\icons\playerMenu.paa' color='%1'/> <t color='%1'>[</t>Airdrop Test<t color='%1'>]</t>", "#FF0000"],{[[player],"APOC_srv_spawnVEH",false,false] call BIS_fnc_MP}, [], -100, false]

Server Function Code

private [_player, _playerPOS, _vehicleChoice, _choiceCost];

_player = _this select 0;
//_vehicleChoice = _this select 1;

_playerPOS = getPos _player;
_spawnPOS = [_playerPOS select 0, _playerPOS select 1 + 5, _playerPOS select 2 + 10];
_veh = "Quadbike_01_base_F" createVehicle _spawnPOS;

Server Error

Error in expression <ce\APOC_srv_spawnVEH.sqf"

private [_player, _playerPOS, _vehicleChoice, _ch>
 Error position: <_player, _playerPOS, _vehicleChoice, _ch>
 Error Undefined variable in expression: _player

So what am I hosing up here?

Share this post


Link to post
Share on other sites

Try:

[[(_this select 1)],"APOC_srv_spawnVEH",false,false] call BIS_fnc_MP;

Share this post


Link to post
Share on other sites

Ok, in that case, let's get the position of the player directly (in the action code), then just pass the position into your function:

{_playerPos = getPos player; [[_playerPos],"APOC_srv_spawnVEH",false,false] call BIS_fnc_MP;}

private [_player, _playerPOS, _vehicleChoice, _choiceCost];

_playerPOS = _this select 0;
//_vehicleChoice = _this select 1;

_spawnPOS = [_playerPOS select 0, _playerPOS select 1 + 5, _playerPOS select 2 + 10];
_veh = "Quadbike_01_base_F" createVehicle _spawnPOS;

Share this post


Link to post
Share on other sites

We both missed the fact that in my private statement, I did not use quotation marks on the variables... Thus the reason it was in a tizzy...

Thanks for the help looking at it. Now the next step is to see why it does not like adjusted _spawnPos. Returns a zero divisor error in the serverlog.

Share this post


Link to post
Share on other sites

You need to use parantheses in your _spawnPOS array:

_spawnPOS = [_playerPOS select 0, (_playerPOS select 1) + 5, (_playerPOS select 2) + 10];

Otherwise it would firstly add up the numbers and then try to select from _playerPOS which of course would fail as you'd try to select outside the array.

Share this post


Link to post
Share on other sites

Thanks! I figured that was the issue after I puzzled on it during the drive to the office. That's what I get for trying to bash some test code together without being thorough enough!

Thanks again for the help, folks!

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  

×