| 04-18-2008, 04:26 AM | #1 |
EDIT: Nevermind I figured it out. Sorry for the worthless post. EDIT#2: Since I made this post anyway, tell me if GetLocalPlayer() is gonna desync how I use it here please. JASS:function AFK_CheckCamera takes nothing returns nothing local integer pId = GetPlayerId(GetEnumPlayer()) if GetLocalPlayer()==GetEnumPlayer() then if udg_afk_position[pId] == GetCameraTargetPositionX() + GetCameraTargetPositionY() then set udg_afk_player[pId] = udg_afk_player[pId] + 1 else set udg_afk_position[pId] = GetCameraTargetPositionX() + GetCameraTargetPositionY() set udg_afk_player[pId] = 0 endif endif endfunction function AFK_Kick_Timer takes nothing returns nothing local integer i=0 local force F = CreateForce() loop exitwhen i>8 if GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING then call ForceAddPlayer(F, Player(i)) endif set i=i+1 endloop call ForForce( F, function AFK_CheckCamera ) call DestroyForce(F) set F = null // This isn't the entire code. // but it's all you should need. endfunction |
| 04-18-2008, 06:22 AM | #2 |
Probably not. However, you can't use those globals for anything syncronous...except possibly dropping the player locally, which would PRESUMABLY cause a desync, but with all the non-kicked players staying together (you'd need to test it, and it would kill the game if used against the host). |
| 04-18-2008, 10:00 AM | #3 |
if you call this rare you can sync the data... |
| 04-18-2008, 04:06 PM | #4 | |
Quote:
Only called every 60 seconds, so it's rare enough. Can you elaborate on "sync the data"; although I don't think it will be an issue. I'm not calling that global in anything syncronous. JASS:if udg_afk_player[i] > 8 then // Player afk over 8 minutes call RemovePlayer(Player(i), PLAYER_GAME_RESULT_DEFEAT) endif |
| 04-18-2008, 04:29 PM | #5 |
Once a minute isn't rare enough. Anyway, that will desync. However, it may only desync the player being disconnected, which would thus not be a problem...test it. |
| 04-19-2008, 09:02 AM | #6 |
Well, it doesn't even get the chance to desync because the kick action won't work. The messages are displayed correctly to the afk player, but the teammates never get the -kick message. Any ideas, or maybe I have to come up with different events to check for activity instead. Here is the entire script. JASS:function AFK_CheckCamera takes nothing returns nothing local integer pId = GetPlayerId(GetEnumPlayer()) if GetLocalPlayer()==GetEnumPlayer() then if udg_afk_position[pId] == GetCameraTargetPositionX() + GetCameraTargetPositionY() then set udg_afk_player[pId] = udg_afk_player[pId] + 1 else set udg_afk_position[pId] = GetCameraTargetPositionX() + GetCameraTargetPositionY() set udg_afk_player[pId] = 0 endif endif endfunction function AFK_Kick_Timer takes nothing returns nothing local integer i=0 local force F = CreateForce() loop exitwhen i>8 if GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING and udg_Host!=i then call ForceAddPlayer(F, Player(i)) endif set i=i+1 endloop call ForForce( F, function AFK_CheckCamera ) call ForceClear(F) set i=0 loop exitwhen i>8 if udg_afk_player[i] >= 6 and udg_afk_player[i] < 8 then call DisplayTimedTextToPlayer(Player(i),0.5,0.5,10,"You appear to be afk and may be kicked in |c008E35EF" + I2S(8 - udg_afk_player[i]) + " minutes.|r") elseif udg_afk_player[i] >= 8 then call DisplayTimedTextToPlayer(Player(i),0.5,0.5,10,"You appear to be afk and may be kicked by your teammates NOW!") call ForceEnumAllies(F, Player(i), null) call ForceRemovePlayer(F, Player(i)) call DisplayTimedTextToForce(F,10,udg_playerColor[i+1]+udg_PlayerName[i+1]+"|r has been afk for |c008E35EF" + I2S(udg_afk_player[i]) + " minutes.|r Type |c00ff0303-kick|r to remove them from the game.") call ForceClear(F) endif set i=i+1 endloop call DestroyForce(F) set F=null endfunction function Trig_AFK_Kick_Actions takes nothing returns nothing local integer i=0 loop exitwhen i>8 if udg_afk_player[i] >= 8 and IsPlayerAlly(Player(i), GetTriggerPlayer()) then call RemovePlayer( Player(i), PLAYER_GAME_RESULT_DEFEAT ) call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,udg_playerColor[i+1] + udg_PlayerName[i+1] + "|r was afk too long and kicked from the game.") set udg_afk_player[i] = 0 exitwhen true endif set i=i+1 endloop endfunction //=========================================================================== function InitTrig_AFK_Kick takes nothing returns nothing local integer i=0 local timer t set gg_trg_AFK_Kick = CreateTrigger( ) loop exitwhen i>8 call TriggerRegisterPlayerChatEvent( gg_trg_AFK_Kick, Player(i), "-kick", true ) set i=i+1 endloop call TriggerAddAction( gg_trg_AFK_Kick, function Trig_AFK_Kick_Actions ) set t = CreateTimer() call TimerStart(t, 60, true, function AFK_Kick_Timer) endfunction |
| 04-19-2008, 10:32 AM | #7 |
Oh, the teammates need to actively kick him? Of course that won't come up for them based on unsynced data, since they don't have access to their camera positions...come to think of it, why we don't have GetPlayerCameraX, I have no idea, since the data is obviously transfered for replays... |
| 04-20-2008, 02:45 AM | #8 |
Exactly, I thought for sure there would be a function for it. Well I guess my option is to have it auto kick without teammate approval, or change to different set of events. |
