Jump to content
Sign in to follow this  
Theodor Schmidt

counting problems

Recommended Posts

Hello, Im rather new to scripting, so this problem may this very easy to you.

Im am making a mission where you have to get supply trucks to a certain point. However I want a message to pop up when a truck arrives. the pop up I want is "Supply trucks through X" with X being the amount of trucks through - which will go up by one each time a truck arrives. The script I am currently using for this is.

cnt = {alive _x} count allUnits; hint format ["Supply trucks through", cnt]

is is probably very obviously wrong to you guys.

The two problems I have are

1. the message is staying up constantly, I only want to see it when a unit arrives, not all the time.

2. The message isn't counting up. It always says "Supply trucks through".

As I have said before, this is probably a noob mistake, but this is my first proper foray into scripting.

p.s I also have another thread asking about a defence module work-around. If you guys are able to can you help me on that as well.

http://forums.bistudio.com/showthread.php?190670-Defence-module-mission-help

Share this post


Link to post
Share on other sites

Ummm (*scratches head*), firstly....

Your syntax on the format command is a bit off:

hint format ["Supply trucks through %1", cnt];

And secondly....ummm...why are you counting all alive units for this?, because that certainly won't give you your desired result, and where and how exactly are you using the code?

Edited by JShock

Share this post


Link to post
Share on other sites

Ah, yes, my noobyness is showing. It is within a trigger which which far south of all the action, the only units which should reach the place are the supply trucks, and from my research and meager understanding, I thought the count all alive units would count all the alive units within the trigger circle.

Here is the picture, with the truck just outside.

http://steamcommunity.com/sharedfiles/filedetails/?id=422197375

Share this post


Link to post
Share on other sites

Yea, no the allUnits command returns all units on the map at any given point in time, you will want to use "thisList" instead.

Share this post


Link to post
Share on other sites

Thanks.

Now the final problem is, the hint doesn't pop up when a new truck arrives and Im not sure if I will need extra code here or if I have made a mistake?

Share this post


Link to post
Share on other sites

This is my simple script which works fine ... edit it as you need if you want. :)

//Simple convoy distance script by LUKI 

uCount = {alive _x} count [color=#333333]thisList[/color]; 
hint format ["Supply trucks through %1, uCount];


waitUntil{(truck distance player)<10}; // if the truck will be closer than 10 meters from player, then the hint shows
hint "Trucks arrived!";

Share this post


Link to post
Share on other sites

thanks for the script, but I dont quite understand how it will help me in my situation (probably due to my lack of knowledge). What I am trying to achieve is a constant spawning of trucks north of Zargabad, which will then head down through Zargabad, through Yarum - where the player is located - and all the way do to the trigger, where when it reaches the trigger the hint "Supply trucks through: 1" pops up. Then when the second one arrives "Supply trucks through 2". However currently when the mission starts it comes up with "supply trucks through 0" then when the first supply truck arrives it doesn't pop up again. I've tested it with 1 truck already inside(to see if it was a problem with them of the trigger at mission start, and with 2 inside and it comes up with "Supply trucks through 1" and "Supply trucks through 2" respectively.

Share this post


Link to post
Share on other sites

Okay, I understand what you want to do now ... put trigger conditions for each trigger which you have on the map in towns (for the example put for each trigger to "Condition" field: townXReached [where X is the number of the town - 1,2,3,4 ...]). Now, you must create a script for hint and distance control (below). Then run that script in your init.sqf script for the example. So script can looks like:

//Simple convoy distance script by LUKI 

town1Reached = FALSE;
town2Reached = FALSE;
uCount = {alive _x} count thisList; 

[] spawn {
waitUntil{town1Reached}; // if the truck reach town 1, the hint shows
hint format ["Supply trucks through %1, uCount];
};

[] spawn {
waitUntil{town2Reached}; // if the truck reach town 2, the hint shows
hint format ["Supply trucks through %1, uCount];
};

... and copy and paste these three lines for each trigger which you have on the map.

Hope you understand me now. :rolleyes:

Edited by [CSLA]LUKI
typo

Share this post


Link to post
Share on other sites

Awesome, I understand you now. However the editor doesn't seem to. I put the entire code into the init.sqf file. then proceeded to put the 3 lines you mentioned into triggers. However the problem is, whenever I click ok it comes up with a blank error message.

Like this.

http://steamcommunity.com/sharedfiles/filedetails/?id=422627222

Share this post


Link to post
Share on other sites

Yes, wrong entry. You need to put all code to the init.sqf ;)

Your work is only to put the each trigger's condition, and script all do alone. :)

EDIT:

LUKI;2917808']... and copy and paste these three lines for each trigger which you have on the map.

Hope you understand me now. :rolleyes:

Sorry' date=' I tought to put these lines into init.sqf and via these 3 lines you define a condition for game/engine ... so if you create a trigger in the editor, you need to give it this condition which i meant in my previous post and define it into script (init.sqf). For the example: If you create a fifth trigger with condition town5Reached, you need to define it into script as i wrote a template = you'll edit only waitUntil condition. ;)

Edited by [CSLA]LUKI

Share this post


Link to post
Share on other sites

My brain is fried :(.

Is it ok if you place it all in the mission, and I will dissect later.

Edited by TWking

Share this post


Link to post
Share on other sites

I said ... it's only simple mission with scripts, no convoy isn't here. There're only scripts and triggers which you must convert to your mission. :)

And if it doesn't work, then I don't know what to do. :d:

Edited by [CSLA]LUKI

Share this post


Link to post
Share on other sites

Ok, with your original trigger (the one in the picture) do the following:

Blufor, Present, Repeatdly

Condition:

this && {alive _x} count thisList > 0

OnAct:

[format ["Supply Trucks through: %1",(glb_truckCount + 1)],"hint",true,false,false] call BIS_fnc_MP;

And make a file named initServer.sqf, and declare and define the "glb_truckCount" variable like so:

glb_truckCount = 0;

---------- Post added at 10:18 ---------- Previous post was at 10:15 ----------

LUKI;2917973']I said ... it's only simple mission with scripts' date=' no convoy isn't here. There're only scripts and triggers which you must convert to your mission. :)

And if it doesn't work, then I don't know what to do. :d:[/quote']

Actually I looked back at my original first post, and realized I missed a double quote in the format command, which you happened to copy/paste over within your code as well, so that may be the cause of the issue. :rolleyes:

Share this post


Link to post
Share on other sites

Ok I've placed everything into the correct places in the trigger (albeit, it is a new trigger since I had already deleted the previous one). I also defined the variable in initServer.sqf, however it only ever wants to go up to 1.

Plus the missed double quote isnt the problem since I had placed it in manually.

Edited by TWking

Share this post


Link to post
Share on other sites

Sorry wow, long ass day....

Replace onAct with:

glb_truckCount = glb_truckCount + 1; [format ["Supply Trucks through: %1",glb_truckCount],"hint",true,false,false] call BIS_fnc_MP;

Share this post


Link to post
Share on other sites

Testing it out now, will return the results soon

Edit: Still seems to only ever want to go to 1 and doesnt want to repeat after the first truck anyway

Edited by TWking

Share this post


Link to post
Share on other sites

Hmm, try the following in the condition line instead:

{alive _x} count thisList > 0

Share this post


Link to post
Share on other sites

Its working! :). Thanks for all the help everyone, its taken us a while but we've done, and I certainly would be nowhere without the help

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  

×