描述
当玩家与服务器断开连接时会调用此回调。
姓名 |
描述 |
playerid |
断开连接的玩家的 ID。 |
reason |
断线的原因。见下表。 |
返回
0 - 将阻止其他过滤器脚本接收此回调。
1 - 表示此回调将传递给下一个过滤器脚本。
它总是在过滤器脚本中首先被调用。
原因
ID |
原因 |
细节 |
0 |
超时/崩溃 |
玩家的连接已断开。要么他们的游戏崩溃了,要么他们的网络出现了故障。 |
1 |
辞职 |
玩家有目的地退出,可以使用 /quit (/q) 命令或通过暂停菜单。 |
2 |
踢出/禁止 |
玩家被服务器踢出或禁止。 |
3 |
风俗 |
被一些图书馆使用。保留供模特私人使用。 |
4 |
模式结束 |
当前模式即将结束,因此请断开所有玩家的连接(他们仍在服务器上)。 |
警告
原因 3 最初由fixes.inc 添加到 SA:MP 中
原因 3 和 4 是由开放多人游戏服务器添加的。
例子
public OnPlayerDisconnect(playerid, reason)
{
new
szString[64],
playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
new szDisconnectReason[5][] =
{
"Timeout/Crash",
"Quit",
"Kick/Ban",
"Custom",
"Mode End"
};
format(szString, sizeof szString, "%s left the server (%s).", playerName, szDisconnectReason[reason]);
SendClientMessageToAll(0xC4C4C4FF, szString);
return 1;
}
笔记
提示
在此回调中使用某些函数可能无法正常工作,因为调用回调时播放器已断开连接。这意味着您无法从 GetPlayerIp 和 GetPlayerPos 等函数中获取明确的信息。