可以通过访问http(注意:不支持https)网站,下载网页数据或脚本等内容
ansnycRobot.lua.share
(3.21 KB, 下载次数: 6)
使用方法:下载后useModule("ansnycRobot")
例子:通过下载网站的lua脚本(http://api.ml30.com/scripts/zudui.lua),然后执行,实现脚本热补丁
注意,本post是异步加载,不会卡gmsv的主线程,所以可以实时加载
      _POST(
'http://api.ml30.com/getScript.php',
{
['sc'] = 'zudui',
--授权码(如需要)
['key'] = '89665783'
},
--异步callback
function(text)
print('返回值:'.. text)
--加载并执行脚本
return (loadstring( text ))()
end
)
php部分:
      <?php
// getScript.php
// 检查必要的参数是否存在
if (!isset($_GET['sc']) || !isset($_GET['key'])) {
http_response_code(400);
die('缺少必要参数');
}
$scriptName = $_GET['sc'];
$key = $_GET['key'];
// 验证key
if ($key !== '89665783') {
http_response_code(403);
die('无效的key');
}
// 安全过滤脚本名,防止目录遍历攻击
$scriptName = preg_replace('/[^a-zA-Z0-9_]/', '', $scriptName);
$scriptPath = __DIR__ . '/scripts/' . $scriptName . '.lua';
// 检查脚本文件是否存在
if (!file_exists($scriptPath)) {
http_response_code(404);
die('脚本不存在');
}
// 读取并输出脚本内容
header('Content-Type: text/plain');
readfile($scriptPath);
?>
|