Jump to content

MechSlayer

Member
  • Content Count

    90
  • Joined

  • Last visited

  • Medals

Everything posted by MechSlayer

  1. Extension to make http requests, currently supporting: GET POST PATCH DELETE PUT First parameter is the mode. Second is the method. Third is the url. Fourth is the authorization, if no authorization needed just pass null Fifth is the request body, only used by POST, PATCH and PUT, if no body needed just pass {} GET request example: "ArmaRequests" callExtension "0|GET|http://headers.jsontest.com/|null"; waitUntil {sleep 1; "ArmaRequests" callExtension "2" == "OK"}; _response = "ArmaRequests" callExtension "1"; _parsedResponse = parseSimpleArray _response; _code = _parsedResponse select 0; _data = _parsedResponse select 1; //Response => [["X-Cloud-Trace-Context","47e3637379c2b3d638285b973e0e4f96/4228286279360018440"],["Host","headers.jsontest.com"]] POST request example: "ArmaRequests" callExtension '0|POST|url|Bot ksZc83aS|{"Number": 4, "String": "String"}'; waitUntil {sleep 1; "ArmaRequests" callExtension "2" == "OK"}; _response = "ArmaRequests" callExtension "1"; _parsedResponse = parseSimpleArray _response; _code = _parsedResponse select 0; _data = _parsedResponse select 1; Every response comes with a status code 0: All data received 1: There's still data to receive 9: Error The codes you can use are 0: New request 1: Receive data 2: Get extension status 3: Parse JSON //Example: "ArmaRequests" callExtensions '3|{"age": 80}'; Due to string length limitations, if the response exceeds that limit it will be sent in chunks with status code 1, to receive the chunk use _fullResponse = ""; // _chunkResponse = "ArmaRequests" callExtension "1"; _parsedChunkResponse = parseSimpleArray _chunkResponse; _code = _chunkResponse select 0; _data = _chunkResponse select 1; _fullResponse = _fullResponse + _data; //You must repeat the receiving process until it responds with a code 0 When there's no more data left, it will respond with a code 0. JSON responses are automatically parsed into arrays, all common variables type are supported. Example code _fullResponse = ""; "ArmaRequests" callExtension "0|GET|http://headers.jsontest.com/|null"; //Send request waitUntil {sleep 1; "ArmaRequests" callExtension "2" == "OK"}; _response = "ArmaRequests" callExtension "1"; _parsedResponse = parseSimpleArray _response; //Parse response _code = _parsedResponse select 0; //Save code and data _data = _parsedResponse select 1; if (_code != 9) then { //Check if is a error _fullResponse = _data; //Assign the data in the full response while {_code == 1} do { //if there's more data receive it _chunkResponse = "ArmaRequests" callExtension "1"; //Receive next chunk data _parsedChunkResponse = parseSimpleArray _chunkResponse; //Parse the chunk data _code = _parsedChunkResponse select 0; //Update the status code _data = _parsedChunkResponse select 1; //Save the data if (_code == 9) exitWith {hint "Error : " + _data;}; //Check if is a error _fullResponse = _fullResponse + _data; //Append the chunk to the full response }; hint str _fullResponse; } else { hint "Error during request " + _data; }; There's also a callback version "ArmaRequestsCallback" callExtension "callbackFunction|Method|url|authorization?|body?"; Example using callback version and normal version TAG_fnc_DiscordMessageSent = { params["_data"]; //[["id","651314298001424405"],["type",0],["content","Hello"],["channel_id","649607925760786442"],["author",[["id","629121190182780929"],["username","Fantasia"],["avatar",null],["discriminator","2964"],["bot",true]]],["attachments",[]],["embeds",[]],["mentions",[]],["mention_roles",[]],["pinned",false],["mention_everyone",false],["tts",false],["timestamp","2019-12-03T06:50:29.478000+00:00"],["edited_timestamp",null],["flags",0],["nonce",null]] _content = (_data select 2) select 1; _username = (((_data select 4) select 1) select 1) select 1; _channelId = (_data select 3) select 1; "ArmaRequests" callExtension format["0|GET|https://discordapp.com/api/v6/channels/%1|Bot TOKEN|{}", _channelId]; waitUntil {sleep 1; "ArmaRequests" callExtension "2" == "OK"}; _channelData = (parseSimpleArray ("ArmaRequests" callExtension "1")) select 1; _channelName = (_channelData select 3) select 1; _guildId = (_channelData select 7) select 1; "ArmaRequests" callExtension format["0|GET|https://discordapp.com/api/v6/guilds/%1|Bot TOKEN|{}", _guildId]; waitUntil {sleep 1; "ArmaRequests" callExtension "2" == "OK"}; _guildData = (parseSimpleArray ("ArmaRequests" callExtension "1")) select 1; _guildName = (_guildData select 1) select 1; hint format["Sent %1 as %2 in the channel %3 of the guild %4", _content, _username, _channelName, _guildName]; }; addMissionEventHandler ["ExtensionCallback", { params["_name", "_function", "_data"]; if (_name == "ArmaRequestsCallback_JSON") then { [parseSimpleArray _data] spawn (missionNamespace getVariable [_function, { diag_log format["ArmaRequestsCallback: Tried to call %1, but isn't defined", _function]; }]); }; if (_name == "ArmaRequestsCallback_Error") then { hint "Request error: " + _data; }; if (_name == "ArmaRequestsCallback_TEXT") then { systemChat _data; }; }]; "ArmaRequestsCallback" callExtension "TAG_fnc_DiscordMessageSent|POST|https://discordapp.com/api/v6/channels/649607925760786442/messages|Bot BOT|{""content"": ""Hello"", ""tts"": false}"; Download link: https://drive.google.com/file/d/1-9oW3PhArHbs15AS4c6R5UQuuk6usInC/view
  2. I'm trying to spawn weapons inside each building in the map, but for some reason more than half spawns as ObjNull Here's the code: _buildings = nearestObjects[_worldCenter, ["building"], (worldName call BIS_fnc_mapSize)]; //Get all buildings. { _buildingPositions = _x buildingPos -1; //Get all positions inside the building. _localPos = selectRandom _buildingPositions; //Select a random one. _spawnPos = [(_localPos select 0), (_localPos select 1), ((_localPos select 2) + 1)]; //Elevate the position 1 meter. _holder = createVehicle ["WeaponHolderSimulated", _spawnPos, [], 0, "CAN_COLLIDE"]; //Spawn the weapon holder. _weapon = selectRandom _weaponsArray; //Select a random weapon. _holder addItemCargoGlobal [_weapon, 1]; //Add the weapon to the holder. } forEach _buildings;
  3. MechSlayer

    Http requests extension

    I tried it first, but the game or c#, converts the parameters to strings even if they already are. Making "string" to """string"""
  4. I need to spawn around 700 units, does anyone know a fast method to do this? Tried a for loop but after hitting 100 units it starts to spawn way too slow. I'm spawning them serverside. Thanks.
  5. MechSlayer

    Http requests extension

    Okey, no more freezing, also the json responses are parsed to arrays (The downside is that only works with numbers, strings, booleans and null values). It looks like the output max size is set by the engine so i can't get rid of it.
  6. MechSlayer

    Http requests extension

    Strange, when I try sending more characters than the output size it throws me buffer overrun
  7. MechSlayer

    Http requests extension

    Now I feel stupid for not thinking about callbacks, the problem is that I have no idea about changing the output size limit
  8. Just a script where you can create interactions without touching the code. It supports Images and text (No background color). It opens with the Left Windows Key. You can add new interactions by editing "Interacciones\initInteracciones.sqf". Inside it's the syntaxis. When you'r writing the Condition or the script to execute you must use ' ' instead of " ". Here's the mission Some screenshots
  9. I have a zombie agent, how can I make it attack players? (By attack I mean only hitting)
  10. You need at least one interaction created inside "fn_initInteracciones.sqf". That errors happens if the script doesn't loop through the "Interacciones_Interacciones" variable.
  11. Try changing player to _unit inside onplayerRespawn.sqf Also you need to pass _unit and _corpse parameters from the event handler.
  12. MechSlayer

    Spawn ai behind selected player

    To get the players you can use _playercount = playableUnits select {_x distance getMarkerPos "Marker1" < 200 && isPlayer _x} For a random unit just use _unit = selectRandom _playercount To spawn the unit behind just change _unit getpos [250,random 50] to _unit getpos [-250,random 50] Or if you want a random distance: _unit getPos [random[-40, -100, -250], random 50] (-40 is the minimum distance, -100 the mid distance and -250 the maximum distance) If you ONLY need to wait, remove the sleep from waitUntil.
  13. _group = createGroup west; {if (side _x == civilian) then {[_x] joinSilent _group;}} forEach allPlayers; Or if you want every player to join blufor _group = createGroup west; allPlayers joinSilent _group;
  14. MechSlayer

    Can't save a .sqf file

    If execVM doesn't work you can also try call compile preprocessFileLineNumbers "rem.sqf";
  15. I've got a problem, when I set a picture that's inside a RscTitles and I try to change the file (photo.paa) to another, it keeps showing the first one. It only changes if I change the name of the file. .hpp class RscTitles { class RscProgress { type = 8; style = 1; colorFrame[] = {0,0,0,1}; colorBar[] = {1,1,1,1}; texture = "#(argb,8,8,3)color(1,1,1,1)"; w = 1; h = 0.03; }; class HUD { idd = 5000; movingEnable = 0; enableSimulation = 1; enableDisplay = 1; duration = 9999999999999; fadein = 0.1; fadeout = 2; name = "HUD"; onLoad = "player setVariable ['stats', _this, true];"; class controlsBackground { class Progress: RscProgress { idc = 1100; colorBar[] = {0.91,0.024,0.024,1}; x = 0.874062 * safezoneW + safezoneX; y = 0.71 * safezoneH + safezoneY; w = 0.02625 * safezoneW; h = 0.042 * safezoneH; }; }; class controls { class RscPicture_1200: RscPicture { idc = 1200; x = 0.834688 * safezoneW + safezoneX; y = 0.626 * safezoneH + safezoneY; w = 0.13125 * safezoneW; h = 0.42 * safezoneH; }; }; }; }; .sqf 1 cutRsc ["HUD","PLAIN",-1,false]; _display = (player getVariable "stats" select 0); _texto = _display displayCtrl 1100; _foto = _display displayCtrl 1200; _foto ctrlsetText "Fotos\persona.paa"; while {true} do { _dano = damage player; _vida = 1 - _dano; _texto progressSetPosition _vida; sleep 0.5; };
  16. How can I get the preview image of the objects like in the 3den editor? (When you place the cursor over a object from the list)
  17. Is it possible to get all the mission displays? (Not the opened like when you use allDisplays, but all that are loaded)
  18. MechSlayer

    RscTitles disappears on death

    The script that I use it's the second, and already tried to create it again, but the RscTitles variable disappears
  19. I have this RscTitles dialog: class HUD { idd = 6000; movingEnable = 0; enableSimulation = 1; enableDisplay = 1; duration = 9999999999999999999999999; fadein = 0.1; fadeout = 2; name = "HUD"; onLoad = "uiNamespace setVariable ['HUDD', _this select 0];"; class controls { class Hambre: RscProgressH { idc = 1600; colorBar[] = {0,0.369,0.043,1}; x = 0.906894 * safezoneW + safezoneX; y = 0.933944 * safezoneH + safezoneY; w = 0.0803196 * safezoneW; h = 0.0219304 * safezoneH; }; class Sed: RscProgressH { idc = 1601; colorBar[] = {0,0.259,0.678,1}; x = 0.906894 * safezoneW + safezoneX; y = 0.96194 * safezoneH + safezoneY; w = 0.0803196 * safezoneW; h = 0.0219304 * safezoneH; }; }; }; I open it with this code: disableSerialization; _display = uiNamespace getVariable "HUDD"; _hambred = _display displayCtrl 1600; _sedd = _display displayCtrl 1601; It works fine when you enter the server, but when you die and respawn it disappears and the the display stored in uiNamespace changes to "No Display". I tried calling it again but didn't worked. Any fix?
  20. Is it possible to make cameras created with camCreate global and use it inside a dialog?
  21. For some reason the signatures won't work and just keeps telling me that I have unsigned content. I signed every .pbo inside the addons folder using DSUtils Pasted the .bikey file inside the Keys folder of the Arma 3 Server, enabled verify signatures on v1 But when I try to join it just keeps telling me that the mods aren't signed TADST Config
  22. MechSlayer

    Signatures problem

    Yes, we bought NoPixel and it comes with the permissions
×