Jump to content
  • 0

Need some expertise on "count" command


dodgitech10

Question

Recommended Posts

  • 0

count is used to check for -how many entrys of an array, -how many items in a box, etc etc...

Also it´s used for a similar function like "forEach".

 

If you mean a random number between 5-500 u better should use:

_someVarName = round(random 500);

 

for the minimum of 5 iam not sure, perhaps:

_someVarName = round(random 500 max 5); //this could be wrong, but i hope u know what i mean :)

 

cheers

Link to comment
Share on other sites

  • 0

Thanks for the reply, What I was if I had 10 apples saved in a box and the map had x amount. I would like to add 10 to the x when it counts all the apple it can find in the map. But the number 10 is just a number I used for example. The reason why I said 5-500 could be larger could never hit 500, just trail and error till I find the number I want. (Trying to code a script for the community)

 

Kind Regards

Link to comment
Share on other sites

  • 0

ah ok...

But for this you don´t have to use the count command.

 

Other question is, if this will work at all, but you can try:

 

EPOCH_VehicleSlotCount = (EPOCH_VehicleSlots + 50);

 

But i think for this some hive calls are needed, or at least publicVariableEventHandlers.

Good luck! :)

Link to comment
Share on other sites

  • 0

EPOCH_VehicleSlotCount = (EPOCH_VehicleSlots + 50);

 

EPOCH_VehicleSlots is an array of all the vehicle slot numbers and you cannot just add 50 to an array, you would need to use either:

EPOCH_VehicleSlotCount = EPOCH_VehicleSlotCount + 50;

or

EPOCH_VehicleSlotCount = (count EPOCH_VehicleSlots) + 50;
 

_someVarName = round(random 500 max 5); //this could be wrong, but i hope u know what i mean  :)

 

this is not correct either and would only return a number up to 5, i belive you misunderstood the use of max and min (common mistake).

 

for correct use, you should do something like this:

 

sorry, i wasnt completly awake here, you are correct, it is:

_Var = (round(random 500))max 5;
Link to comment
Share on other sites

  • 0

_Var = (round(random 500))min 5;

Yes, this was my second idea :D

But i wrote, iam not sure if its correct or not :)

 

Referred to the vehicle slots: I never looked at this part of the files. It´s not that easy when somebody comes around with a part of code, because i dont knew what is original and what is custom :)

 

But thank you for clearing this up ;)

 

@dodgitech10:

Like i said, good luck and keep us informed if it works what you want to do.

 

cheers

Link to comment
Share on other sites

  • 0

Well it did work in a sense but only that it would add +50 to the client side count, So when I added the +50 code, Infistar was counting the vehicle slots available based on the allowed vehicle list then just adding +50 to it and thought I had more slots then it actually did so when I spawned vehicles in, The available slots counter wouldn't drop below 50 and even thou you think it is saving them upon restart any vehicle spawned in after the 50 mark would get deleted/not saved.

Link to comment
Share on other sites

  • 0

Infistar gathers the vehicle count from this line of code in EPOCH_spawn_vehicles.sqf line 248. I changed it to (Check Below). This worked opening the spawn menu in infistar, but it wouldn't save the vehicles. Tested and confirmed, I change the db to save every 60 seconds if 1 thing changed and it didn't include the vehicles that spawn once the available slots got to 50 value.

EPOCH_VehicleSlotCount = (count EPOCH_VehicleSlots) + 50; // Thanks Halv/Sp4rky

My idea was to find a way to increase the upper vehicle list without increasing the spawned vehicles. I will keep digging through the files which I believe I have found the correct place for the global max vehicles in server_variables.sqf line 117-121

Link to comment
Share on other sites

  • 0

Infistar gathers the vehicle count from this line of code in EPOCH_spawn_vehicles.sqf line 248. I changed it to (Check Below). This worked opening the spawn menu in infistar, but it wouldn't save the vehicles. Tested and confirmed, I change the db to save every 60 seconds if 1 thing changed and it didn't include the vehicles that spawn once the available slots got to 50 value.

EPOCH_VehicleSlotCount = (count EPOCH_VehicleSlots) + 50; // Thanks Halv/Sp4rky
My idea was to find a way to increase the upper vehicle list without increasing the spawned vehicles. I will keep digging through the files which I believe I have found the correct place for the global max vehicles in server_variables.sqf line 117-121
You are spawning additional vehicles, they do appear in 3D game world but don't get saved to redis db?

One potential reason:

Did you add that additional ("Dear EpochMod, please save this vehicle to the database") token to each extra vehicle you spawned?

Link to comment
Share on other sites

  • 0

Did you add that additional ("Dear EpochMod, please save this vehicle to the database") token to each extra vehicle you spawned?

 

Thats what im talking from, i didnt remembered the name :D

Can u post the way to do this, perhaps i need this sexy token too... ? :)

 

cheers

Link to comment
Share on other sites

  • 0

Thats what im talking from, i didnt remembered the name :D

Can u post the way to do this, perhaps i need this sexy token too... ? :)

 

cheers

Sorry, I can't remember.

I'm on mobile now, shall find it for you and post from home if nobody else replies then.

Link to comment
Share on other sites

  • 0

Thats what im talking from, i didnt remembered the name :D

Can u post the way to do this, perhaps i need this sexy token too... ? :)

 

cheers

 

 

Sorry, I can't remember.

I'm on mobile now, shall find it for you and post from home if nobody else replies then.

 

 

 

Hello Sp4rkY,

As promised, I looked at the code I had on mind, here it is:

_SUTaxiAIVehicleObject        call        EPOCH_server_setVToken;.

However, on examination of the same source file, I see the following comments: Server is running EPOCH MOD. Post vehicle creation, setVToken issued to prevent accidental-clean up .

If I remember correctly, this token was added to protect custom-spawned-vehicles from Epoch's auto-cleanup procedures which is the one that happens during server runtime (i.e.: this code PREVENTS vehicles from disappearing from 3D world suddenly and unexpectedly due to Epoch cleaner).

 

Not sure if it will also help save to the database? Perhaps add it in and give it a try - should take 10 minutes! Good luck.

If you do test, please remember to post an update for the next guy :)

Link to comment
Share on other sites

  • 0

I might have to stop on this, Learn arma 3 scripting then come back. Kinda got lost when I was told you can't add it to an array. But I will be sure to come back

Might depend on the person but IMO best way to learn a scripting language is tackling a specific problem; such as setting out to fix/improve a particular aspect of an existing script OR aiming a new one from scratch.

Personally, I set out for the latter months ago & still at it lol

Learned a lot though.

Other sources of learning that might help:

* Killzone Kid's blog has bite-sized articles which is usually newbie friendly.

*The bible (i.e.: BIKI).

*Reading others' scripts.

Good luck in your endeavour! :)

Link to comment
Share on other sites

  • 0

Here is a great e x ample of spawning in a vehicle for a mission.

Here is the code

_item = createVehicle["B_MRAP_01_EPOCH", _hunterPosition, [], 0.0, "CAN_COLLIDE"];
		_item setDamage 0.8;
		_item setFuel 2;
		_item setVariable["LASTLOGOUT_EPOCH",1000000000000];
		_item setVariable["LAST_CHECK",1000000000000];
			//So Vehicle doesnt despawn
		EPOCH_VehicleSlotsLimit = EPOCH_VehicleSlotsLimit + 1;
		EPOCH_VehicleSlots pushBack str(EPOCH_VehicleSlotsLimit);
		_slot = EPOCH_VehicleSlots select 0;
		_item setVariable ['VEHICLE_SLOT',_slot,true];
		EPOCH_VehicleSlots = EPOCH_VehicleSlots - [_slot];
		EPOCH_VehicleSlotCount = count EPOCH_VehicleSlots;
		publicVariable 'EPOCH_VehicleSlotCount';
		_item call EPOCH_server_setVToken;
			//Creates vehicle inventory
		clearWeaponCargoGlobal    _item;
		clearMagazineCargoGlobal  _item;
		clearBackpackCargoGlobal  _item;
		clearItemCargoGlobal       _item;
I guess some people forgot that I provided some quality posts before the whole thing.
Link to comment
Share on other sites

  • 0

As mentioned, the BI wiki (https://community.bistudio.com/wiki/) is your scripting bible, don't leave home without it. Avoid simply guessing the use of a scripting command at all costs, always use the Wiki first. I've added the BI Wiki as a search engine on Firefox, and I constantly use it whenever writing any kind of code. Every page for each scripting command explains its syntax and how it's used (what goes in, what goes out).

 

When scripting, it doesn't even matter if I "think" I know about the scripting commands that I use, I always double-check if I have the slightest doubt. Very often, I find that many commands can be used in multiple ways, just check the page for "count" as an example: https://community.bistudio.com/wiki/count. It seems common for new scripting commands (or new ways to use them) to be added with every Arma 3 update, so it's always worth the time to double-check the wiki for any syntax changes or new commands.

 

As for saving vehicles to the DB, that's something I recommend avoiding like the plague because you will 100% encounter problems eventually.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...