Jump to content
Sign in to follow this  
eagledude4

Undefined Variable in Expression issue

Recommended Posts

player is an object. You can't format an object into a variable. Instead of

_Sex = call compile format ["%1sex", player];

Try

_Sex = call compile format ["%1sex", vehicleVarName player];

Share this post


Link to post
Share on other sites

I've used "_Sex = call compile format ["%1sex", player];" for several applications without issue. I recently converted the below code from client base, to server base, and forgot to make the variables public

civ1sex = "male";
civ2sex = "male";
civ3sex = "male";
civ4sex = "male";
civ5sex = "male";
civ6sex = "male";
civ7sex = "male";
civ8sex = "male";
civ9sex = "male";
civ10sex = "male";
civ11sex = "male";
civ12sex = "male";
civ13sex = "male";
civ14sex = "male";
civ15sex = "male";
civ16sex = "male";
civ17sex = "male";
civ18sex = "male";
civ19sex = "male";
civ20sex = "male";
civ21sex = "male";
civ22sex = "male";
civ23sex = "male";
civ24sex = "male";
civ25sex = "male";
civ26sex = "male";
civ27sex = "male";
civ28sex = "male";
civ29sex = "male";
civ30sex = "male";
civ31sex = "male";
civ32sex = "male";

publicVariable "civ1sex";
publicVariable "civ2sex";
publicVariable "civ3sex";
publicVariable "civ4sex";
publicVariable "civ5sex";
publicVariable "civ6sex";
publicVariable "civ7sex";
publicVariable "civ8sex";
publicVariable "civ9sex";
publicVariable "civ10sex";
publicVariable "civ11sex";
publicVariable "civ12sex";
publicVariable "civ13sex";
publicVariable "civ14sex";
publicVariable "civ15sex";
publicVariable "civ16sex";
publicVariable "civ17sex";
publicVariable "civ18sex";
publicVariable "civ19sex";
publicVariable "civ20sex";
publicVariable "civ21sex";
publicVariable "civ22sex";
publicVariable "civ23sex";
publicVariable "civ24sex";
publicVariable "civ25sex";
publicVariable "civ26sex";
publicVariable "civ27sex";
publicVariable "civ28sex";
publicVariable "civ29sex";
publicVariable "civ30sex";
publicVariable "civ31sex";
publicVariable "civ32sex";


while {true} do {
civ1description = ["a brown jacket", "light gray pants"] call BIS_fnc_selectRandom;
civ2description = ["a brown jacket", "dark gray pants"] call BIS_fnc_selectRandom;
civ3description = ["a orange jacket", "purple pants"] call BIS_fnc_selectRandom;
civ4description = ["a burgandy jacket", "dark blue pants"] call BIS_fnc_selectRandom;
civ5description = ["a black suit", "red tie"] call BIS_fnc_selectRandom;
civ6description = ["a brown suit", "blue tie"] call BIS_fnc_selectRandom;
civ7description = ["a blue overcoat", "black pants"] call BIS_fnc_selectRandom;
civ8description = ["a blue jacket", "light blue pants", "a yellow hat"] call BIS_fnc_selectRandom;
civ9description = ["a brown Jacket", "brown pants", "an orange/red hat"] call BIS_fnc_selectRandom;
civ10description = ["a gray jacket", "blue track pants", "an orange hat"] call BIS_fnc_selectRandom;
civ11description = ["a brown jacket", "green pants", "blue/white hat"] call BIS_fnc_selectRandom;
civ12description = ["a dark blue jacket", "dark blue jeans"] call BIS_fnc_selectRandom;
civ13description = ["a light blue jacket", "light blue jeans"] call BIS_fnc_selectRandom;
civ14description = ["a light brown jacket", "black jeans"] call BIS_fnc_selectRandom;
civ15description = ["a blue jacket", "blue jeans"] call BIS_fnc_selectRandom;
civ16description = ["a white shirt", "light blue jeans", "a black beret"] call BIS_fnc_selectRandom;
civ17description = ["a light blue shirt", "tan pants", "a brown beret"] call BIS_fnc_selectRandom;
civ18description = ["a green shirt", "brown pants", "a burgandy beret"] call BIS_fnc_selectRandom;
civ19description = ["a yellow shirt", "blue pants", "an orange beret"] call BIS_fnc_selectRandom;
civ20description = ["a dark brown jacket", "dark blue pants", "a tan ushanka"] call BIS_fnc_selectRandom;
civ21description = ["a green jacket", "tan pants", "a yellow ushanka"] call BIS_fnc_selectRandom;
civ22description = ["a tan jacket", "camoflauge pants", "a dark brown ushanka"] call BIS_fnc_selectRandom;
civ23description = ["a black jacket", "green pants", "a tan ushanka"] call BIS_fnc_selectRandom;
civ24description = ["a light jean-vest", "white pants", "a yellow hat"] call BIS_fnc_selectRandom;
civ25description = ["a yellow checker vest", "orange pants", "a yellow decorative hat"] call BIS_fnc_selectRandom;
civ26description = ["a dark brown jacket", "dark gray pants"] call BIS_fnc_selectRandom;
civ27description = ["a tan vest", "blue pants", "a light blue hat"] call BIS_fnc_selectRandom;
civ28description = ["a green vest", "light blue pants", "a dark yellow/green hat"] call BIS_fnc_selectRandom;
civ29description = ["a brown jacket", "light gray pants"] call BIS_fnc_selectRandom;
civ30description = ["a brown jacket", "dark gray pants"] call BIS_fnc_selectRandom;
sleep 10;
};

publicVariable "civ1description";
publicVariable "civ2description";
publicVariable "civ3description";
publicVariable "civ4description";
publicVariable "civ5description";
publicVariable "civ6description";
publicVariable "civ7description";
publicVariable "civ8description";
publicVariable "civ9description";
publicVariable "civ10description";
publicVariable "civ11description";
publicVariable "civ12description";
publicVariable "civ13description";
publicVariable "civ14description";
publicVariable "civ15description";
publicVariable "civ16description";
publicVariable "civ17description";
publicVariable "civ18description";
publicVariable "civ19description";
publicVariable "civ20description";
publicVariable "civ21description";
publicVariable "civ22description";
publicVariable "civ23description";
publicVariable "civ24description";
publicVariable "civ25description";
publicVariable "civ26description";
publicVariable "civ27description";
publicVariable "civ28description";
publicVariable "civ29description";
publicVariable "civ30description";
publicVariable "civ31description";
publicVariable "civ32description";

I realize a lot of the code is redundant, but it works for now :P

Edited by eagledude4

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  

×