#arma3_scripting
1 messages ยท Page 239 of 1
Assuming you're trying to pull on the client from the server
So, I believe you'd do something like
RedReinforcements select 0;
That would give you the first unit in that array
RedReinforcements is already being broadcast on the server to the clients, so you should just be able to use the variable name as it will default to the missionNamespace
(I've never helped anyone on here, so someone please correct me if I'm wrong)
If a client can pull a value for that variable when a unit is in the array, we should be able to expand upon that.
That's pretty helpful! I'm trying to get caught up to you just now. I'm testing your suggestions for additions to the array checks now.
Cool ๐
Okay, that didn't work, got a script error saying it was missing a semi-colon, but honestly, I'm much more interested in getting the objects grabbed from the arrays and added to the choppers than I am concerned with getting the array checks perfect at the moment.
In a watch field, from the client, can you pull RedReinforcements?
Does it list the array?
We have to see it before we can pull from it
Yeah, both reinforcement arrays are being filled and we can watch the arrays be filled as clients JIP or are killed in game.
So RedReinforcements select 0 returns a unit?
Wait one, will check.
RedReinforcements select 0;
returns
C11A
Which is the first (and only) unit in the array.
Welp, that's how you pull the selective information from the array.
Now, you can do a forEach loop on the array
{
/*do stuff*/
systemChat format ["%1", _x];
} forEach RedReinforcements;
Where _x will be each value in the array per iteration
According to : https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/addMissionEventHandler#EntityRespawned you're adding player objects to the arrays, so _x should return a unit.
I'm testing this a bit on my end. Never used the EntityRespawned EH before.
I have AddActions on some players I want to restrict while next to a specific object. How would I add an if statement to check if a player is within X feet of Y marker?
And then disable the addaction if its true
"player distance _whateverMarker > _specifiedDistance"
Use < if you want them to be next to the object
if you want them away from the object
add this actions to the Object? and than look if the caller == hte player
or just add the action on the players client
I want players to be able to only use the addaction outside of the zone, not within, that's why I asked ๐
So use >
I know I can add the action to the init field of an object
Are you scripting or do you want a copy/paste solution?
Yeah
That makes sure the player is a minimum distance away before the action appears.
player addaction ["<t color='#FFA500">Action Name</t>",{/*Put script here*/},[_script,_arguments,_here],0, true, false, "Action", "_this distance _object > _specifiedDistance"];
For example.
ah you're beautiful
Check out that link to learn more. In the condition part at the end, _this is the player using the action and _target is the object the action is called from
I was over here thinking of what kind of precompiled function to throw in my SQF and it's just that simple
Fantastic, thank you.
๐ Np
โค
If I can learn to script for Arma, anyone can ๐
@shadow sapphire I didn't forget about you.
In my arrays, I'm seeing units, not the strings you're getting.
[B Alpha 1-1:1 (pigneedle)]
Is there a conversion going on somewhere I can't see?
@winged thistle, every unit in my missions have a variable name.
These addactions are added via script on respawn, would it make more sense to add these options to each playable units init in the Editor?
Yeah, they refer to specific units.
Cool Del
@shadow sapphire Then you should be able to do the forEach loop to do things for each person in the array. You can then set conditions around which units should be handled and which should be ignored
@winged thistle, okay! That's awesome. Will try it now and send a code block for double check soon, if that's okay.
@shadow sail When a unit dies and respawns, the new unit object is different from the old unit object, so the action must be readded.
Sure Del ๐
This is me taking a day off ๐
Well to give context they currently have the option to spawn in a vehicle via script referenced in onPlayerRespawn.sqf, such as
player addAction ["Supply Drop","supplydrop.sqf"];
Do I need to simply change this to:
player addAction ["Supply Drop","supplydrop.sqf","_this distance _object > _specifiedDistance"];?
and is that comparison checked on every frame or?
My thought process was a waituntil with a sleep and checking a boolean, then run an if to see if the player is near the marker, if they are not within x distance enable the action
But if I can simply add that distance comparison in the init that would be great
You have to account for each parameter in addAction
And yes, that's the purpose of the condition parameter ๐
To make my headache go away ๐
I had the same problem fairly recently
_this select 0 distance _object
I believe johoko helped me out
As the first index of _this will be the object the addaction is attached to
player addAction ["Supply Drop","supplydrop.sqf",[],0,true,false, "", "_this distance _object > _specifiedDistance"];
Namely
target (_this select 0): Object - the object which the action is assigned to
caller (_this select 1): Object - the unit that activated the action
ID (_this select 2): Number - ID of the activated action (same as ID returned by addAction)
arguments (_this select 3): Anything - arguments given to the script if you are using the extended syntax```
@dusk sage I liked it to him already ๐
im unfamiliar with what to put in the shortcut section hence ""
ahhh gotcha
Also
There's a list of them linked in the addaction page under the param
considering the fact you've attatched the addAction to the player
you are more than welcome to just do
Could just use player
player distance _object
I prefer the copy/pastable version though ๐
So you can remoteExec later and allow players to create objects that have multiplayer interaction options ๐
eh
But yes, always optimize when you can.
Well, to reveal a little secret I really realllllllly missed Invade and Annex on Stratis and I've spent about 80 hours tearing it apart and putting it back together with debugmod and fnc_logs to try and get a good error-free base with a few custom features enabled. One of these features is a Tank Crew squad that can spawn in a Slammer by parachute (working) and I didn't want people to see the option, pop it, then have it fall on a team-mate or a building and/or explode in base.
Helping me a ton! ๐
Dude don't you worry
I've been coding a similar mission for the past 3-4 months ๐
Basically re-wrote AAS from Arma 2 from scratch, and added a bunch of cool stuff.
If you see "Scorched Earth" with a password in server browser that's me mucking about ๐
nice!
That would be super fun in A3
It's just the first version though. I don't know if it'll be as awesome as it will be when I'm done with all my milestones.
But it will be playable, at least.
Hah, I'd be happy to be good enough to need milestones ๐
I modded AAS in Arma 2. That took a few months. I was completely new and hadn't ever played Arma.
What is AAS and what is it all about?
Made another mission right after Christmas for Arma 3. Took a couple months. Simple dogfight mission.
Advance and Secure, capture objectives in series by outnumbering the enemy
This mission started at the beginning of March and I'm still not done.
it was pretty rad
But I'm really close ๐
That's pretty much all of my Arma experience. I've spent more time coding for Arma than I have playing it ๐
Haha I am complete opposite, I have 800 hours in ArmA 2 and almost 300 in ArmA 3 and maybe 20 hours scripting in a very very rough manner ๐
Studying other peoples code and getting the bigger picture is a huge help. I had no idea how things were called during server start in the beginning and was trying to find out how everything was linked to init.sqf, like WHY ARE THERE NO REFERENCES??
And of course I found the BIS page and it made sense, but it was not implicitly obvious ๐
I've got a phrase I started telling the boss way back when
He'd ask why we couldn't do something, and I'd only be able to respond, "Cuz Arma"
It stuck
haha
But compared to most other games, there's a hell of a lot you can do
And they only improve with every update
I was surprised, after hearing the pains of some of my buddies in ArmA 2 I am finding ArmA 3 scripting to be difficult but more time consuming than obtusely complex
Which is fine with me
๐
I'd say it's been a healthy balance of both. But so is every script.
Yea, I think my ignorance is the only reason I've stuck with it this long. "Can't be that hard to take a two year old mission that no longer works OOB and make it run smooth"
Now I know how much I bit off before I chewed ;p
But, I'm this far, can't turn back now
I'm down to zero script errors aside from debug mode script errors for the Werthles client on respawn, but its disabled so it's all smooth atm. Just trying to do one thing very slowly at a time and get it working.
I gotta say man, I've actually been in an extremely similar position. Be glad you started in Arma 3. There were so many things we ran into that were only in Arma 3 during development. I wanted to cry sometimes. ๐ฆ
Haha I am very glad ๐
If you read through Werthles client, line by line, and learn what each line does, you'll find you don't need it anymore because you'll write your own streamlined version.
Once I have my mission working in the sense that I am confident to put it in beta, I'll definitely look at reworking Werthles
I mean it runs great, I just think I can cut out all the debug stuff and not miss anything
It's worth it. I got back 10 frames after I dropped it.
We use 1 but our server is OP
Yea, I'm on some fat hardware myself probably only need one
There are a bunch of other servers being hosted on the same hardware, so 1 each is enough for now.
Hi guys,does anyone know how can i exclude a script from error logging?
Thanks for your guys' help, it works flawlessly.
Is there a simple way to add a cooldown to a script?
sleep
that easy?
just add a 30 second sleep to the end with a hint and itll wait for the sleep before it enables the use of the script again?
Aslong as the script is run scheduled
sleep 30;
hint "bye";
Will have a 30 second gap between hi and bye
Right, I want to prevent a player from using an addAction ability for a set period after use
And that'll do the same?
After they use a supply drop I'd like to prevent them from doing it again for a set period
Very little on the forums in regards to that :\
When I do
player addAction ["Supply Drop","supplydrop.sqf",[],0,true,false, "", "player distance respawn_west > 250"];
Can I somehow add another conditional? Like..
player addAction ["Supply Drop","supplydrop.sqf",[],0,true,false, "", "player distance respawn_west > 250 && Cooldown < 1"];
and then do:
//some code
sleep 30;
Cooldown = 0;```
?
player addAction ["Supply Drop",{
hint "hey";
sleep 30;
hint "bye";
},[],0,true,false, "", "player distance respawn_west > 250 && Cooldown < 1"];
?
is && Cooldown < 1 a viable operand in the init field? That's what I am curious about
and I'll have to see
in the beginning of your supplydrop.sqf you could have a check
that would be easiest
okay,
unless you dont even want the addaction to appear
it depends on which is easier, I'd like it if it remained on screen and it was simply disabled
but, if it was removed after use and then put back once conditions were met thats fine too
keep the action menu lean
would i just wrap the code in my SQF in a waitUntil
like
wait Until { var = 1;
// do stuff
var = 1;
sleep 30;
var = 0;```
d'oh
Does anyone else feel like it's a little silly for people to be all like "I don't share my Arma scripts or code bro."
When we all know the code/scripts they are writing are jokingly easy to replicate anyways?
Why hoard knowldge like that, why not, idk share / teach / and expand the community so we have reason TO make scrips, mods, etc.
or would it be
if var == 0
//do all my normal stuff
wait until ( var = 1;
sleep 30;
var = 0;)```
Depends. My community has some scripts that are extremely time consuming to replicate and we aren't hoarding them, we might share if people asked, but we won't publicly release them, because we want our server to be the one that has those scripts.
err set it to 1, sleeep, then 0
DEL-J, I guess it's less about tthe scripts themselves, and more about some folks attitude, thinking that sqf is some magic thing, or refusing to share knowldge and experince simply because they don't want anyone else to be able to do what they do. It's sad man, I know it's not everyone, but I tend to find the jerks most of the time.
I try to make public everything I do so everyone benefits
The problem for me is should I release shoddy code
Share code when you think its worth sharing
if you think you rushed it and its not the best way to do it, dont share it because otherwise everyone who will use that code will be running around with non optimized stuff
and the people that quickly copy paste functions found on the internet tend to be the ones that are not capable of differentiating between good and bad code
so they will A) either think its good code and adapt your style or B) run around with bad code and dont question it
I would make it public if I personally came up with anything new or interesting, but I am likely never going to be at that level, myself. I'm not passionate enough about it. I've got three projects that I want to do, two are simple, one is deep, the deep one I have guys on, but my other two I can do by getting the wonderful people here to help me. I don't even intend to credit myself as the author, haha
I don't mind.
A) either think its good code and adapt your style
Yes, can't stress enough how important this is!!!! People need to know if what they are looking at is something to emulate or not! We have to set up future sqf-kids for sucess, it's honestly the best way to keep this community a fun, great place.
sorry to interrupt, could someone help me with some config scripting?
my function:
(format ["configName _x isKindOf %1",_parent]) configClasses (configFile >> "CfgVehicles");``` it's called like ```_classes = ["aus_Physx_Objects"] call MG_fnc_returnChildren;```
but _classes returns nothing
_parent = "aus_Physx_Objects"; (format ["configName _x isKindOf %1",_parent]) configClasses (configFile >> "CfgVehicles"); returns []
I am trying to add two numbers together, what should the sum be?
Maybe I just don't understand the context eagledude4
Syntax looks good tho ;D
It just seems that trying to use format wont work
'configName _x isKindOf "aus_Physx_Objects"' configClasses (configFile >> "CfgVehicles");
works
configClasses dont return inherited classes if i remeber right or subclasses of them i am not sure there was some bug with that
oh right ok ๐
It was a topic of discussion here a week ago
this is my workaround for now
'''_classesConfig = 'configName _x isKindOf "aus_Physx_Objects"' configClasses (configFile >> "CfgVehicles");
_classes = [];
{_classes pushBack (configName _x)} forEach _classesConfig;
_classes deleteAt 0;
_cargoClass = selectRandom _classes;'''
oh, I think I know what I did wrong ๐
I'm certain the issue is with _classesConfig = (format ["configName _x isKindOf %1",_parent]) configClasses (configFile >> "CfgVehicles");
when i replace the format with
_classesConfig = 'configName _x isKindOf "aus_Physx_Objects"' configClasses (configFile >> "CfgVehicles");
it works
@agile pumice it's because you're taking off the quotes
_classesConfig = (format ["configName _x isKindOf '%1'",_parent]) configClasses (configFile >> "CfgVehicles");
around %1
thanks, I'll give it a try
I guess it's less about tthe scripts themselves, and more about some folks attitude, thinking that sqf is some magic thing, or refusing to share knowldge and experince simply because they don't want anyone else to be able to do what they do. It's sad man, I know it's not everyone, but I tend to find the jerks most of the time.
Luckily the code produced by those people is rarly worth looking at anyway.
does setPos ignore all kinda of collision?
or is setVehiclePosition with can_collide needed?
just for sure: documentation for new server admin #commands and server.cfg settings in profiling (performance) binaries 1.60.136560
https://forums.bistudio.com/topic/160288-arma-3-stable-server-160-performance-binary-feedback/page-77?p=3035423#entry3035423
Page 76 of 76 - Arma 3 STABLE server 1.60 "performance binary" feedback - posted in ARMA 3 - SERVERS & ADMINISTRATION: Hey, i think u misunderstod me.
before the patch i had only a few crashes like 2-3 a week.
With the v9 everything worked perfekt, no crashes anymore. But now with the 1.60 my Server
Crashed like 6-8 Times in 24 Hours.
@velvet merlin afaik its ignoring everything. BUT (for example with a Vehicle) afterwards -> PhysX kicks in
@jade abyss thanks
BR is getting floating magazines/items in weaponholder_ground with us (IFA3); trying to find out why or what to do
setPosATL ? @velvet merlin
[x,y,0]
Example:
_Pos = getPos _GWH;
_GWH setPosATL [(_Pos select 0), (_Pos select 1), 0];```
hello. im using this "if (alive (_this select 0) && {side (_this select 0) isEqualTo CIVILIAN} && {isPlayer (_this select 1)}) then {hint ""Innocent Civilian Harmed"";}"; to put out a msg whenever a civilian is hit. What i would really want is for the player's name who did the damage to also be displayed. eg. "Innocent Civilian harmed by Zaf" can anyone help?
@velvet merlin Does the GroundWeaponHolder itself is flying in the Air or just the Item inside it? (means: When you add a Vanilla Item to it -> Is it on the ground?)
params ["_unit", "_shooter"];
if (alive _unit && {side group _unit == civilian} && {isPlayer _shooter}) then {
private _message = format ["Civilian harmed by %1", name _shooter];
_message remoteExec ["systemChat"];
};
"innocent" civilian is a tautology
Then, i assume, the GWH is spawned in the air ๐
_Pos = getPos _GWH;
_GWH setPosATL [(_Pos select 0), (_Pos select 1), 0];```
Or does it occur, when you drop stuff from the Inventory? oO
PU says when interacted, they get to ground level and after that back to floating (sounds like change of locality to me)
mom
this is what they use currently:
if(getTerrainHeightASL _pos < 0) then {_pos = ASLtoATL _pos;};
if (surfaceIsWater _pos) then {
_pos setPosASLW _pos;
};
_object = createVehicle ["WeaponHolderSimulated", _pos, [], 0, "CAN_COLLIDE"];
_object setPos _pos;
_object setDir (random 360);```
tried "GroundWeaponHolder"?
he is switching back now
+i would create the GWH first at. [0,0,0] then using setPos
So:
_pos = _house modelToWorld (_positions select _p);
if(getTerrainHeightASL _pos < 0) then {_pos = ASLtoATL _pos;};
if (surfaceIsWater _pos) then {
_pos setPosASLW _pos;
};
_object = createVehicle ["GroundWeaponHolder", [0,0,0], [], 0, "CAN_COLLIDE"];
_object setDir (random 360);
_object setPos _pos;```
+switched setPos and setDir
good idea. 0,0,0 was notorious from have weird behavior - did BI fix all that?
like back in the day -10,-10,0 or sth was safe instead
like that area was the blackhole of arma ๐
I remember, that createVehicle had a Problem with creating at a certain Spot (Pos not accurate, sometimes 1-2-3-4-500m away from real position + extremly slow updating of Pos to the Clients
+Is the player (who activated the Script) beeing send to the script? (wich is, i assume, is executed Serverside)
yeah that too. was also a prob with VON
hum
you "new" guys all missed out the many fun bugs of the old days ๐
yes yes i was just generalizing ๐
I remember: Tank flipped, switch to Gunner seat, fire Sabot, fly around the map with Hyperdrive ๐
in OFP close after MP was introduced sth like 1.0.x locality for choppers was bugged - so you had rockets coming from nothing at times ๐
๐
yeah that one was nice too
Or the wonderful "desctruction" Anims XD
"f**k, i am stuck in the Destroyed house again. crap, dead"
Okay, back2script:
Is the player send over to the script, then ->
_Player reveal _object; <-- something like this should be added to it (iirc, sometimes Arma doesn't update so fast)
yup
especially after setPos player or object
how to determine the object p3d if it has no class - nearObjects?
hmmm. i put the script commy posted: params ["_unit", "_shooter"];
if (alive _unit && {side group _unit == civilian} && {isPlayer _shooter}) then {
private _message = format ["Civilian harmed by %1", name _shooter];
_message remoteExec ["systemChat"];
};
into civkill.hpp
then i added #include "civkill.hpp" into description.ext
but it crashes
you can't include SQF code into description.ext
description.ext uses a class structure
should it be in init?
from what i see it's the code block for an event handler
the original code was
class Extended_Hit_Eventhandlers {
class Civilian {
class civ_hit {
// runs where unit is local
hit = "if (alive (_this select 0) && {side (_this select 0) isEqualTo CIVILIAN} && {isPlayer (_this select 1)}) then {hint ""Innocent Civilian Harmed"";}";
};
};
it was a script from DCG by senseii which i just modified
it was in an hpp file. and the description.ext "included" it
Right so convert commys code back into a string and replace the hit = ""; string
like this?
class Extended_Hit_Eventhandlers {
class Civilian {
class civ_hit {
// runs where unit is local
params ["_unit", "_shooter"];
hit = "if (alive _unit && {side group _unit == civilian} && {isPlayer _shooter}) then {
private _message = format ["Civilian harmed by %1", name _shooter];
_message remoteExec ["systemChat"];}";
};
};
};
please dont get angry
no, the params [... line needs to be in the hit = ... class as well
oh. hold on
also certain PBO packing tools will not accept a line break in a string and will error, be sure to escape with \n or remove the line break
class Extended_Hit_Eventhandlers {
class Civilian {
class civ_hit {
// runs where unit is local
hit = "params ["_unit", "_shooter"]; if (alive _unit && {side group _unit == civilian} && {isPlayer _shooter}) then {private _message = format ["Civilian harmed by %1", name _shooter];_message remoteExec ["systemChat"];}";
};
};
};
how bout now
now the quotes will break, replace the " inside the outer two " with ' like hit = " systemChat 'this is a string inside a string';";
all instances except the main outer two?
class Extended_Hit_Eventhandlers {
class Civilian {
class civ_hit {
// runs where unit is local
hit = "params ['_unit', '_shooter']; if (alive _unit && {side group _unit == civilian} && {isPlayer _shooter}) then {private _message = format ['Civilian harmed by %1', name _shooter];_message remoteExec ['systemChat'];}";
};
};
};
now all thats left is for you to test it
here we go
๐
thanks cptnnick. Now i can shame players who shoot innocents in my server.
@velvet merlin Fixed your issue with floating loot yet?
I have a function that (workaround) fixed it for me
on any map
@tame portal building new release atm. we will see after that
scriptName "fn_lowestPosition";
#define __filename "fn_lowestPosition.sqf"
// Parameters
_pos = param[0,[0,0,0],[[]]];
_pos = AGLToASL _pos;
// Exceptions
if (_pos isEqualTo [0,0,0]) exitWith {[0,0,0]};
// Code
_intersectsAt = lineIntersectsSurfaces [_pos, _pos vectorAdd [0, 0, -50], player, objNull, true, 1, "GEOM", "NONE"];
if (count _intersectsAt > 0) then {
ASLToAGL (((_intersectsAt select 0) select 0))
} else {
[0,0,0]
};
In case you need it
Pretty much just take the buildingPos position, run it through this function and you have an optimal position for your loot
works for every type of surface
@velvet merlin Any results yet?
in 30min i should know more
ay why so long ๐
ok it seems my config change in groundweaponholder fixed it ๐
@tame portal still your assistance much appreciated
@jade abyss same to you ๐
Is it possible to add a unique identifier to an object when spawned, so when its spawned again the previous version gets removed through delVehicle?
Do I wield missionNamespace for this?
ah ha, thank you
No prob mate
is there a way to add an id specific to a player itself?
I feel like if I add an id to a spawned vehicle and someone else spawns the same vehicle, wont it delete the first?
or if its private it will that name only be relevant to that thread of the script?
What do you want to do exactly ?
I have a supply drop script that will be for squad leaders, when they spawn it a second time I'd like the first to be deleted
Dropping it works but I added a 'duration' to the supply drops, I realize I'd rather have the first get deleted to prevent abuse instead of it automatically deleting itself after x seconds
They you can do this
Do a setVariable to the leader
And put as variable value the dropped item
When leader asks a new drop
Delete the old object using gervariable
Your welcome
If it is for single player you can just store it in a global var
Note : if you want the actual setVariable to be available for every players or even server, you should make sure this variable is public by adding "true" to the set variable
Because by default, setVariable is local to computer who setted the var
Yea this is for a dedicated, thank you
I guess I only need the setvar to be available to the local machine requesting it right?
Since not all individuals have the action?
Or am I looking at it the wrong way
If your drop script is server side, you can set the variable only server side
Then set variable in private ;)
awesome thanks
๐
Hardest part about SQF is understanding the bigger picture
So far anyways
If you need any help or improvement do not hesitate to send me pastebin of you mr script in private and I will have a look
Sure thing, I'll probably need some guidance ๐
I guess the dilemma is twofold. I have an option here, I can either have the box have 'duration' which I have added by self-deleting after a period of time and then add a _cooldown = 0 check with an if statement around the spawning of the object, OR make the object have a unique name and delete it on every spawn, preventing the server from filling up with extra crates. My concern with the second option is if a player spawns a crate and then leaves, if the server is up for 6 hours a number of people can do this on Stratis and I have boxes everywhere. I feel like if I add both I am making it unnecessarily complex. What would you do as an experienced scripter?
Well here is a workaround
You could set a variable on you crate with the player object in value
And do a loop that checks every X minutes if the specified player is always logged in
And if not delete the crate
ahhh
Or delete the crate after X time if no players nearby simply
You could even do a 2 in 1
When player calls drop, it deletes old drop
AND
Every 5 minutes, all crates spawned since more than, let's say 30 minutes and no players nearby, it gets deleted
Okay, so currently the addaction is given to a player and prevented from working while near the respawn_west marker with this:
player addAction ["Supply Drop","supplydrop.sqf",[],0,true,false, "", "player distance respawn_west > 250"];
And the Supply Drop script is here: http://pastebin.com/raw/Gw8WS9DR
I have no issue anyone seeing my probably borked code ;p
and objectDuration.sqf is just:
_box = _this select 0;
sleep 180;
deleteVehicle _box;```
its a separate script since I was going to reference it elsewhere
I see but actualy your script is called client side
ah since if (isServer) isnt in place?
Since you must make player remote exec on server ;)
so do I just add:
//script
};```
Not really. Explaining
okay
When you want script to be run on server but called from player you must use remoteExec command
Check BIWiki
BIS_fnc_mp?
But you can also in your case make it fully clieny side
Yeah it's nearly the same
Makes less network trafic
And eventually on server you could add a onPlayerDisconnect eventHandler to delete crate
Nope, on leader
Okay, thank you so much ๐
Nvm Dwarden pointed me in the right place
ack wrong spot
Can you encrypt anything aside from the mission.sqm for file size sake? I am not doing it to hide anything just to make the PBO lighter
nope
Okay thank you
If you have pictures , you can convert them to .paa
Sounds to .wss
Can't do anything with scripts or configs.
Thanks ๐
Could anyone help me finish off this script that Rafael09ED helped develop to this point?
https://gist.github.com/DEL-J/39a13c663b8081194b2305aa6b9d2e63
It's getting close, I can feel it.
The script is for more immersive respawn in a PVP game mode.
It takes dead and late joining players, puts them into spectator mode, and whenever an objective is captured, it triggers the respawn function, which should load the JIPs and dead (respawned) players into a helicopter and drops them off at their base.
So, I have units that are squad leaders I want to assign a specific action. Can I somehow do if (player == _unit) { and then make _unit an array with all squad leader names (like S1, S6, etc.)?
@shadow sail, I am not good at this, so you'll have to hear a second opinion, but you should be able to just be able to use the array if you give variable names to all of the squad leaders.
leader is a script command that reports the leader of a group or unit
well hot damn
yw
thank you!! ๐
so I would do if (player isKindOf leader then {
I guess I could do a second condition in the init
nope. isKindOf checks if a object or classname (left side) inherits from the classname on the right side
ah gotcha
And leader needs something on the right side
@little eagle, any chance you feel like reading over my function and giving some guidance there?
I think this is strange:
!(_spawned in GreenReinforcements)
Why would an object respawn twice?
I think this check is unnecessary.
Even then, you could simply replace pushBack with pushBackUnique
That will make sure you won't add another thing to the array if it's already in there
@shadow sail if((leader (group player)) == player)
ah, โค
Or, simpler, if((leader player) == player)
@little eagle, the respawn twice catch is because when players join in progress, they are respawned. It's because we have an issue where if a player ragequits after being killed and another player joins that slot or the player returns, it is added to the array again. However, even with that check, the issue was still happening, so I believe I will change over to pushBackUnique! Thank you for the tip! However, the main issue I am having at present is that units in the array aren't being added to the helicopter for some reason and we don't know why.
hmm, im using old invade and annex, it must treat all units as leaders as they're getting the addactions
I'm pretty sure that won't work. Each time a unit respawns, a new "entity" is created. No two entities can be the same (hence entity I guess?)
@shadow sail In SP, you will always be the leader by default
well this is on a dedi
You can decrease your rating to get the AI to be leader
if im the only player in the group am I the leader?
Or increase the rating of a bot. If all ratings are equal - and that is the default - the player will be the leader
well this is a Dedi and if I choose either the Grenadier slot or the Squad Leader I get the actions added
doesn't matter. By SP I mean all group members are AIs
Also "Squad leader" doesn't mean the unit is the leader
"Squad leader" is just a soldier class
Try to increase the rating of the Squad Leader above the default
You can do that by selecting a higher "rank"
And this will work in MP?
Well the only AI on the mission are simply the playable units, no actual AI on my side.
unless the rating changes ofcourse
Okay
playable units are AI
well, I mean they arent occupied by an AI during the mission
If you have AI disabled and you are the only guy in your group, you will always be the leader too
Every group has to have a leader
You can start another instance of the game to do MP testing btw
I have a dedicated up that I test on
That way your second game instance can be a non-leader
So if I had AI disabled and someone else joins my squad, what happens then? Am I no longer leader?
Or will it fall back on the playable unit AI ranking
Gotcha
If they are the same then a player will be the leader
If both are player, the unit that was placed in the editor first is the leader
"Squad Leader" unit class means nothing
If you place groups (F2), the units will have predefined ranks/ratings and usually the one with the highest rank is the "Squad Leader"
If you place them by hand, everyone will have the default rank/rating
Ah thank you
@little eagle, it seems that even pushbackunique did not stop the problem of having duplicates in the array.
neither will the in check
In check?
Because every time a unit respawns, a new entity is created
!(_spawned in GreenReinforcements)
Rats. Any ideas on how to fix it? Do we just let it go? Surely it won't be common enough to be a problem soon.
are those duplicate reinforcements dead?
Yes, I believe. The duplicates are created whenever a player that is in the queue leaves and someone rejoins that same slot.
You need another event handler that removes objects from the array if a player disconnects
Ah, I see. This can be done, but for now, I would have to say it isn't the priority, since we don't even have the units in the array being added to the chopper correctly at present.
Whenever the choppers spawn, it clears the array, the choppers arrive, land, open doors, wait, close doors, fly away, delete flawlessly, but no unit is ever put into or taken from the chopper.
addMissionEventHandler ["HandleDisconnect", {
params ["_unit"];
// do stuff
false //event has to return boolean, true would cause the server to keep the unit as AI
}];
So, I put that in the function, rather than putting a file together in the onplayerdisconnect.sqf?
Thank you!
I see that you never put the units into the helicopter
Correct. I am unsure of how to do it.
There are moveInXXX commands
But I believe they are broken for players and only work for AI
I see. We do have movein commands.
MoveInCargo, but it doesn't appear to be working.
I thought there was an assignAsCargo command that worked, but I can't find that one.
Where is your script running?
init.sqf.
Should be, yes.
That is good, but MoveInCargo only works if you execute it on the machine where the unit is local
Wait...
[_unit, _vehicle] remoteExec ["moveInCargo", _unit]
That is the syntax to execute commands on other machines
remoteExec
moveInCargo is the command
[_unit, _vehicle] are the arguments for that command
basically: _unit moveInCargo _vehicle
And the second _unit says: "execute this command on the machine where the unit is local"
This is difficult networking-locality stuff, but I hope it helps
I am sure it will! Due to the context, do I replace _unit with _x or do I use it exacty as you've posted?
_x hideObjectGlobal false;
_x enableSimulationGlobal true;
[_unit, _vehicle] remoteExec ["moveInCargo", _unit]
["Terminate"] remoteExec ["BIS_fnc_EGSpectator", _x];
} forEach _units;```
you obviously have to replace my variables with yours
Many thanks to you. Will test now, I think I've got it squared away.
So I put the names of the squad leader units into an array and am passing over it with a forEach, but unfortunately it doesn't seem to be working Doesn't it need to be the variable name of the soldier or the actual soldier name like B_Blah_TL_F?
It doesn't show errors but the Leaders aren't getting the actions
You have to addAction on the player machines
It is
Change the condition to "true" to make sure
{
player addAction ["Tank Drop","tankdrop.sqf",[],0,true,false, "", "player distance respawn_west > 250"];
player addAction ["Supply Drop","supplydrop.sqf",[],0,true,false, "", "player distance respawn_west > 250"];
} forEach mapLeaders;```
Neither the variable name of the leader or the soldier name seem to work. If I remove the foreach all soldiers get the aciton.,
What is respawn_west ?
Can't be. Waypoints are Strings "respawn_west" would be a waypoint
I can use my actions and the distance from respawn_west all works, its when I assign it to a specific soldier it breaks
An object with the name "respawn_west"
whatever thats not relevant to the foreach
You aren't adding the actions to soldiers. You are adding them to the player
Yes and I am trying to GIVE the PLAYER in that SLOT the action.
That's what trouble I am having
If I assign the slot a variable name like Leader1, and then do a forEach it doesnt work, do I need to get all players and compare them to the slot?
if (typeOf player == "B_Soldier_TL_F") then {
// add action
};
typeOf player == "B_Soldier_TL_F" or typeOf player == "B_Soldier_?_F"
ah ha
thanks
I guess I can just change the SL_F to TL_F too and not worry about it
Thanks for your help
sure
is ? a usable wildcard in such things?
You can think so if you like, but it works just fine on my dedi.
So you put your marker "respawn_west" into a variabe called respawn_west ?
Oh, so it's not a marker after all
I was confused because "respawn_west" is the hard coded marker name for blufor respawn points
Ah okay
Yea, it's my flagpole spawn ;p
I didn't mean to say waypoint mb
Sorry for being terse, sometimes this gets frustrating ๐
You tell me
Hehe
@little eagle, your solution worked perfectly for my problem... but it is only loading one unit from the array into the chopper, but still clearing the array. Any idea why it might do this?
I'm toying with setVariable and getVariable to delete an object if a new object is spawned, I understand set and getvariable, but if I set the variable on to the crate and then spawn another, how do I getvariable of the first crate to delete it?
delVehicle _veh
//do the things
_veh setVariable ["DeleteThis", "1", false]```
I feel like I am missing something obvious
or am I thinking of this the wrong way?
you cannot use setVariable after you delete the object
well I am trying to check to see if a previous object with that variable exists and if so delete it
and keep it local to the client
so they cant spam airdrops and fill up the server over time
you wrote
delVehicle _veh
_veh setVariable ["DeleteThis", "1", false]
but _veh is deleted before you use setVar
well it spawns the vehicle in the //do the things section
I shouldve been more clear
Oh, they are different things
_para setPosATL (player modelToWorld[0,0,200]);
_veh = createVehicle ["B_CargoNet_01_ammo_F", [0,0,80], [], 0, ""];
_veh attachTo [_para,[0,0,-3]];
["AmmoboxInit",[_veh,true]] spawn BIS_fnc_arsenal;```
is the current supplydrop script
when this runs I'd like it to kill off the previous spawned object
okay, so if I setvariable do I then have to do nearObjects and get all CargoNet boxes and check if the variable exists to delete?
Im sure there is an easier way
I think you have to rethink want you want to do
Explain?
Player has an addaction to spawn a crate with a parachute. This works. I'd like it to be able to remove a previously spawned crate when a new one is spawned.
So if the player paradrops another crate, the previous one is deleted?
Yea
private _prevCrate = player getVariable "prevCrate";
if (!isNil "_prevCrate") then {
// delete
};
//paradrop
player setVariable ["prevCrate", _ammoBox];
I love you.
edited it, pressed enter to soon
๐
You probably want to also clean up the crates when a player disconnects
use a handleDisconnected like I posted before and let the server delete it
might want to use the public setVariable then
so the server knows the crate too
okay cool
thank you
well currently they have a duration to avoid that
but thats probably better
The problem with those lifetime counters is, that if the player that has the timer running disconnects
Ah..
it will never reach 0
Yeah. The "HandleDisconnect(ed?)" one is nice, because you get the player object
In your code example above would my delete be deleteVehicle _ammoBox or deleteVehicle _prevCrate?
ahh nvm
Works great thanks ๐
Guys bit of a warning, for some reasons it seems that groups created via BIS_fnc_spawngroup don't get deleted.
i don't think any groups get deleted unless you delete them
Unless the last unit of the group is killed (not deleted, killed) the group will NEVER be deleted
I wrote a cleaner to avoid reaching the group limit.
yeah, we had to do the same recently. do you know if it's always been the case?
since 1.56 apparently
could've swarn empty groups used to get deleted automatically
corpse and wreck cleaner don't work either
i see.. that would fit when ours starting stuffing up
Jeez I had to really scroll for this conversation, but it's relevant http://pastebin.com/MB90iXE5
Or just delete groups serverside?
I guess the conclusion was that groups that are empty don't get cleaned up if they are not local
doesn't matter if they are local or not
If the last unit is removed instead of killed the group won't be deleeted
Is the group definitely empty? Because I would think that group would be local
here's my cleanup function https://github.com/alganthe/Co-ops/blob/dev_altis/functions/misc/fn_cleaner.sqf
It was hapenning with AI groups spawned on the server
those don't change locality nor owner
I also managed to have 146 east groups somehow :p
lol that's really odd
My functions spawn AOs, and just me deleting the units via zeus
reached 146 groups after 5-6 AOs
So are you saying you needed that script to clean up the groups, or that the groups aren't cleaned up even with that script?
that I needed that
The body cleaner / wreck cleaner and the engine solution BI has to delete empty groups don't work
The only thing that seems to work fine is the ground holders being removed after some time
can see the issue easily.. just spawn 150 single man groups with a script, then delete all the units, and count allGroups
will still be 144 or whatever
does anyone know if KillZoneKid uses Discord?
I have not once seen him in here
Unless he hasn't said anything or is under a different name
the script of quicksilver isn't safe in scheduled env.
It could wreck another spawn script doing stuff like:
(createGroup west) createUnit [blah]
by deleting the new group before the new unit was created.
Hey guys,does anyone know how can i get player object using profilename or UID ?
gimme a sec
// finding a player var based on his name
(allPlayers select {toUpper (name _x) == toUpper ""} param [0, objNull]);
use example:
(allPlayers select {toUpper (name _x) == toUpper "alganthe"} param [0, objNull]) setDamage 1;
That wouldn't get dead players though
๐
So cool thank you alganthe!
So name in multiplayer is the same thing as profilename ?
If i understand it correctly
I might be wrong, but in case two people with profilename "Dardo" connect, then 'name _unit' will return Dardo (2) on the second guy, where his profilename will still be "Dardo'
@jovial nebula ^
If you start up two copies of the game you can connect to your own hosted LAN game and test it.
Are you alganthe's brother? ๐ฎ
Thank you so much guys,going to test it in the lan
name doesn't include squad XML does it?
If you change your identity in game with setIdentity , name player will return whatever identity you've changed to
I saw on the wiki that in mp is the same
https://community.bistudio.com/wiki/name
"NOTE: In Arma 3 setName can be used on a person to set name. However in multiplayer name always returns profileName."
that is why you never script around the "names", but the objects or client IDs instead
@lone glade
Isn't == case insensitive?
(allPlayers select {name _x == ""} param [0, objNull]);
or if you wanted
(allPlayers select {toUpper (name _x) isEqualTo toUpper ""} param [0, objNull]);
== is NOT case sensitive
isEqualTo IS case sensitive
exactly
So the toUpper isn't needed
Unless using isEqualTo, like in the example. I said insensitive ๐
Hmmm battlefield 2 in arma..
NOT A GIFV? YOU HEATHEN
YES
Anyone know of a script or function that has the ability to SMOOTHLY move targets in multiplayer? I've got one that's super nice for single player, but it has some odd behavior to say the least when it's done in multiplayer.
what do you mean by move ?
Which type of targets?
If it's vehicles you can use setVEelocity to make a bit better
Doesn't work since it has to be synced in MP
@lone glade, I have the moving zombies on rails. I can send a picture to illustrate what I'm after. Wait one.
I think those should illustrate what I'm trying to do better than I can describe.
There doesn't happen to be a moving targets on rails module I can just drop in, huh?
Also, what's a PFH?
This is what I am using now, found it online somewhere. How might I apply a perframehandler?
does that even works ? there's a syntax error
Haha, yeah, it works in single player and it works (with odd behavior) when I am alone on a multiplayer server.
under what are those rails btw?
I don't quite understand your question.
the rails on the ground, under what object category are they?
OH! I am unsure, I know they are under empty objects. I'll find it for you, wait one.
Props/Things/Targets/Rails
nevermind found them
May I get a link to perframehandlers? I can only find CBA related links.
it's a CBA thing, I ported it to vanilla tho
Oh? That's what's up.
but the gist of what you want to do is pretty much:
- align both ends properly
- Make the object move in the direction of one of the ends
- Check if the object is near the end, if it is stop it.
Both ends are definitely aligned properly. Straight as an arrow! However, the rest I don't even know where with to start!
erf setVelocity doesn't work properly on non physX objects
That super sucks!
got it working with setPos
[{
params ["_args", "_pfhID"];
private _dir = getDir target;
private _speed = 5;
if (target distance2D end2 >= 1) then {
target setPosWorld
[
(position target select 0) - (sin (_dir))*_speed,
(position target select 1) - ((cos (_dir)))*_speed,
0
];
target setPos
[
(position target select 0) + ((sin (_dir)))*_speed,
(position target select 1) + ((cos (_dir)))*_speed,
0
];
} else {
_pfhID call derp_fnc_removePerFrameHandler;
};
}, 0, []] call derp_fnc_addPerFrameHandler;
name both your end rails, and invert the + and - pos for advance, back up
just gimme a sec to pack up the mission
am bad with maths so it won't go forward, but it goes backwards fine :p
Wow! Holy cow! Thank you very much! I didn't expect you to do it for me while I was away! Goodness.
Do you think there is any way I could make the targets go forward instead of backwards simply? Like by changing a +/- somewhere, maybe?
maths, and i'm bad with them
Haha, okay. I'll see what I can do!
It's throwing an error saying advance.sqf not found, but it's working perfectly nonetheless! Going to test in MP as soon as I get it figured all out here.
@lone glade
forgot to remove the class under functions
wait, did this actually work?
Fixed: The HandleDamage Event Handler was not working correctly
Added: โNo spamโ versions of some of the RPT logs
gotta love the descriptive commit messages
Hey
No
๐
I already love you
Yup
Seems that when using setVariable on building even with public flag at true, result is not reliable on players
Sometimes broadcasted, sometimes not
on MapObject?
Yup
Create a Can (or whatever) at the Pos of the House and check the Var from there.
It's not even setVariable
The game can't even remember damaged winows and opened doors
Just when the Data is beeing set, before its known by the player.
Or you know, maybe attach a white flag on the house and set variables on it
Pirat flag
@jade abyss https://feedback.bistudio.com/T117338
If you see anything to add
Dwarden asked me to do a bug report
(Also for @little eagle )
I think, there was already a bugtracker entry
IDK
Dwarden - Aujourd'hui ร 23:32
ye i need repro or seriously serious simple yet effective report ๐(รฉditรฉ)
Let's say this new one is less dusty
add a note with the Link to the other one? Maybe? Just an opinion?
I did
Seems like the ticket you gave me is in "Feature request" and not bug report
Could be why it didn't got fixed since march 2014
I just made an "example"
Check the 2nd Link, there are alot of other Entrys with the SetVariable problem
Yep I know there are others feebacks about this
But as Dwarden asked me to do a bug report, it's done and link sent in PM to him
So at least it could me more "accessible" for BI Dev team
Hey is anyone getting radio issues with the Intro and Outro modes of the editor?
I cannot seem to use sideRadio, groupRadio, globalRadio and vehicleRadio. (same issue applies with kbTell too)
the only command that works is "DIRECT" for kbTell and directSay
I have searched everywhere, but every single thread out there has been unsolved. :(
When doing addaction is there a way to prevent it from showing up on the players crosshair immediately?
@shadow sail: think that's the 'showWindow' parameter
Thanks!
Would anyone happen to know the default values of weapon sway and associated coefficients for ArmA 2?
It's totally different from A3.
Does anybody knows what has changed in 1.60 regarding Taru Pods? In Exile-Mod the pods are no longer accessible / lockable
@gleaming relic I know this was a while ago but does this help you? http://epochmod.com/forum/topic/37068-taru-pods-utilization-mod-script/?page=4
Seems that guy can get at least one of them working, wonder if their classnames changed?
Okay, I'm back and I'm still having issues with my helicopter redeploy function. At present, it's only grabbing one object from my array to redeploy, but it's clearing the whole array.
Anyone feel like taking a look?
https://forums.bistudio.com/topic/150500-development-branch-captains-ai-log/page-6#entry3038177
nice changes to AI vehicle crew bailout mechanics
Page 6 of 6 - Development Branch Captains AI Log - posted in ARMA 3 - DEVELOPMENT BRANCH: 13-05-2016Added: A default value for the AIAvoidStance to the Default class of cfgSurfaces (0 means no change in the behavior on that surface, 1 means less preference for going prone, 2 means almost never going prone)Relates to the previous post.
Is there an easy way to give all players the option to repair vehicles? Spawn them with a toolbox or?
@shadow sail, it's a little more complicated than that, but it's not super hard. Wait one and I can try to help you out.
@shadow sail, try this and let me know what happens. Paste it into your initplayerlocal.sqf:
player addAction ["Field Repair",{
_ct = cursorTarget;
_startTime = time;
_totalTime = time + 60;
[60, ['FIXING','','FIELD REPAIRING'], 'Acts_CarFixingWheel', true];
_dmg = getDammage _ct;
_ct setDamage _dmg;
},nil,1,true,false,"",'
("ToolKit" in items player || "ToolKit" in itemCargo cursorTarget) &&
(cursorTarget isKindOf "LandVehicle" or cursorTarget isKindOf "Ship" or cursorTarget isKindOf "Air") &&
speed cursorTarget <= 3 &&
player distance cursorTarget <= 4
'];```
and an easy way to include the ToolKit on all players?
Players have to wear a backpack to hold the toolkit, so you'll need at least:
_unit addItemToBackpack "ToolKit";```
In your loadout script.
Hey guys does anyone know how hard is to make a unit play an animation while in a vehicle?
Thanks a bunch DEL-J. โค
@jovial nebula, with Arma scripting, the question usually shouldn't be, "is it possible?" it should be, "how hard is it?"
Haha, good stuff. Anyway, I'm not very good at this stuff, so I don't know how to answer your question, but I know making a unit play an animation is usually very easy, but it seems like to make the units do it in a vehicle, you may have to know some commands that I don't know.
If you play an animation while in a vehicle
It should work
But you won't return to your sitting position
@dusk sage, does it matter if it's a switch move or play move animation?
Not enirely sure, I could imagine playMove would cause problems, switchMove wouldn't
@jovial nebula, take note!
@dusk sage, any chance you feel like helping me with my helicopter redeply function?
Lol i got it
Where is it?
I'll get you a paste or gist. Which do you prefer?
paste
so I can copy paste it
๐
Prefer reading from my own editor
Which really, means it doesnt matter
Jesus, too hot today
@dusk sage, http://pastebin.com/jdFEP4GC
The problem is that when the chopper spawns, only the first unit from the array gets added in to the chopper. That's not the only problem, but that's the big one.
The secondary problem is that most of the time, the players don't get "seated" in the chopper, they just levitate above their seat the whole ride in that "unknown" animation that happens when you're on a handrail or other thing you shouldn't be on, as if the chopper is freefalling to simulate microgravity.
How difficult is it to implement extdb for saving kills and deaths? Very few guides in regards to setting it up and even fewer in pulling out the data I am looking for. Or is there a way to keep kills and deaths persistent and also export those values when the server restarts?
I know I can do it using profileNamespace and eventhandlers in the mission itself, but I am interested in getting that data out and am not sure the best way.
Having a look now
PM @shadow sapphire
@shadow sail
Using extDB to save kills and deaths would be incredibly easy
Just keep a count, or even update on each death/kill
onPlayerKilled gives you the killer
Does anyone know a way to log who's drawing on map using that new feature? We have addon that logs placed markers but it doesn't log drawing...
don't you think iterating over all markers every frame is overkill?
it is
@lone glade, the moving target script with per frame event handler didn't work. I came up with an alternate idea that was much easier to use.
I can't find anything in regards to building the extDB database with MySQL. It seems as if the old extdb2 github repo is down and the bitbucket guide for extdb has no information regarding it. Where would I start?
Because both methods are equally bad
Thanks!
It's getting more and more subtle quicky :p
Alganthe, I'd add a draw eh to the map display
Building a database with MySQL has no special relation to extDB2. It will work absolutely fine on any database, regardless if it is for ARMA or not. So nail down making a simple SQL with a table, and Bob's your Uncle @shadow sail
that way only markers are deleted if the map is shown
I'll do that then.
Okay, so I can just make it whatever and then put the credentials in the extdb config and go from there?
yep
Thanks!
It executes simple commands, that is all
you spend like 1% of the time on the map, so huge improvement
won't happen. computers are really bad at identifying pictures
see reverse image seatch ...
we need that penii detection algorithm in arma 3
good luck doing that
doesn't sound that hard
but it probably won't happen
you have to know WHO made a marker
idk if there is a way for that
:/
still a PITA
that deletes all markers for that player
everyone who is in that white list would either still see the markers
or see no markers
depends on if deleting them is global
it's global afaik
So if there is at least one client that is not whitelisted on a map
all ploylines vanish
stringtable.csv no longer usable wih 1.60 ?
can't find the strings anymore
You can use setVar / getVar on markers ?
the code above should work, it can be improved tho.
no
merge the two IFs into one and use in instead of that BIS func
going to grab a bite, I'll check after that, I don't have much to do :p
How would I implement a HandleDisconnect event handler to delete any vehicles spawned by a player? And is there an eventhandler for switching squads or positions on the same side?
store the spawned vehicle object references in a public object namespace variable
and on dc, iterate through the array and delete the objects
and what about switching squads or roles?
is there an EH for that?
and do you have an example by chance of any of this?
switching groups? The object would stay the same
right I mean is there an EH to handle switching groups?
Switching roles? how? HandleDisconnect should fire when returning to the lobby
Ah
if the script is referenced by multiple people and it sets a publicVariable will they all get overwritten?
there is no event hander for switching groups
okay
if the script is referenced by multiple people and it sets a publicVariable will they all get overwritten?
nonono
not a global variable
a public object namespace variable
player setVariable ["blah", [<array>], true]
ah okay, I have that currently for when the script fires a second time it deletes the previous iteration
player setVariable ["prevCrate", _veh];
yes. You make that one an array and append it every time you spawn a vehicle
So the event handler would be PlayerDisconnected
player addMPEventHandler ["PlayerDisconnected", {deleteVehicle _prevCrate; deleteVehicle _prevChute}];?
doh
you use it on the server
okay
Secondly, PlayerDisconnected is kinda broken atm
hmm so how should I go about this? HandleDisconnect or?
alternative:
["myTag_myOPD", "onPlayerDisconnected", { script }] call BIS_fnc_addStackedEventHandler
myOPD?
just a string to identify the thing
ah okay
can be anything, but should be tagged
so I would say ["_veh","onPlayerDisconnected", { deleteVehicle _prevCrate }] call BIS_fnc_addStackedEventHandler ?
what is your tag?
prevCrate
ah
["_prevCrate", "onPlayerDisconnected", { deleteVehicle _prevCrate }] call BIS_fnc_addStackedEventHandler
right? since _prevCrate is assigned by player setVariable ["prevCrate", _veh];
onPlayerDisconneted is not what you want
that was in your example?
addMissionEventHandler ["HandleDisconnect", {
params ["_unit"];
private _objects = _unit getVariable ["thearray", []];
{
} forEach _objects;
}];
HandleDisconnect != (on)PlayerDisconnected
ah
HandleDisconnect gives the old player object, OPD does not
also HandleDisconnect isn't broken
I see, so that will grab the player unit info when they disconnect, get the variable I defined in "thearray" from "_unit" and then iterate over each object, right?
I know the actual action is missing in your example I just wanted to make sure I understood
yes
params ["_unit"];
private _objects = _unit getVariable ["_prevCrate", []];
{ deleteVehicle
} forEach _objects;
}];```
right?
sure. it'd choose a different variable name, but whatever
why so?
"_prevCrate" means "prvious crate"
crateS
well there can only be one per player, there is an if (!isNil) check to see if there is a prevcrate and it deletes it to prevent the server from filling up
I just wanted a way if they left to also get rid of it
also , having a global variable with underscore is confusing and strange
well its private at the moment, I realize I have to make it global
gonna change that
I think you completely misunderstood that
private _crate = ...createVehicle
^ local variable
player setVariable ["MyTag_crate", _crate, true];
^ global public (object namespace) varibale
setVariable always is about global variables
About tags...
It is good practice to name your global variables with a tag
So they don't collide with global variables of the base game or other mods and missions
It also indicates what a global variable is and what a scripting command
So it makes the code easier to read
You can't for example not name your global variable "items", because "items" is a scripting command
gotcha
If you used "params" as global variable before 1.44 your script would've been broken by BI adding a command with that name later
So you should name them "MyTag_params" or "MyTag_items"
ahh
EH only needed to be executed once, correct? So I could put that in its own SQF and execVM in init.sqf?
only once and only on the server
so if (isServer) or initServer?
doesn't matter