CONNEXION
  • RetourJeux
    • Sorties
    • Hit Parade
    • Les + populaires
    • Les + attendus
    • Soluces
    • Tous les Jeux
    • Gaming
  • RetourActu Gaming
    • News
    • Astuces
    • Tests
    • Previews
    • Toute l'actu gaming
  • RetourBons plans
    • Bons plans
    • Bons plans Smartphone
    • Bons plans Hardware
    • Bons plans Image et Son
    • Bons plans Amazon
    • Bons plans Cdiscount
    • Bons plans Decathlon
    • Bons plans Fnac
    • Tous les Bons plans
  • RetourJVTech
    • Actus High-Tech
    • Intelligence Artificielle
    • Smartphones
    • Mobilité urbaine
    • Hardware
    • Image et son
    • Tutoriels
    • Tests produits High-Tech
    • Guides d'achat High-Tech
    • JVTech
  • RetourCulture
    • Actus Culture
    • Culture
  • RetourVidéos
    • A la une
    • Gaming Live
    • Vidéos Tests
    • Vidéos Previews
    • Gameplay
    • Trailers
    • Chroniques
    • Replay Web TV
    • Toutes les vidéos
  • RetourForums
    • Hardware PC
    • PS5
    • Switch 2
    • Xbox Series
    • Switch
    • Pokemon pocket
    • FC 25 Ultimate Team
    • League of Legends
    • Tous les Forums
  • PC
  • PS5
  • Xbox Series
  • Switch 2
  • PS4
  • One
  • Switch
  • iOS
  • Android
  • MMO
  • RPG
  • FPS
En ce moment Genshin Impact Valhalla Breath of the wild Animal Crossing GTA 5 Red dead 2
Forum
  • Accueil
  • Actus
  • Tests
  • Vidéos
  • Images
  • Soluces
  • Forum
Liste des sujets

Aide Script Arma 3 : Spawn véhicule.

JO_CMD
JO_CMD
Niveau 1
31 mars 2019 à 10:45:21

Bonjour à tous !

Je viens rechercher votre aide pour un script de véhicule déjà existant que je veux modifier pour l'améliorer un peu.
Lien du script : http://www.armaholic.com/page.php?id=23020

Je m'explique, j'ai rajouté un bouton a coché (onCheckedChanged)
Je veux lorsque le bouton est coché, mon véhicule apparaisse avec un ARSENAL (VAS) grace à un addAction.
A l'inverse lorsque le bouton est décoché mon véhicule apparaît sans ARSENAL.

Mon script fonctionne à moitié,
quand je spawn un véhicule en cochant la case, il apparait bien avec le VAS, mais quand je quitte la boite de dialogue et que je la relance, le bouton est décoché mais considéré comme activé. Pour spawn un véhicule sans VAS je dois le cocher puis décocher.

En soit ça fonctionne, mais j'aime le travail bien fait et j'ai envie d'améliorer mes connaissances...
donc amis scripteur je fais appel à vous.

Voici mes scripts entier, je mettrais en dessous les parties que j'ai rajouté.

ENTIER

menu.h

#include "resource.h"
#include "defines.h"

class VAScheckbox {
	access = 0; // Control access (0 - ReadAndWrite, 1 - ReadAndCreate, 2 - ReadOnly, 3 - ReadOnlyVerified)
	idc = -1; // Control identification (without it, the control won't be displayed)
	type = 77; // Type
	style = ST_LEFT + ST_MULTI; // Style
	default = 0; // Control selected by default (only one within a display can be used)
	blinkingPeriod = 0; // Time in which control will fade out and back in. Use 0 to disable the effect.
	
	x = 0;
	y = 0;
	w = 1 * GUI_GRID_CENTER_W; // Width
	h = 1 * GUI_GRID_CENTER_H; // Height

	//Colors
	color[] = { 1, 1, 1, 0.7 }; // Texture color
	colorFocused[] = { 1, 1, 1, 1 }; // Focused texture color
	colorHover[] = { 1, 1, 1, 1 }; // Mouse over texture color
	colorPressed[] = { 1, 1, 1, 1 }; // Mouse pressed texture color
	colorDisabled[] = { 1, 1, 1, 0.2 }; // Disabled texture color

	//Background colors
	colorBackground[] = { 0, 0, 0, 0 }; // Fill color
	colorBackgroundFocused[] = { 0, 0, 0, 0 }; // Focused fill color
	colorBackgroundHover[] = { 0, 0, 0, 0 }; // Mouse hover fill color
	colorBackgroundPressed[] = { 0, 0, 0, 0 }; // Mouse pressed fill color
	colorBackgroundDisabled[] = { 0, 0, 0, 0 }; // Disabled fill color

	//Textures
	textureChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";		//Texture of checked CheckBox.
	textureUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";		//Texture of unchecked CheckBox.
	textureFocusedChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";	//Texture of checked focused CheckBox (Could be used for showing different texture when focused).
	textureFocusedUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";	//Texture of unchecked focused CheckBox.
	textureHoverChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";
	textureHoverUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";
	texturePressedChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";
	texturePressedUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";
	textureDisabledChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";
	textureDisabledUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";

	tooltip = ""; // Tooltip text
	tooltipColorShade[] = { 0, 0, 0, 1 }; // Tooltip background color
	tooltipColorText[] = { 1, 1, 1, 1 }; // Tooltip text color
	tooltipColorBox[] = { 1, 1, 1, 1 }; // Tooltip frame color

	//Sounds
	soundClick[] = { "\A3\ui_f\data\sound\RscButton\soundClick", 0.09, 1 }; // Sound played after control is activated in format {file, volume, pitch}
	soundEnter[] = { "\A3\ui_f\data\sound\RscButton\soundEnter", 0.09, 1 }; // Sound played when mouse cursor enters the control
	soundPush[] = { "\A3\ui_f\data\sound\RscButton\soundPush", 0.09, 1 }; // Sound played when the control is pushed down
	soundEscape[] = { "\A3\ui_f\data\sound\RscButton\soundEscape", 0.09, 1 }; // Sound played when the control is released after pushing down
};

class VAStext {
	x = 0;
	y = 0;
	h = 0.037;
	w = 0.3;
	type = 0;
	style = 0;
	shadow = 1;
	colorShadow[] = {0, 0, 0, 0.5};
	font = "PuristaMedium";
	SizeEx = "(			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
	text = "";
	colorText[] = {1, 1, 1, 1.0};
	colorBackground[] = {0, 0, 0, 0};
	linespacing = 1;
};


class VVS_Menu
{
	idd = VVS_Menu_IDD;
	name = "VVS_Menu";
	movingEnabled = false;
	enableSimulation = true;
	onLoad = "[] spawn VVS_fnc_mainDisplay;";
	
	class controlsBackground
	{
		class titleBackground : VVS_RscText
		{
			idc = -1;
			colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.7])"};
			x = 0.1;
			y = 0.2;
			w = 0.8;
			h = (1 / 25);
		};
		
		class MainBackground : VVS_RscText
		{
			idc = -1;
			colorBackground[] = {0,0,0,0.76};
			x = 0.1;
			y = 0.2 + (11 / 250);
			w = 0.8;
			h = 0.6 - (22 / 250);
		};
		
		class Footer : VVS_RscText
		{
			idc = -1;
			colorBackground[] = {0,0,0,0.8};
			x = 0.1;
			y = 0.805;
			w = 0.8;
			h = (1 / 25);
		};
		
		class ClearCargoText : VVS_RscText
		{
			idc = -1;
			colorBackground[] = {0,0,0,0};
			text = "Emplacement libre:";
			sizeEx = 0.04;
			x = 0.105;
			y = 0.805;
			w = 0.8;
			h = (1 / 25);
		};
		
		class CargoCheck : VVS_RscActiveText 
		{
			idc = VVS_CargoCheck;
			text = "Non";
			action = "[] call VVS_fnc_checkBox";
			sizeEx = 0.04;
// def 2015 09 19>
			colorDisabled[] = {1, 1, 1, 0.3};
// <def 2015 09 19
			x = 0.32; y = 0.805;
			w = 0.275; h = 0.04;
		};
		
		class Title : VVS_RscTitle
		{
			colorBackground[] = {0, 0, 0, 0};
			idc = -1;
			text = "POOL VEHICULE";
			x = 0.1;
			y = 0.2;
			w = 0.8;
			h = (1 / 25);
		};
	};
	
	class controls
	{
		class vehicleListNew : VVS_RscListNBox
		{
			idc = VVS_VehicleList;
			text = "";
			sizeEx = 0.04;
			columns[] = {0,0.105,0.5,0.8};
			drawSideArrows = false;
			idcLeft = -1;
			idcRight = -1;
			rowHeight = 0.050;
			x = 0.1; y = 0.26;
			w = 0.8; h = 0.49 (22 / 250);
		};
		
		class FilterList : VVS_RscCombo
		{
			idc = VVS_FilterList;
			colorBackground[] = {0,0,0,0.7};
			onLBSelChanged  = "_this call VVS_fnc_filterList";
			x = 0.244 + (6.25 / 19.8) + (1 / 250 / (safezoneW / safezoneH));
			y = 0.8 - (1 / 25);
			w = 0.34; h = (1 / 25);
		};
		
		class ButtonClose : VVS_RscButtonMenu 
		{
			idc = -1;
			text = "Fermer";
			onButtonClick = "closeDialog 0;";
			x = 0.1;
			y = 0.8 - (1 / 25);
			w = (6.25 / 40);
			h = (1 / 25);
		};
		
		class ButtonSettings : VVS_RscButtonMenu 
		{
			idc = -1;
			text = "Valider";
			onButtonClick = "[] spawn VVS_fnc_spawnVehicle";
			x = 0.1 + (6.25 / 40) + (1 / 250 / (safezoneW / safezoneH));
			y = 0.8 - (1 / 25);
			w = (6.25 / 40);
			h = (1 / 25);
		};
		
				class ObjectSyncCheckbox : VAScheckbox
		{
			idc = -1;
			x = 0.75; y = 0.805;
			tooltip = "Rajoute un ARSENAL au véhicule";
			onCheckedChanged = "if((_this select 1) == 1) then {Vas_Vhl = true;} else {Vas_Vhl = false;};";
			w = 1 * GUI_GRID_CENTER_W;
			h = 1 * GUI_GRID_CENTER_H; 
		};

		class ObjectSynctext : VAStext {
			idc = -1;
			text = "ARSENAL";
			x = 0.78; y = 0.805;
			w = .35; h = .04;
		};
		
	};
};

fn_spawnVehicle.sqf

disableSerialization;
private["_position","_direction","_className","_displayName","_spCheck","_cfgInfo"];
if(lnbCurSelRow 38101 == -1) exitWith {hint "Vous n'avez pas sélectionner de véhicule à faire apparaitre."};

_className = lnbData[38101,[(lnbCurSelRow 38101),0]];
_displayName = lnbData[38101,[(lnbCurSelRow 38101),1]];
_position = getMarkerPos VVS_SP;
_direction = markerDir VVS_SP;

//Make sure the marker exists in a way.
if(isNil "_position") exitWith {hint "Le marqueur d'apparition n'existe pas.";};

//Check to make sure the spawn point doesn't have a vehicle on it, if it does then delete it.
_spCheck = nearestObjects[_position,["landVehicle","Air","Ship"],12] select 0;
if(!isNil "_spCheck") then {deleteVehicle _spCheck;};

_cfgInfo = [_className] call VVS_fnc_cfgInfo;

_vehicle = _className createVehicle _position;
_vehicle allowDamage false;
_vehicle setPos _position; //Make sure it gets set onto the position.
_vehicle setDir _direction; //Set the vehicles direction the same as the marker.


if(Vas_Vhl) then {
	_vehicle addaction ["<t color=""#FF0000"">ARSENAL",{["Open",true] call BIS_fnc_arsenal}];
} 
else {};







if((_cfgInfo select 4) == "Autonomous") then
{
	createVehicleCrew _vehicle;
};

if(VVS_Checkbox) then
{
	clearWeaponCargoGlobal _vehicle;
	clearMagazineCargoGlobal _vehicle;
	clearItemCargoGlobal _vehicle;
};

_vehicle allowDamage true;
hint format["Vous avez fait apparaitre un %1",_displayName];
closeDialog 0;

voilà pour le gros du scipt, maintenant la partie qui nous intéresse.

menu.h

class VAScheckbox {
	access = 0; // Control access (0 - ReadAndWrite, 1 - ReadAndCreate, 2 - ReadOnly, 3 - ReadOnlyVerified)
	idc = -1; // Control identification (without it, the control won't be displayed)
	type = 77; // Type
	style = ST_LEFT + ST_MULTI; // Style
	default = 0; // Control selected by default (only one within a display can be used)
	blinkingPeriod = 0; // Time in which control will fade out and back in. Use 0 to disable the effect.
	
	x = 0;
	y = 0;
	w = 1 * GUI_GRID_CENTER_W; // Width
	h = 1 * GUI_GRID_CENTER_H; // Height

	//Colors
	color[] = { 1, 1, 1, 0.7 }; // Texture color
	colorFocused[] = { 1, 1, 1, 1 }; // Focused texture color
	colorHover[] = { 1, 1, 1, 1 }; // Mouse over texture color
	colorPressed[] = { 1, 1, 1, 1 }; // Mouse pressed texture color
	colorDisabled[] = { 1, 1, 1, 0.2 }; // Disabled texture color

	//Background colors
	colorBackground[] = { 0, 0, 0, 0 }; // Fill color
	colorBackgroundFocused[] = { 0, 0, 0, 0 }; // Focused fill color
	colorBackgroundHover[] = { 0, 0, 0, 0 }; // Mouse hover fill color
	colorBackgroundPressed[] = { 0, 0, 0, 0 }; // Mouse pressed fill color
	colorBackgroundDisabled[] = { 0, 0, 0, 0 }; // Disabled fill color

	//Textures
	textureChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";		//Texture of checked CheckBox.
	textureUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";		//Texture of unchecked CheckBox.
	textureFocusedChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";	//Texture of checked focused CheckBox (Could be used for showing different texture when focused).
	textureFocusedUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";	//Texture of unchecked focused CheckBox.
	textureHoverChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";
	textureHoverUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";
	texturePressedChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";
	texturePressedUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";
	textureDisabledChecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_checked_ca.paa";
	textureDisabledUnchecked = "\A3\Ui_f\data\GUI\RscCommon\RscCheckBox\CheckBox_unchecked_ca.paa";

	tooltip = ""; // Tooltip text
	tooltipColorShade[] = { 0, 0, 0, 1 }; // Tooltip background color
	tooltipColorText[] = { 1, 1, 1, 1 }; // Tooltip text color
	tooltipColorBox[] = { 1, 1, 1, 1 }; // Tooltip frame color

	//Sounds
	soundClick[] = { "\A3\ui_f\data\sound\RscButton\soundClick", 0.09, 1 }; // Sound played after control is activated in format {file, volume, pitch}
	soundEnter[] = { "\A3\ui_f\data\sound\RscButton\soundEnter", 0.09, 1 }; // Sound played when mouse cursor enters the control
	soundPush[] = { "\A3\ui_f\data\sound\RscButton\soundPush", 0.09, 1 }; // Sound played when the control is pushed down
	soundEscape[] = { "\A3\ui_f\data\sound\RscButton\soundEscape", 0.09, 1 }; // Sound played when the control is released after pushing down
};

class VAStext {
	x = 0;
	y = 0;
	h = 0.037;
	w = 0.3;
	type = 0;
	style = 0;
	shadow = 1;
	colorShadow[] = {0, 0, 0, 0.5};
	font = "PuristaMedium";
	SizeEx = "(			(			(			((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)";
	text = "";
	colorText[] = {1, 1, 1, 1.0};
	colorBackground[] = {0, 0, 0, 0};
	linespacing = 1;
};
class controls
	{
		class ObjectSyncCheckbox : VAScheckbox
		{
			idc = -1;
			x = 0.75; y = 0.805;
			tooltip = "Rajoute un ARSENAL au véhicule";
			onCheckedChanged = "if((_this select 1) == 1) then {Vas_Vhl = true;} else {Vas_Vhl = false;};";
			w = 1 * GUI_GRID_CENTER_W;
			h = 1 * GUI_GRID_CENTER_H; 
		};

		class ObjectSynctext : VAStext {
			idc = -1;
			text = "ARSENAL";
			x = 0.78; y = 0.805;
			w = .35; h = .04;
		};
		
	};
};

fn_spawnVehicle.sqf

if(Vas_Vhl) then {
	_vehicle addaction ["<t color=""#FF0000"">ARSENAL",{["Open",true] call BIS_fnc_arsenal}];
} 
else {};

Merci par avance si vous vous donnez la peine de m'aider,
bonne journée !

JO_CMD

Message édité le 31 mars 2019 à 10:50:14 par JO_CMD
chal00
chal00
Niveau 10
01 avril 2019 à 02:51:35

Salut :-)))

Je viens de jeter un oeil vite fait sur ce que tu as posté.
Suis sur mobile et j'ai donc pas le script entier devant moi..
Cependant j'ai vite compris ce qui t'arrive !
Dans ton menu.h tu utilises la commande "onCheckedChanged"... hors comme son nom laisse supposer, mais j'ai vérifié tout de même ( https://community.bistudio.com/wiki/User_Interface_Event_Handlers#onCheckedChanged ), ça ne se déclenche que lorsque la case est changée (cochée ou décochée )...

Hors visiblement, il n'y a qu'à ce moment que tu définis la valeur de ta variable globale Vas_Vhl !
Donc pas étonnant en fait que tu sois obligé de coher/décocher pour faire ta variable revenir à false.

Ce qu'il te faut donc c'est définir la valeur de cette variable à false chaque fois que tu lances le script...
Sur mobile, je vois que la 1ère fonction lancée est celle-ci : VVS_fnc_openVVS
Tu peux peut être juste rajouter
Vas_Vhl = false;
au début de cette fonction ou (bien ailleurs) :-)))

Message édité le 01 avril 2019 à 02:52:05 par chal00
Sous forums
  • Les modes Life
  • Configurations PC et ses problèmes
  • Teams et Serveurs
  • Teams et Serveurs MilSim
La vidéo du moment