mirror of
https://github.com/CFC-Servers/cfc_chat_transit.git
synced 2025-03-04 03:03:05 -05:00
Pure-lua playercount fix
This commit is contained in:
parent
d21cbdc81f
commit
daf8cfb5cc
@ -3,6 +3,7 @@ require "logger"
|
||||
|
||||
export ChatTransit = { Logger: Logger "ChatTransit" }
|
||||
include "cfc_chat_transit/server/avatar_service.lua"
|
||||
include "cfc_chat_transit/server/player_count.lua"
|
||||
|
||||
import Read from file
|
||||
import GetColor from team
|
||||
@ -67,6 +68,8 @@ ChatTransit.guard = (f) -> (...) ->
|
||||
|
||||
return nil
|
||||
|
||||
ChatTransit.delay = (f) -> timer.Simple 0, f
|
||||
|
||||
logger\info "Loading modules..."
|
||||
for f in *file.Find "cfc_chat_transit/server/modules/*.lua", "LUA"
|
||||
logger\info "Loading modules/#{f}"
|
||||
|
@ -1,4 +1,4 @@
|
||||
import guard from ChatTransit
|
||||
import delay, guard from ChatTransit
|
||||
import SteamIDTo64 from util
|
||||
-- TODO: Send a preliminary avatarservice link that will be backfilled when they fully connect
|
||||
|
||||
@ -13,7 +13,7 @@ ChatTransit.PlayerConnect = (data) =>
|
||||
Data:
|
||||
SteamName: name
|
||||
SteamId: steamId and SteamIDTo64 steamId
|
||||
PlayerCountCurrent: player\GetCount! + 1
|
||||
PlayerCountCurrent: ChatTransit.playerCount
|
||||
PlayerCountMax: game\MaxPlayers!
|
||||
|
||||
ChatTransit.PlayerInitialSpawn = (ply) =>
|
||||
@ -24,5 +24,5 @@ ChatTransit.PlayerInitialSpawn = (ply) =>
|
||||
SteamId: ply\SteamID64!
|
||||
|
||||
gameevent.Listen "player_connect"
|
||||
hook.Add "player_connect", "CFC_ChatTransit_SpawnListener", guard ChatTransit\PlayerConnect
|
||||
hook.Add "player_connect", "CFC_ChatTransit_SpawnListener", delay guard ChatTransit\PlayerConnect
|
||||
hook.Add "PlayerInitialSpawn", "CFC_ChatTransit_SpawnListener", guard ChatTransit\PlayerInitialSpawn
|
||||
|
@ -1,4 +1,4 @@
|
||||
import guard from ChatTransit
|
||||
import delay, guard from ChatTransit
|
||||
import GetBySteamID from player
|
||||
import SteamIDTo64 from util
|
||||
|
||||
@ -12,9 +12,9 @@ ChatTransit.PlayerDisconnected = (data) =>
|
||||
Data:
|
||||
SteamName: ply and ply\Nick! or name
|
||||
SteamId: ply and ply\SteamID64! or SteamIDTo64 steamId
|
||||
PlayerCountCurrent: player\GetCount! - 1
|
||||
PlayerCountCurrent: ChatTransit.playerCount
|
||||
PlayerCountMax: game\MaxPlayers!
|
||||
Content: reason
|
||||
|
||||
gameevent.Listen "player_disconnect"
|
||||
hook.Add "player_disconnect", "CFC_ChatTransit_DisconnectListener", guard ChatTransit\PlayerDisconnected
|
||||
hook.Add "player_disconnect", "CFC_ChatTransit_DisconnectListener", delay guard ChatTransit\PlayerDisconnected
|
||||
|
14
moon/cfc_chat_transit/server/player_count.moon
Normal file
14
moon/cfc_chat_transit/server/player_count.moon
Normal file
@ -0,0 +1,14 @@
|
||||
ChatTransit.playerCount = 0
|
||||
|
||||
increment = -> ChatTransit.playerCount += 1
|
||||
decrement = -> ChatTransit.playerCount -= 1
|
||||
|
||||
hook.Add "ClientSignOnStateChanged", "ChatTransit_PlayerCount", (_, _, newstate) ->
|
||||
return unless newstate == 7
|
||||
increment!
|
||||
|
||||
gameevent.Listen "player_connect"
|
||||
hook.Add "player_connect", "ChatTransit_PlayerCount", increment
|
||||
|
||||
gameevent.Listen "player_disconnect"
|
||||
hook.Add "player_disconnect", "ChatTransit_PlayerCount", decrement
|
Loading…
Reference in New Issue
Block a user