Jump to content

fauconjona

Member
  • Content Count

    20
  • Joined

  • Last visited

  • Medals

Posts posted by fauconjona


  1. 2 hours ago, silola said:

    Hi,

     

    is there anything to consider if I switch to "addMissionEventHandler", because it's not working for me :(

    I've tried this so far:

     

    _ef = addMissionEventHandler ["EachFrame", xCam_fCamUnit];
    _ef = addMissionEventHandler ["EachFrame",{ _this execVM "xCam\xCam_Cam_Unit.sqf" }];

     

     

    Silola

     

    I found the solution:

     

    in xCam_Press_Btn.sqf:

     

    replace:

    _ef = ["xCam_EF_ID", "onEachFrame", xCam_fCamObject] call BIS_fnc_addStackedEventHandler;

     by :

    onEachFrame{
    	[] spawn xCam_fCamObject;
    };

     

    And, in xCam_Cam_Object.sqf:

     

    add this on begin (I don't know why it doen't inisialized in xCam_Start_UI.sqf):

    if(isNil 'xcam_vector_marker')then
    {
    	xCam_Vector_Marker = createVehicle ["Sign_Sphere10cm_F", (position player), [], 0, "NONE"];
    };

     

    And done, you can move the camera ;)

    • Like 3

  2. Hello everybody,

     

    I'm creating an extension to remote sqf function by socket.

     

    For the moment I'm just trying to connect to the server, start the process by calling extension from arma and execute the client application.

     

    But, I can't connect and when I look the log I have "Client connected" on every frame even without my client application.

     

    Before, create the .dll I tried with a server application and there's no problem.

    
    #include "stdafx.h"
    
    #include <unordered_map> 
    #include <thread> 
    #include <mutex> 
    #include <atomic> 
    
    #pragma comment(lib,"Ws2_32.lib")
    #include <WinSock2.h>
    #include <iostream>
    #include <string>
    #include <fstream>
    
    #include "Log.h"
    
    const int MAX_CONNECTION = 20;
    char PASSWORD[MAX_CONNECTION];
    char IP[MAX_CONNECTION];
    int PORT;
    const int MESSAGE_SIZE = 256;
    
    SOCKET connections[MAX_CONNECTION];
    int connectionCounter = 0;
    
    bool socketWorking = false;
    
    using namespace std;
    struct Data
    {
    	bool ready = false;
    	string params = "";
    	string result = "";
    };
    
    unordered_map<long int, Data> tickets;
    mutex mtx;
    atomic<bool> worker_working(false);
    long int id = 0; // global ticket id 
    long int cur_id = 0; // current ticket id
    
    int clientHandlerThread(int index)
    {
    	char buffer[MESSAGE_SIZE];
    
    	//password check
    
    	writeInFile("connection", "Waiting for password");
    
    	recv(connections[index], buffer, sizeof(buffer), NULL);
    
    	if (strcmp(buffer, PASSWORD) != 0)
    	{
    		strcpy_s(buffer, "refused");
    		send(connections[index], buffer, sizeof(buffer), NULL);
    		connectionCounter--;
    		return 0;
    	}
    	else
    	{
    		strcpy_s(buffer, "accepted");
    		send(connections[index], buffer, sizeof(buffer), NULL);
    	}
    
    
    	while (strcmp(buffer, "exit") != 0)
    	{
    		recv(connections[index], buffer, sizeof(buffer), NULL);
    		writeInFile("message", (char*)(std::string("Message: ") + std::string(buffer)).c_str());
    	}
    
    	connectionCounter--;
    	return 0;
    }
    
    
    bool getConfig() {
    	std::ifstream confFile("AventuraRCon//config.txt", std::ifstream::binary);
    	if (confFile) {
    		std::string line;
    		//ip
    		std::getline(confFile, line);
    		strcpy_s(IP, (char*)line.c_str());
    		writeInFile("config", (char*)(std::string("IP : ") + std::string(IP)).c_str());
    		//port
    		std::getline(confFile, line);
    		PORT = atoi(line.c_str());
    		writeInFile("config", (char*)(std::string("PORT : ") + line).c_str());
    		//password
    		std::getline(confFile, line);
    		strcpy_s(PASSWORD, (char*)line.c_str());
    		writeInFile("config", (char*)(std::string("PASSWORD : ") + std::string(PASSWORD)).c_str());
    	}
    	else
    	{
    		return false;
    	}
    
    	return true;
    }
    
    void socketWorker()
    {
    
    	if (!getConfig())
    	{
    		return ;
    	}
    
    	//winsock startup
    	WSAData wsaData;
    	WORD DllVersion = MAKEWORD(2, 1);
    	if (WSAStartup(DllVersion, &wsaData) != 0)
    	{
    		return;
    	}
    
    	socketWorking = true;
    
    
    	SOCKADDR_IN addr;
    	int addrlen = sizeof(addr);
    	addr.sin_addr.s_addr = inet_addr(IP);
    	addr.sin_port = htons(PORT);
    	addr.sin_family = AF_INET;
    
    	SOCKET sListen = socket(AF_INET, SOCK_STREAM, NULL);
    	bind(sListen, (SOCKADDR*)&addr, sizeof(addr));
    	listen(sListen, SOMAXCONN);
    
    	SOCKET newConnection;
    
    	while (true) {
    
    		if (connectionCounter < MAX_CONNECTION)
    		{
    			newConnection = accept(sListen, (SOCKADDR*)&addr, &addrlen);
    			if (newConnection == 0)
    			{
    				writeInFile("debug", "Client can't connect");
    				closesocket(newConnection);
    				WSACleanup();
    			}
    			else
    			{
    				writeInFile("debug", "Client connected");
    				connections[connectionCounter] = newConnection;
    				CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)clientHandlerThread, (LPVOID)(connectionCounter), NULL, NULL);
    				connectionCounter++;
    			}
    		}
    		else
    		{
    			Sleep(10);
    		}
    
    
    	}
    
    	return ;
    }
    
    
    extern "C" 
    { 
    	__declspec (dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function); 
    }
    
    void worker() 
    {
    	//to-do later
    } 
    
    void __stdcall RVExtension(char *output, int outputSize, const char *function) 
    {
    
    	if (!strcmp(function, "Start"))
    	{
    		//start socketworker
    		if (socketWorking)
    		{
    			strncpy_s(output, outputSize, "ALREADY WORKING", _TRUNCATE); 
    			
    		}
    		else
    		{
    			CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)socketWorker, NULL, NULL, NULL);
    			strncpy_s(output, outputSize, "DONE", _TRUNCATE); 
    			
    		}
    		
    	}
    	else if (!strncmp(function, "C:", 2)) // searching for command
    	{ 
    		if (!tickets.empty()) 
    		{ 
    			mtx.lock(); 
    			strncpy_s(output, outputSize, tickets[0].params.c_str(), _TRUNCATE); // result 
    			mtx.unlock(); 
    			return;
    		} 
    		strncpy_s(output, outputSize, "EMPTY", _TRUNCATE);
    		
    	} 
    	else if (!strncmp(function, "R:", 2)) // sending result
    	{ 
    		mtx.lock(); 
    		std::string tmp = function;
    		tickets.at(0).result = (char*)tmp.substr(2, size_t(function) - 2).c_str();
    		tickets.at(0).ready = true;
    		mtx.unlock(); 
    		strncpy_s(output, outputSize, "DONE", _TRUNCATE);
    		
    	} 
    	else 
    	{ 
    		strncpy_s(output, outputSize, "INVALID COMMAND", _TRUNCATE);
    		
    	} 
    }
    

    To create it I use this tutorial:

     

    http://killzonekid.com/arma-scripting-tutorials-how-to-make-arma-extension-part-4/

     

    and, this one:

     

     

    I've already did some .dll, but this time I really don't know where's the problem.

     

    Any solution?


  3. Ok, I think I find the problem!

     

    My server wait 5-6 minutes (after the mission started) to load persistent things, and when the loading finish player can get their informations. It is at this moment that the server loses fps, in fact, in my custom network request I generate a random global variable to broadcast the answer to player, but I never set my var to nil after broadcast. I think this is it, I'll test it at the next reboot ;).

     

    oa9Tkmf.png

     

     

    When the server is at 47fps, is loading, there're some drop but not a lot. As you can see, there're the same count of players during the loading than the game start. So it's not player on the server, but something after loading, and the same moment it's beginning of network traffic ^^. So my bad is on the network traffic ;).

     

    I'll keep you informed


  4. Hello everybody :)

     

    I know there is already some thread about this, but I need some clarification.

     

    I have a server, it turns at 47fps with nobody, with ~10 players : >30fps and with >60 players : 5 - 0 fps.

     

    I have only 1 loop, not hard for the moment, on the server side. There's never desync on the server even with 1fps.

     

    server.cfg:

    class sockets{maxPacketSize = 1400;};
    adapter=-1;
    3D_Performance=1;
    Resolution_W=0;
    Resolution_H=0;
    Resolution_Bpp=32;
    
    Windowed=0;
    MaxMsgSend = 2048; 
    MaxSizeGuaranteed = 958; 
    MaxSizeNonguaranteed = 384; 
    setTerrainGrid = 50;
    viewDistance = 600;
    
    MinBandwidth = 107374182;   
    MaxBandwidth = 1073741824; 
    
    MinErrorToSend = 0.01;	
    MinErrorToSendNear = 0.02;		
    MaxCustomFileSize = 1310720;	
    

    with 80 or 0 vehicles is the same thing and there isn't AI on the mission.

     

    CPU goes to 50% and memory to 2000MB.

     

    I don't know why the server loses fps like this.

     

    Anyone have an idea to help me?


  5. To get the list of functions, you have to type call then have at least one space and then press ctrl+space.

     

    It appears that you aren't the first to not have renaming capabilities with functions, which is strange. If you check out https://community.bistudio.com/wiki/Functions_Library_(Arma_3),it will show how to define functions inside CfgFunctions.

    Here is a portion of my CfgFunctions:

     

    It's work to get list of function with what you say, thanks ;).

     

    And my CfgFunctions work perfectly, the plugin don't detect if it's in another file.

     

    Is it possible to add my custom macro in IntelliJ? I would like to add ifelse, for, forEach, while, switch ...


  6. Hello,

     

    I tried your plugin and it's awesome!!!

     

    But there is a thing I can't use ^^.

     

    I tried "call" and ctrl + space, but nothing append. If i use ctrl + space alone I can show all commands, but not my functions. (and I tried with CfgFunctions directly in description.ext)

     

    I saw an other problem, if CfgFunction is in another file than description.ext I can't use rename command ("function '....' is not defined in CfgFunctions config").

     

    But ctrl+G and F2 macro are very useful ;), thanks a lot for your plugin :D


  7. Hello everybody,

     

    To begin, sorry for my english ^^.

     

    My team converted our mission 2d to eden mission and now I have an issue I can't fix.

     

    Let me explain:

    when I'm connecting for the first time everything's ok, but when I return to lobby to reconnect on the same slot I become a seagull...

     

    I read this topic : https://forums.bistudio.com/topic/188328-jip-in-eden

     

    But it didn't fix my problem.

     

    If I use 2d mission it's work, but we would like to use eden ^^.

     

    Another thing, in the description.ext I included some .hpp, and if there's an error, like "member already defined", arma server doesn't show me the error with the eden mission. Is the mission.sqm corrupted?

     

    please help me, I don't have any solution....


  8. the xcam_xxx objects only have a very basic config. so they mostly are better looking bricks ... these objects / the editor upgrade is mostly aimed for terrain building.

    if you want to use the xcam for missions you better use the proper configured vanilla objects (or from other addons). and in addition you wont have any dependencies in the mission so people dont need to install the xcam to play that mission.

    Ok, but I tried to copy an existing building from Altis(not xcam_xxx object), and I'm not able to open door...

×