Jump to content
Sign in to follow this  
meatball

Need some assistance with variables

Recommended Posts

Let me explain what I'm trying to do and what I've tried and hopefully someone can help me out here.

I'm creating a mission (and still learning what the heck I'm doing) where the players need to run around and destroy some buildings. I'd like to keep a running tally of the buildings that are destroyed and present the number destroyed with hints and then when they get to a certain number of destroyed buildings, it fires off a trigger. So for example, let's say the missions need the players destroy both lighthouses on the island and once they get both, they'll finish the mission.

I know I need to set a global variable "lighthousedest = 0;" somewhere as the mission initializes, but I'm not sure where. I tried putting it in init.sqf, but I think this might reset it to 0 any any JIP connections.

Second, I tried to set a trigger with a bounding box on the lighthouses object, grouped the trigger to the lighthouse ID so it's activated on "Static Object" with the "Not Present" condition. Then I put "lighthousedest = lighthousedest + 1;hint format ["Lighthouses Destroyed: %1",lighthousedest];" in the On Act in the hope it would increment the total count from 0 to 1 on the first lighthouse going down and 1 - 2 on the 2nd. I also set a hint on my player init so I can check the lighthousedest value.

Finally, I added an End #1 trigger with the condition "lighthousedest = 2;".

There's more to it than that, but that's the basics. Problem I'm finding is that when I connect, the hint is popping up telling me 3 lighthouses are destroyed, and if I blow up the other lighthouses, I see the hint popup, but the variable isn't incrementing.

I dug around to try to find more info on global type variables and incrementing, but got lost in public, local and special variables. :) Anyone have any thoughts?

Share this post


Link to post
Share on other sites

can't really help much I don't know about jip, I do notice that the condition "lighthousedest = 2;". is wrong it should be lighthousedest == 2

Share this post


Link to post
Share on other sites

i use setvariable - remember to use True as the last parameter to update across all the clients and the server.

update: Put the "lighthousedest = 0;" in a trigger (on activation) maybe with the a and b axes set to 0 (can't recall), condition set to isserver and set to only run once. {this is where you can set up all of your variables to set up starting values.}

for the second trigger use what f2K Sel has said, to check a value you need to use ==

I have done a similar thing for a captive script where I had a running counter keep track of rescued hostages and even dead ones, when the total = 4 end mission. then depending on number alive it was win or fail.- Unfortunately I cannot find the mission now to check hat i have done, but it sounds like the same thing you want to do.

Edited by KevsnoTrev

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  

×