Jump to content
Sign in to follow this  
falconx1

random spawn location "variable" causes an error

Recommended Posts

this has been haunting me all day yesterday, and i can't track down the source, ive tried sleep, making sure vars are being broadcast after they change etc and it still draws an error, but only around 50 percent of the time.

init.sqf

//---GetSelected StartLocation Param
GetStartLocation = (paramsArray select 9);
publicvariable "GetStartLocation";


if (isServer) then {ExecVM "server.sqf"};

waitUntil {player == player}; 
if (local player) then {ExecVM "client.sqf"};

server

if (GetStartLocation == 100) then{

// Pick Start Location /
RndmStartLoc = round ((random 11) + 0.5); // 
publicvariable "RndmStartLoc";
sleep 3;
switch (RndmStartLoc) do
{

Client.sqf

if (GetStartLocation  == 100) then 
{


   switch (RndmStartLoc) do
{

case 1:
{


 player setpos getmarkerpos "StartingLocation1"; 
	player setdir 180;
};

error log

Error in expression <tartLocation  == 100) then 
{


switch (RndmStartLoc) do
{

case 1:
{


player s>
 Error position: <RndmStartLoc) do
{

case 1:
{


player s>
 Error Undefined variable in expression: rndmstartloc

Edited by falconx1

Share this post


Link to post
Share on other sites

Error is right there:

Error Undefined variable in expression: rndmstartloc

Where do you define "rndmstartloc"?

Why are you doing the two ifs?

Just have the server figure out the start location and move the units there. No need to test if it's random, then figure it out, then pass out the variable just to get tested again. Also using publicVarible for that seems like it might have issues reading the wiki, especially with JIP.

Just have the server move the players before gamestart based on parameters and don't have clients move themselves at all.

Edited by kylania

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  

×