Afk system based on mouse movement (In Stage Room + In Game)

Results 1 to 7 of 7
  1. #1
    Member Hideasu is offline
    MemberRank
    Aug 2011 Join Date
    CanadaLocation
    78Posts

    Afk system based on mouse movement (In Stage Room + In Game)

    ZStageInterface.cpp : Line : 30
    Code:
    void GunzAFKSystem(int LastMouseMoveTime, bool WarningOutput, bool AFK, POINT CursorPos, POINT OldCursorPos){
    ZApplication::GetGameInterface()->SetState(GUNZ_STAGE);
    while(1){
    	if(GetCursorPos(&CursorPos) && ((CursorPos.x == OldCursorPos.x) || (CursorPos.y == OldCursorPos.y)) && AFK != true){
    		LastMouseMoveTime = timeGetTime();
    		WarningOutput = true;
    		AFK = true;
    	}else if(GetCursorPos(&CursorPos) && ((CursorPos.x != OldCursorPos.x) || (CursorPos.y != OldCursorPos.y)) && AFK != false){
    		LastMouseMoveTime = 3600000;
    		WarningOutput = false;
    		AFK = false;
    	}else{
    		OldCursorPos = CursorPos;
           }
    
    	if(LastMouseMoveTime + 30000 < timeGetTime() && WarningOutput != false){
    		ZChatOutput(ZCOLOR_CHAT_SYSTEM_GAME, "Warning: If you do not move the mouse in 30seconds, you will be returned to the lobby.");
    		WarningOutput = false;
    	}else if(LastMouseMoveTime + 60000 < timeGetTime() && AFK != false){
    		if(ZApplication::GetGameInterface()->GetState() != GUNZ_STAGE){
    			ZPostStageLeaveBattle(ZGetGameClient()->GetPlayerUID(), ZGetGameInterface()->GetIsGameFinishLeaveBattle());
                ZPostStageLeave(ZGetGameClient()->GetPlayerUID());
    			AFK = false;
    	    }else{
    			ZPostStageLeave(ZGetGameClient()->GetPlayerUID());
    			AFK = false;
    		}
    	 }
    	if(ZApplication::GetGameInterface()->GetState() == GUNZ_LOBBY || ZApplication::GetGameInterface()->GetState() == GUNZ_NA){
    		break;
    	}
       }
     return;
    }
    ZStageInterface.cpp : Line : 244
    Code:
    CreateThread(0, 0, (LPTHREAD_START_ROUTINE)GunzAFKSystem, 0, 0, 0);
    Feel free to comment or like if you use or find these code useful.
    WARNING: Do not use this system whit any other AFK system.
    -------------------------------------------------------------------------------------------------------------
    04/12/2012: Fixed crash when exiting Gunz from in-game.
    04/12/2012: Code have been pre-optimized.
    Last edited by Hideasu; 05-12-12 at 05:47 AM.


  2. #2
    Account Upgraded | Title Enabled! KeyTrix is offline
    MemberRank
    Feb 2012 Join Date
    EverywhereLocation
    268Posts

    Re: Afk system based on mouse movement (In Stage Room)

    No wonder, as i said you always post a cool stuff.

  3. #3
    Hi, I'm Omar! Vusion is offline
    MemberRank
    Jan 2011 Join Date
    HereLocation
    1,658Posts

    Re: Afk system based on mouse movement (In Stage Room + In Game)

    Why not combine both into one? Or even one thread.

  4. #4
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: Afk system based on mouse movement (In Stage Room + In Game)

    Indeed, why would you use a thread, you've done it without before.

    http://forum.ragezone.com/f245/afk-s...vement-894457/

  5. #5
    Member Hideasu is offline
    MemberRank
    Aug 2011 Join Date
    CanadaLocation
    78Posts

    Re: Afk system based on mouse movement (In Stage Room + In Game)

    Quote Originally Posted by Vusion View Post
    Why not combine both into one? Or even one thread.
    ZApplication::GetGameInterface()->SetState(GUNZ_STAGE); < Try to define that in the main thread, you will see what will happen + on stage creation gunz state stay (GUNZ_LOBBY).

  6. #6
    Hi, I'm Omar! Vusion is offline
    MemberRank
    Jan 2011 Join Date
    HereLocation
    1,658Posts

    Re: Afk system based on mouse movement (In Stage Room + In Game)

    Quote Originally Posted by Hideasu View Post
    ZApplication::GetGameInterface()->SetState(GUNZ_STAGE); < Try to define that in the main thread, you will see what will happen + on stage creation gunz state stay (GUNZ_LOBBY).
    "combine".

  7. #7
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: Afk system based on mouse movement (In Stage Room + In Game)

    Quote Originally Posted by Hideasu View Post
    ZApplication::GetGameInterface()->SetState(GUNZ_STAGE); < Try to define that in the main thread, you will see what will happen + on stage creation gunz state stay (GUNZ_LOBBY).
    Why would you set the state of GunZ? Just attach your piece of code to a stage specific function that gets called every now and then (ZMyCharacter has a few, pretty sure there's plenty more) and you're good to go.

    Threads for one simple command is no go, especially not if you don't add a call to Sleep() to it, it'll keep taking processing time from your processor making the game lag on older machines.



Advertisement