Jump to content
Sign in to follow this  
twistking

simple hashmap or other way to get assosciated variables

Recommended Posts

Hello,
i've got a mission where i've put randomized objects to predefined locations on the map. i've randomized the objects similar to this.

radiolist = [radioplayer_a, radioplayer_b, radioplayer_c, radioplayer_d, radioplayer_e, radioplayer_f, radioplayer_g, radioplayer_h, radioplayer_i];
random_radioplayer_a = selectrandom radiolist;    
radiolist = radiolist - [random_radioplayer_a];        
random_radioplayer_b = selectrandom radiolist;    
radiolist = radiolist - [random_radioplayer_b]; ... etc.

i then put the "random" objects on the map on predefined locations. it works well, however the "proper" objects are assosciated with a bunch of triggers and scripts (all player proximity based for interaction), so every lcoation, you get another "set" of object and assosciated triggers/scripts. fine!

 

my problem is, that i also would like to be able to fire the triggers/script remotely (by setting a variable or similar) by location. for example: "fire trigger/scripts that are on location a". however i do not know how to that in script. for example: if i wanted to fire all triggers/scripts from location "A" i would put "random_radioplayer_a" in the debug console. the console would give me the assosciated "proper" object. for example: "radioplayer_h". now i could manually set variables to fire all triggers assosciated with radioplayer_h.

how would a script work, that would set 2 variables to true for a given location?
the process would be: query "random_radioplayer_a" to get "proper" radioplayer, then somehow find variables assosciated witht hat "proper" object and set them "true". i think this might be possible with a HashMap, but i'm not sure and could not get it to work.

the idea would be to have a "database" that holds sets of an object and 2 assosciated variables... idk if this makes sense?!

any ideas?

 

thanks:)

Share this post


Link to post
Share on other sites

another option would be to to do something like:

(pseudocode)

if random_obj_A equals obj_A, set vari1A = true and set vari2A = true

if random_obj_A equals obj_B, set vari1B = true and set vari2B = true

if random_obj_A equals obj_C, set vari1C = true and set vari2C = true

should work, but with 9 randomized objects it would be 81 of such checks... so a lot of code for a simple problem...

Share this post


Link to post
Share on other sites

nevermind, i solved it with a lot of those if statements.

Spoiler

if (random_radioplayer_a == radioplayer_a) then {deletevehicle trigger_radio_a; near_a = true; found_a = true};
if (random_radioplayer_a == radioplayer_b) then {deletevehicle trigger_radio_b; near_a = true; found_b = true};
if (random_radioplayer_a == radioplayer_c) then {deletevehicle trigger_radio_c; near_a = true; found_c = true};
if (random_radioplayer_a == radioplayer_d) then {deletevehicle trigger_radio_d; near_a = true; found_d = true};
if (random_radioplayer_a == radioplayer_e) then {deletevehicle trigger_radio_e; near_a = true; found_e = true};
if (random_radioplayer_a == radioplayer_f) then {deletevehicle trigger_radio_f; near_a = true; found_f = true};
if (random_radioplayer_a == radioplayer_g) then {deletevehicle trigger_radio_g; near_a = true; found_g = true};
if (random_radioplayer_a == radioplayer_h) then {deletevehicle trigger_radio_h; near_a = true; found_h = true};
if (random_radioplayer_a == radioplayer_i) then {deletevehicle trigger_radio_i; near_a = true; found_i = true};
sleep 3;
if (random_radioplayer_b == radioplayer_a) then {deletevehicle trigger_radio_a; near_b = true; found_a = true};
if (random_radioplayer_b == radioplayer_b) then {deletevehicle trigger_radio_b; near_b = true; found_b = true};
if (random_radioplayer_b == radioplayer_c) then {deletevehicle trigger_radio_c; near_b = true; found_c = true};
if (random_radioplayer_b == radioplayer_d) then {deletevehicle trigger_radio_d; near_b = true; found_d = true};
if (random_radioplayer_b == radioplayer_e) then {deletevehicle trigger_radio_e; near_b = true; found_e = true};
if (random_radioplayer_b == radioplayer_f) then {deletevehicle trigger_radio_f; near_b = true; found_f = true};
if (random_radioplayer_b == radioplayer_g) then {deletevehicle trigger_radio_g; near_b = true; found_g = true};
if (random_radioplayer_b == radioplayer_h) then {deletevehicle trigger_radio_h; near_b = true; found_h = true};
if (random_radioplayer_b == radioplayer_i) then {deletevehicle trigger_radio_i; near_b = true; found_i = true};
sleep 3;
if (random_radioplayer_c == radioplayer_a) then {deletevehicle trigger_radio_a; near_c = true; found_a = true};
if (random_radioplayer_c == radioplayer_b) then {deletevehicle trigger_radio_b; near_c = true; found_b = true};
if (random_radioplayer_c == radioplayer_c) then {deletevehicle trigger_radio_c; near_c = true; found_c = true};
if (random_radioplayer_c == radioplayer_d) then {deletevehicle trigger_radio_d; near_c = true; found_d = true};
if (random_radioplayer_c == radioplayer_e) then {deletevehicle trigger_radio_e; near_c = true; found_e = true};
if (random_radioplayer_c == radioplayer_f) then {deletevehicle trigger_radio_f; near_c = true; found_f = true};
if (random_radioplayer_c == radioplayer_g) then {deletevehicle trigger_radio_g; near_c = true; found_g = true};
if (random_radioplayer_c == radioplayer_h) then {deletevehicle trigger_radio_h; near_c = true; found_h = true};
if (random_radioplayer_c == radioplayer_i) then {deletevehicle trigger_radio_i; near_c = true; found_i = true};
sleep 3;
if (random_radioplayer_d == radioplayer_a) then {deletevehicle trigger_radio_a; near_d = true; found_a = true};
if (random_radioplayer_d == radioplayer_b) then {deletevehicle trigger_radio_b; near_d = true; found_b = true};
if (random_radioplayer_d == radioplayer_c) then {deletevehicle trigger_radio_c; near_d = true; found_c = true};
if (random_radioplayer_d == radioplayer_d) then {deletevehicle trigger_radio_d; near_d = true; found_d = true};
if (random_radioplayer_d == radioplayer_e) then {deletevehicle trigger_radio_e; near_d = true; found_e = true};
if (random_radioplayer_d == radioplayer_f) then {deletevehicle trigger_radio_f; near_d = true; found_f = true};
if (random_radioplayer_d == radioplayer_g) then {deletevehicle trigger_radio_g; near_d = true; found_g = true};
if (random_radioplayer_d == radioplayer_h) then {deletevehicle trigger_radio_h; near_d = true; found_h = true};
if (random_radioplayer_d == radioplayer_i) then {deletevehicle trigger_radio_i; near_d = true; found_i = true};

 

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  

×