Jump to content

Search the Community

Showing results for tags 'sqf'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me

Found 3 results

  1. 1.首先在ext中定义并编写一个对话框: Control1_BG中的text指定了一个1.paa,这个是对话框的背景图片,可以自己把png转为paa,注意有分辨率要求否则会半透明。 Control1_BUT中的的onButtonClick 中写入 "[0,nil] call DESTINY_fnc_Launch;closeDialog 0;",当按钮被单机调用从CAS上发射,并且关闭当前对话框。 class DESTINY_Launch_Missile { idd = 669988; class Controls { class Control1_BG { type = 0; idc = 0; x = -0.17499955; y = -0.42499949; w = 1.35000044; h = 1.80000063; style = 48; text = "1.paa"; colorBackground[] = {0,0,0,0}; colorText[] = {1,1,1,1}; font = "PuristaMedium"; sizeEx = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1); moving = true; }; class Control1_BUT { type = 16; idc = -1; x = 0.66500013; y = 0.76500016; w = 0.35000002; h = 0.12500003; style = 2; text = "启动"; animTextureDefault = "#(argb,8,8,3)color(1,1,1,1)"; animTextureDisabled = "#(argb,8,8,3)color(0.2,0.2,0.2,1)"; animTextureFocused = "#(argb,8,8,3)color(1,1,1,1)"; animTextureNormal = "#(argb,8,8,3)color(1,1,1,1)"; animTextureOver = "#(argb,8,8,3)color(1,1,1,1)"; animTexturePressed = "#(argb,8,8,3)color(1,1,1,1)"; color[] = {1,1,1,1}; color2[] = {0.502,0.6,1,1}; colorBackground[] = {0,0,0,0}; colorBackground2[] = {0, 0, 0, 0}; colorBackgroundFocused[] = {0,0,0,0}; colorDisabled[] = {0.2,0.2,0.2,1}; colorFocused[] = {1,0.7131,0,1}; font = "PuristaMedium"; size = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 2); sizeEx = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1); soundClick[] = {"\A3\ui_f\data\sound\RscButtonMenu\soundClick",0.09,1.0}; soundEnter[] = {"\A3\ui_f\data\sound\RscButtonMenu\soundEnter",0.09,1.0}; soundEscape[] = {"\A3\ui_f\data\sound\RscButtonMenu\soundEscape",0.09,1.0}; soundPush[] = {"\A3\ui_f\data\sound\RscButtonMenu\soundPush",0.09,1.0}; textureNoShortcut = ""; onButtonClick = "[0,nil]call DESTINY_fnc_Launch;closeDialog 0;"; class HitZone { top = 0; right = 0; bottom = 0; left = 0; }; class ShortcutPos { top = 0; left = 0; w = 0; h = 0; }; class TextPos { top = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) - (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)) / 2; right = 0.005; bottom = 0; left = 0.25 * (((safezoneW / safezoneH) min 1.2) / 40); }; }; }; }; 2.接下来定义定义和编写在游戏中导弹视角的HUD: Control618624017里text使用到了2.paa,是用来显示瞄准的图片,可以自己换 class RscTitles { class DESTINY_HUD_MISS { idd = 98100; duration = 4; fadeIn = 0; fadeOut = 0; name = "DESTINY_HUD_MISS"; onLoad = "uiNamespace setVariable ['DESTINY_HUD_MISS',_this select 0]"; class ControlsBackground { class Control618624017 { type = 0; idc = 0; x = 0.00000016; y = -0.0749998; w = 1.00000025; h = 1.15000022; style = 48; text = "2.paa"; colorBackground[] = {0,0,0,0}; colorText[] = {1,1,1,1}; font = "PuristaMedium"; sizeEx = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1); }; class ControlSpeed { type = 0; idc = 98101; x = 0.30000012; y = 0.82500011; w = 1; h = 0.05000004; style = 0; text = "速度:"; colorBackground[] = {0,0,0,0}; colorText[] = {1,1,1,1}; font = "PuristaMedium"; sizeEx = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1.5); }; class ControlPerspective { type = 0; idc = 98102; x = 0.30000012; y = 0.97500012; w = 1; h = 0.05000004; style = 0; text = "视角:"; colorBackground[] = {0,0,0,0}; colorText[] = {1,1,1,1}; font = "PuristaMedium"; sizeEx = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1.5); }; class ControlMode { type = 0; idc = 98103; x = 0.30000012; y = 0.90000011; w = 1; h = 0.05000004; style = 0; text = "模式:"; colorBackground[] = {0,0,0,0}; colorText[] = {1,1,1,1}; font = "PuristaMedium"; sizeEx = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1.5); }; class ControlRadar { type = 0; idc = 98105; x = 0.30000012; y = 1.11424053; w = 1; h = 0.05000004; style = 0; text = "范围:"; colorBackground[] = {0,0,0,0}; colorText[] = {1,1,1,1}; font = "PuristaMedium"; sizeEx = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1.5); }; class ControlDistance { type = 0; idc = 98104; x = 0.30000012; y = 1.05000012; w = 1; h = 0.05000004; style = 0; text = "高度:"; colorBackground[] = {0,0,0,0}; colorText[] = {1,1,1,1}; font = "PuristaMedium"; sizeEx = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1.5); }; }; }; } 3.编写发射功能:将文件命名为:fnc_Launch.sqf #define DESTINY_HUD_speed ((uiNamespace getVariable "DESTINY_HUD_MISS") displayCtrl 98101) #define DESTINY_HUD_HUD ((uiNamespace getVariable "DESTINY_HUD_MISS") displayCtrl 98102) #define DESTINY_HUD_Mode ((uiNamespace getVariable "DESTINY_HUD_MISS") displayCtrl 98103) #define DESTINY_HUD_Distance ((uiNamespace getVariable "DESTINY_HUD_MISS") displayCtrl 98104) #define DESTINY_HUD_Radar ((uiNamespace getVariable "DESTINY_HUD_MISS") displayCtrl 98105) closeDialog 669988; DESTINY_Y = 0; DESTINY_P = 0; DESTINY_R = 0; //注册键盘点击事件 DESTINY_fnc_setKeyDown = { _HE = (findDisplay 46) displayAddEventHandler ["KeyDown", "_this call DESTINY_fnc_keyListen;"]; player setVariable["DESTINY_HE",_HE]; }; //创建摄像机 DESTINY_fnc_createCAM = { Destiny_cam = "camera" camCreate getPosASL (_this # 0); Destiny_cam cameraEffect ["External", "BACK"]; Destiny_cam camSetTarget (_this # 1); Destiny_cam camSetRelPos (_this # 2); showCinemaBorder false; false setCamUseTI 0; Destiny_cam camCommit 0.1; cameraEffectEnableHUD true; if (_this # 3) then { call DESTINY_fnc_setKeyDown; }; }; //创建导弹 [_this # 0,_this # 1] spawn { _type = _this # 0; DESTINY_VLS_DAODAN = _this # 1; EXIT_SCRIPT = false; _pos = getPos player; cutText ["","BLACK OUT",0.5]; _TypePos = [_pos # 0,_pos # 1,1000]; if (_type == 2) then { _TypePos = [0,0,1000]; }; DESTINY_obj = "ammo_Missile_Cruise_01" createVehicle _TypePos; DESTINY_obj enableSimulation false; sleep 0.5; cutText ["","PLAIN"]; switch _type do { case 0: { CASobj = createVehicle ["B_Plane_CAS_01_dynamicLoadout_F", [_pos # 0,_pos # 1,1100], [], 100, "FLY"]; DESTINY_pilot = [ CASobj, [ ["B_Fighter_Pilot_F","driver"] ] ] call BIS_fnc_initVehicleCrew; CASobj allowDamage false; _Pylon = ["pylons1","pylons2","pylons3","pylons8","pylons9","pylons10"]; { CASobj setPylonLoadout [_x, "PylonRack_3Rnd_Missile_AGM_02_F",true]; } forEach _Pylon; _CASpos = getPos CASobj; CASobj setPos [_CASpos # 0,_CASpos # 1,(_CASpos #2) + 2000]; _vel = velocity CASobj; _dir = direction CASobj; _speed = 100; CASobj setVelocity [ (_vel select 0) + (sin _dir * _speed), (_vel select 1) + (cos _dir * _speed), (_vel select 2) ]; _XX = 60; _Y = 100; _Z = 10; DESTINY_obj attachTo [CASobj,[0,0,-1]]; [DESTINY_obj,CASobj,[10,50,10],false] call DESTINY_fnc_createCAM; while {true} do { CASobj setVectorDirAndUp [ [ sin 0 * cos 0,cos 0 * cos 0,sin 0], [[ sin 0,-sin 0,cos 0 * cos 0],-0] call BIS_fnc_rotateVector2D ]; _lastTime = time; sleep 0.1; if (_XX != 30) then { _XX = _XX - 1; }; if (-2 < _Y) then { _Y = _Y - 1; }; if (_Z != 0) then { _Z = _Z - 1; }; if (-2 >= _Y) exitWith { [Destiny_cam] spawn { _j = -1; while {true} do { _j = _j - 0.1; DESTINY_obj attachTo [CASobj,[0,0,_j]]; if (_j < -5) exitWith { detach DESTINY_obj; DESTINY_obj enableSimulation true; call DESTINY_fnc_setKeyDown; }; }; }; }; Destiny_cam camSetTarget CASobj; Destiny_cam camSetRelPos [_XX,_Y,_Z]; Destiny_cam camcommit 5 * (time - _lastTime); }; }; case 1: { DESTINY_obj enableSimulation true; [DESTINY_obj,DESTINY_obj,[0,-10,0],true] call DESTINY_fnc_createCAM; }; case 2: { _objUpVector = vectorUp DESTINY_VLS_DAODAN; _dirVector = vectorDir DESTINY_VLS_DAODAN; _oldPOS = getPosASL DESTINY_VLS_DAODAN; deleteVehicle DESTINY_VLS_DAODAN; DESTINY_obj setVectorDirAndUp [_dirVector,_objUpVector]; DESTINY_obj setPosASL _oldPOS; DESTINY_obj enableSimulation true; [DESTINY_obj,DESTINY_obj,[10,50,10],false] call DESTINY_fnc_createCAM; sleep 3; }; default {EXIT_SCRIPT=true;}; }; if (EXIT_SCRIPT) exitWith {}; _lastpos = getPosASL DESTINY_obj; _dir = getDir DESTINY_obj; DESTINY_Radar = 4000; //绘制目标图标到敌军坐标 _handlerID = addMissionEventHandler ["Draw3D", { { if (!(isPlayer _x) and (side _x) == east and (alive _x) and (DESTINY_obj distance _x) <= DESTINY_Radar) then { _M = format["%1 m",round (DESTINY_obj distance _x)]; if ((vehicle _x) != _x) then { drawIcon3D ["a3\ui_f\data\gui\Cfg\Hints\icon_text\n_unknown_ca.paa", [1,1,1,1], ASLToAGL getPosASL _x, 1, 1, 45, _M,0, 0.03, "TahomaB","center",true]; }else{ drawIcon3D ["a3\ui_f\data\gui\Cfg\Cursors\scroll_gs.paa", [1,1,1,1], ASLToAGL getPosASL _x, 1, 1, 45,_M, 1, 0.03, "TahomaB","center",true]; }; }; } forEach allUnits; }]; [_type]spawn { _type = _this # 0; sleep 3; player setVariable["DESTINY_Perspective",[true,0]]; switch _type do { case 0: { deleteVehicle CASobj; }; case 2: { call DESTINY_fnc_setKeyDown; }; }; player setVariable["DESTINY_N",0]; }; while {!(isNull DESTINY_obj)} do { _Perspective = player getVariable ["DESTINY_Perspective",[false,-1]]; if (_Perspective # 0) then { cutText ["","BLACK OUT"]; _hide = switch (_Perspective # 1) do { case 0: {true}; case 1: {false}; }; sleep 1; DESTINY_obj hideObject _hide; cutText ["","BLACK IN"]; player setVariable["DESTINY_Perspective",[false,(_Perspective # 1)]]; }; _n = player getVariable ["DESTINY_N",8]; _lastTime = time; _lastpos = getPosASL DESTINY_obj; _dir = getDir DESTINY_obj; sleep 0.01; Destiny_cam camSetTarget DESTINY_obj; Destiny_cam camSetRelPos (player getVariable ["DESTINY_POS",[0,-5,0]]); if(_n >= 0 && _n < 8) then{ true setCamUseTI _n; }else{ false setCamUseTI 0; }; _vel = velocity DESTINY_obj; _spd = (_vel distance [0,0,0]) max 1; _perspectiveText= switch (_Perspective # 1) do { case 0: {"第一人称"}; case 1: {"第三人称"}; default {"关闭"}; }; _modeText = switch _n do { case 0: {"白热"}; case 1: {"黑热"}; case 2: {"绿色"}; case 3: {"深绿"}; case 4: {"浅红"}; case 5: {"深红"}; case 6: {"暗红"}; case 7: {"散热"}; default {"关闭"}; }; _distancePOS = getPosASL DESTINY_obj; _meters = _distancePOS distance [_distancePOS # 0,_distancePOS # 1,0]; cutRsc ["DESTINY_HUD_MISS","PLAIN"]; DESTINY_HUD_speed ctrlSetText format["速度: %1 km/h",round _spd]; DESTINY_HUD_HUD ctrlSetText format["视角: %1 (R)",_perspectiveText]; DESTINY_HUD_Mode ctrlSetText format["模式: %1 (N)",_modeText]; DESTINY_HUD_Distance ctrlSetText format["高度: %1 米",round _meters]; DESTINY_HUD_Radar ctrlSetText format["雷达: %1 米 (F)",DESTINY_Radar]; Destiny_cam camcommit 5 * (time - _lastTime); }; player setVariable["DESTINY_N",8]; Destiny_cam camSetPos [(_lastpos select 0) - 200*sin(_dir), (_lastpos select 1)-200*cos(_dir), (_lastpos select 2) + sin(45)*200]; Destiny_cam camCommit 5; Destiny_cam camSetTarget _lastpos; _endTime = time + 5; while {time<_endtime} do { sleep 1 }; //当导弹爆炸后移除各种事件并销毁摄像机 Destiny_cam cameraeffect ["terminate", "back"]; camDestroy Destiny_cam; cutText ["","BLACK IN"]; (findDisplay 46) displayRemoveEventHandler ["KeyDown",player getVariable["DESTINY_HE",0]]; removeMissionEventHandler ["Draw3D",_handlerID]; }; 3.编写键盘控制事件控制导弹转向:将文件命名位为:fnc_keyListen.sqf #include "\a3\ui_f\hpp\definedikcodes.inc" params['_d','_key','_shift_state','_control_state','_alt_state']; private['_handled']; _handled = false; _n = player getVariable["DESTINY_N",-1]; //当ADSW按下,做相应的动作 switch (_key) do { case DIK_A:{ if (DESTINY_Y == 0) then { DESTINY_Y = 360; }; DESTINY_Y = DESTINY_Y - 1; _handled = true; }; case DIK_D:{ if (DESTINY_Y == 360) then { DESTINY_Y = 0; }; DESTINY_Y = DESTINY_Y + 1; _handled = true; }; case DIK_W:{ if (DESTINY_P == 0) then { DESTINY_P = 360; }; DESTINY_P = DESTINY_P - 1; _handled = true; }; case DIK_S:{ if (DESTINY_P == 360) then { DESTINY_P = 0; }; DESTINY_P = DESTINY_P + 1; _handled = true; }; case DIK_N:{ _n = _n + 1; player setVariable["DESTINY_N",_n]; if (_n == 8) then { player setVariable["DESTINY_N",-1]; }; }; case DIK_F:{ DESTINY_Radar = DESTINY_Radar + 1000; if (DESTINY_Radar == 11000) then { DESTINY_Radar = 4000; }; }; case DIK_R:{ _Perspective = player getVariable ["DESTINY_Perspective",[false,-1]]; _jc = _Perspective # 1; _jc = _jc + 1; if (_jc == 2) then { _jc = 0; }; player setVariable ["DESTINY_Perspective",[true,_jc]]; }; }; //将得到的数据计算并设置导弹的向量 DESTINY_obj setVectorDirAndUp [ [ sin DESTINY_Y * cos DESTINY_P,cos DESTINY_Y * cos DESTINY_P,sin DESTINY_P], [[ sin DESTINY_R,-sin DESTINY_P,cos DESTINY_R * cos DESTINY_P],-DESTINY_Y] call BIS_fnc_rotateVector2D ]; _handled; 4.在ext中定义函数: class CfgFunctions { class DESTINY { class destiny_studio{ class DESTINY_fnc_Launch {file = "fnc_Launch.sqf的相对路径";}; class DESTINY_fnc_keyListen {file = "fnc_keyListen.sqf的相对路径";}; } } } 5.在控制台中运行并测试,并点击发射: _ok = createDialog "DESTINY_Launch_Missile"; if !(_ok) exitWith { hint "创建巡航导弹发射菜单失败!"; }; 6.直接运行 //从CAS上发射控制导弹 [0,_projectile] call DESTINY_fnc_Launch; //直接控制导弹 [1,_projectile] call DESTINY_fnc_Launch; //控制指定的导弹 _projectile = 创建后的导弹 [2,_projectile] call DESTINY_fnc_Launch; enjoy~
  2. using System.Text; using System.Runtime.InteropServices; using RGiesecke.DllExport; using System; using System.Threading.Tasks; using System.Collections; using System.Web.SessionState; using System.Web; using System.Collections.Generic; /** * by MarkCode 七龙 * url https://o.ls * 这个东西非常坑爹,对中国人用非常不友好,我的坑 * */ namespace ArmaMapsExt { public class ArmaMapsExt { public static ExtensionCallback callback; public delegate int ExtensionCallback([MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string function, [MarshalAs(UnmanagedType.LPStr)] string data); public static ServiceStack.Redis.RedisClient client = null; #if WIN64 [DllExport("RVExtensionRegisterCallback", CallingConvention = CallingConvention.Winapi)] #else [DllExport("_RVExtensionRegisterCallback@4", CallingConvention = CallingConvention.Winapi)] #endif public static void RVExtensionRegisterCallback([MarshalAs(UnmanagedType.FunctionPtr)] ExtensionCallback func) { callback = func; } /// <summary> ///当arma启动并加载所有扩展时被调用。 ///最好在单独的线程中加载静态对象,以使扩展不需要任何单独的初始化 /// </ summary> /// <param name =“ output”>包含以下内容的字符串生成器对象:函数的结果</ param> /// <param name =“ outputSize”>可以返回的最大字节数</ param> #if WIN64 [DllExport("RVExtensionVersion", CallingConvention = CallingConvention.Winapi)] #else [DllExport("_RVExtensionVersion@8", CallingConvention = CallingConvention.Winapi)] #endif public static void RvExtensionVersion(StringBuilder output, int outputSize) { output.Append("MapsExt by Qilong v1.0"+ outputSize); } /// <summary> ///默认callExtension命令的入口点。 /// </ summary> /// <param name =“ output”>包含函数结果的字符串生成器对象</ param> /// <param name =“ outputSize”>可以返回</ param> /// <param name =“ function”>与callExtension一起使用的字符串参数</ param> #if WIN64 [DllExport("RVExtension", CallingConvention = CallingConvention.Winapi)] #else [DllExport("_RVExtension@12", CallingConvention = CallingConvention.Winapi)] #endif public static void RvExtension(StringBuilder output, int outputSize, [MarshalAs(UnmanagedType.LPStr)] string function) { output.Append(function); } /// <summary> /// callExtensionArgs命令的入口点。 /// </ summary> /// <param name =“ output”>包含函数结果的字符串生成器对象</ param> /// <param name =“ outputSize”>可以返回</ param> /// <param name =“ function”>与callExtension一起使用的字符串参数</ param> /// <param name =“ args”>作为字符串传递给callExtension的args array </ param> /// <param name =“ argsCount”>字符串数组args的大小</ param> /// <returns>结果代码</ returns> #if WIN64 [DllExport("RVExtensionArgs", CallingConvention = CallingConvention.Winapi)] #else [DllExport("_RVExtensionArgs@20", CallingConvention = CallingConvention.Winapi)] #endif public static int RvExtensionArgs(StringBuilder output, int outputSize, [MarshalAs(UnmanagedType.LPStr)] string function, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 4)] string[] args, int argCount) { if (args.Length > 10240) { output.Append("ERROR"); return 0; } for (int i = 0; i < args.Length; i++) { args[i] = args[i].Trim().Replace("\"", ""); } //请求结果 if (function.Equals("connectRedis")) { try { //output.Append(args[0] + "*" + args[1] + "*" + args[2]); // return 0; if (args.Length > 2) { client = new ServiceStack.Redis.RedisClient(args[0], int.Parse(args[1]), args[2]); } else { client = new ServiceStack.Redis.RedisClient(args[0], int.Parse(args[1])); } output.Append("success"); return 0; } catch (Exception e) { output.Append("fail"); return 0; } } //储存请求 if (function.Equals("sendMsg")) { try { if (args.Length > 2) { var timeOut = new TimeSpan(0, 0, 0, int.Parse(args[2])); if (client.Set<string>(args[0], args[1], timeOut)) { output.Append("success"); } else { output.Append("fail"); } } else { if (client.Set<string>(args[0], args[1])) { output.Append("success"); } else { output.Append("fail"); } } } catch (Exception e) { output.Append("fail"); return 0; } } if (function.Equals("getMsg")) { try { string value = client.Get<string>(args[0]); output.Append(value); return 0; } catch(Exception e) { output.Append("fail"); return 0; } } return 0; } } } HTTP异步请求扩展 这是一个允许服务端发送GET HTTP请求的DLL扩展,您可以通过服务端请求web服务器的动态内容,实现游戏内动态信息展示 使用方法 [] spawn { _handle = ["GET","http://api.arma3bbs.com:81/api/1.0/toguid?uid=2323232323"] call ELSTP_fnc_AyncHttpRequest; diag_log format["test value:%1",_handle]; } DLL扩展方法 //发送get请求 "ArmaAsyncExt" callExtension ["get",["http://XXXXXXX"]]; //获取get请求内容 "ArmaAsyncExt" callExtension ["Result",[""]]; DLL请求状态以及数据格式 数据以 | 分割 即为 状态码|内容 WAIT = 等待中或者请求中 ERROR = 发生错误 SUCCESS = 请求成功 GitHub: https://github.com/elstp/ArmaAsyncExt
  3. using System.Text; using System.Runtime.InteropServices; using RGiesecke.DllExport; using System; using System.Threading.Tasks; using System.Collections; using System.Web.SessionState; using System.Web; using System.Collections.Generic; /** * by MarkCode 七龙 * url https://o.ls * REDIS 扩展 * */ namespace ArmaMapsExt { public class ArmaMapsExt { public static ExtensionCallback callback; public delegate int ExtensionCallback([MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string function, [MarshalAs(UnmanagedType.LPStr)] string data); public static ServiceStack.Redis.RedisClient client = null; #if WIN64 [DllExport("RVExtensionRegisterCallback", CallingConvention = CallingConvention.Winapi)] #else [DllExport("_RVExtensionRegisterCallback@4", CallingConvention = CallingConvention.Winapi)] #endif public static void RVExtensionRegisterCallback([MarshalAs(UnmanagedType.FunctionPtr)] ExtensionCallback func) { callback = func; } /// <summary> ///当arma启动并加载所有扩展时被调用。 ///最好在单独的线程中加载静态对象,以使扩展不需要任何单独的初始化 /// </ summary> /// <param name =“ output”>包含以下内容的字符串生成器对象:函数的结果</ param> /// <param name =“ outputSize”>可以返回的最大字节数</ param> #if WIN64 [DllExport("RVExtensionVersion", CallingConvention = CallingConvention.Winapi)] #else [DllExport("_RVExtensionVersion@8", CallingConvention = CallingConvention.Winapi)] #endif public static void RvExtensionVersion(StringBuilder output, int outputSize) { output.Append("MapsExt by Qilong v1.0"+ outputSize); } /// <summary> ///默认callExtension命令的入口点。 /// </ summary> /// <param name =“ output”>包含函数结果的字符串生成器对象</ param> /// <param name =“ outputSize”>可以返回</ param> /// <param name =“ function”>与callExtension一起使用的字符串参数</ param> #if WIN64 [DllExport("RVExtension", CallingConvention = CallingConvention.Winapi)] #else [DllExport("_RVExtension@12", CallingConvention = CallingConvention.Winapi)] #endif public static void RvExtension(StringBuilder output, int outputSize, [MarshalAs(UnmanagedType.LPStr)] string function) { output.Append(function); } /// <summary> /// callExtensionArgs命令的入口点。 /// </ summary> /// <param name =“ output”>包含函数结果的字符串生成器对象</ param> /// <param name =“ outputSize”>可以返回</ param> /// <param name =“ function”>与callExtension一起使用的字符串参数</ param> /// <param name =“ args”>作为字符串传递给callExtension的args array </ param> /// <param name =“ argsCount”>字符串数组args的大小</ param> /// <returns>结果代码</ returns> #if WIN64 [DllExport("RVExtensionArgs", CallingConvention = CallingConvention.Winapi)] #else [DllExport("_RVExtensionArgs@20", CallingConvention = CallingConvention.Winapi)] #endif public static int RvExtensionArgs(StringBuilder output, int outputSize, [MarshalAs(UnmanagedType.LPStr)] string function, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPStr, SizeParamIndex = 4)] string[] args, int argCount) { if (args.Length > 10240) { output.Append("ERROR"); return 0; } for (int i = 0; i < args.Length; i++) { args[i] = args[i].Trim().Replace("\"", ""); } //请求结果 if (function.Equals("connectRedis")) { try { if (args.Length > 2) { client = new ServiceStack.Redis.RedisClient(args[0], int.Parse(args[1]), args[2]); } else { client = new ServiceStack.Redis.RedisClient(args[0], int.Parse(args[1])); } output.Append("success"); return 0; } catch (Exception e) { output.Append("fail"); return 0; } } //储存请求 if (function.Equals("sendMsg")) { try { if (args.Length > 2) { var timeOut = new TimeSpan(0, 0, 0, int.Parse(args[2])); if (client.Set<string>(args[0], args[1], timeOut)) { output.Append("success"); } else { output.Append("fail"); } } else { if (client.Set<string>(args[0], args[1])) { output.Append("success"); } else { output.Append("fail"); } } } catch (Exception e) { output.Append("fail"); return 0; } } if (function.Equals("getMsg")) { try { string value = client.Get<string>(args[0]); output.Append(value); return 0; } catch(Exception e) { output.Append("fail"); return 0; } } return 0; } } } 这是个简单的实现ARMA3连接Reids缓存服务器的源代码,使用C#实现 自行编译为dll,放置服务的目录下即可。 食用方法: //在服务端初始化后首先连接redis服务器,只需要连接一次不能重复执行如要重复请修改源代码。 //参数: [ip,端口,密码],redis有密码: "ArmaMapsExt_x64" callExtension ["connectRedis",["127.0.0.1","6379","123456"]] //redis无密码: "ArmaMapsExt_x64" callExtension ["connectRedis",["127.0.0.1","6379"]] //储存一个字符串至redis缓存服务器,参数:[key,value] //缓存无限期: "ArmaMapsExt" callExtension ["sendMsg",["usename","小明"]] //缓存有限期(单位:秒): "ArmaMapsExt" callExtension ["sendMsg",["usename","小明","60"]] //从key中获取一个缓存字符串,参数:[key] _data = "ArmaMapsExt" callExtension ["getMsg",["username"]] //如果命中缓存则返回值,否则返回空字符串 注意:全程只能在服务器上执行! 模组也只能服务器挂载 如果你要在客户端测试,必须关闭be,否则会被阻止! MOD: 编译好的MOD
×
×
  • Create New...