[Trigger] How to detect "Single Player"?

Status
Not open for further replies.
Level 9
Joined
Oct 11, 2009
Messages
477
Hello... Could I ask on how to detect Single Player gaming mode? Because I am creating an anti-cheat system on my map. JASS or GUI versions are accepted but its better for you to send me a GUI version. Thanks!!!!!:cute:
 
Level 9
Joined
Oct 11, 2009
Messages
477
Thanks!!!

Yes! I tried your recommendation and it worked! Thanks to you(+rep 4 u)!!! As you see, I followed the tutorial at this link:http://clancbs.com/board/showthread.php?t=2802 which is more complicated than the one you recommended, I also followed the correct sequence of the tutorial but when I tested it, the system also initializes even if I tried it in Multiplayer. Anyway Thanks for your reply!!!:grin::grin::grin:
 
If you want a simple check, do this:
  • Custom Script: if bj_isSinglePlayer then
    • //do your actions
  • Custom Script: endif
Blizzard initially sets this variable when the game starts/initializes:
JASS:
set bj_isSinglePlayer = false
    set userControlledPlayers = 0
    set index = 0
    loop
        exitwhen index >= bj_MAX_PLAYERS
        if (GetPlayerController(Player(index)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(index)) == PLAYER_SLOT_STATE_PLAYING) then
            set userControlledPlayers = userControlledPlayers + 1
        endif
        set index = index + 1
    endloop
    set bj_isSinglePlayer = (userControlledPlayers == 1)

But there was a slight debate about the functionality of it:
http://www.thehelper.net/forums/showthread.php?t=147352
 
Level 11
Joined
Mar 31, 2009
Messages
732
Hmm. For some reason that bj_isSinglePlayer doesn't show in the Jasshelper function/constant listing.
Anyway, that is essentially the method I posted above, it counts the number of human players in the game, but doesn't distinguish between playing in single player mode, and having one player in a game on LAN/battle.net.
 
Hmm. For some reason that bj_isSinglePlayer doesn't show in the Jasshelper function/constant listing.
Anyway, that is essentially the method I posted above, it counts the number of human players in the game, but doesn't distinguish between playing in single player mode, and having one player in a game on LAN/battle.net.

of course it wont show in the function list... all bj constants doesnt show up there since they are not functions...

anyway when I used that trigger, it will only return true when the game is single player but returns false when you play on LAN even with only one player...
 
Level 6
Joined
May 19, 2004
Messages
267
anyway when I used that trigger, it will only return true when the game is single player but returns false when you play on LAN even with only one player...
As you see, I followed the tutorial at this link:http://clancbs.com/board/showthread.php?t=2802 which is more complicated than the one you recommended, I also followed the correct sequence of the tutorial but when I tested it, the system also initializes even if I tried it in Multiplayer. Anyway Thanks for your reply!!!:grin::grin::grin:

The method works perfectly fine, so you shouldn't have any problems if you imported it correctly.
Did you use the Jass-version or the GUI-version?

That link you posted is 2 years old and will no longer work as of a patch a while ago.

Which patch?
 
Level 11
Joined
Jan 25, 2009
Messages
572
Ehrm, it's easy I think, here's the trigger I made for you, and i think it should work, otherwise use After 0 second of game time.
  • Single Player Detection
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set SPD_Group = (All players controlled by a User player)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of players in SPD_Group) Equal to 1
        • Then - Actions
          • -------- You'r actions here --------
        • Else - Actions
 
Level 7
Joined
Jul 18, 2009
Messages
272
tjordell, yours also kicks a player who plays alone in a LAN/battle.net-game.

I know another solution that does exactly what the thread starter wants without using game cache. It uses the nice function "Cheat" which does just that: it uses cheats. (And works only in Singleplayer-Mode, just like the normal cheats) ^^

JASS:
function Trig_AntiSinglePlayerMode_Kopieren_Actions takes nothing returns nothing
    call Cheat("greedisgood 1000000")
    call TriggerSleepAction(0.01)
    if ( GetPlayerState(GetLocalPlayer(), PLAYER_STATE_RESOURCE_GOLD ) == 1000000 ) then
        call CustomDefeatBJ( GetLocalPlayer(), "No Single-Player-Mode!" )
    endif
endfunction
 
Level 9
Joined
Oct 11, 2009
Messages
477
tjordell, yours also kicks a player who plays alone in a LAN/battle.net-game.

I know another solution that does exactly what the thread starter wants without using game cache. It uses the nice function "Cheat" which does just that: it uses cheats. (And works only in Singleplayer-Mode, just like the normal cheats) ^^

JASS:
function Trig_AntiSinglePlayerMode_Kopieren_Actions takes nothing returns nothing
    call Cheat("greedisgood 1000000")
    call TriggerSleepAction(0.01)
    if ( GetPlayerState(GetLocalPlayer(), PLAYER_STATE_RESOURCE_GOLD ) == 1000000 ) then
        call CustomDefeatBJ( GetLocalPlayer(), "No Single-Player-Mode!" )
    endif
endfunction


meOme, could you post a GUI version of that JASS code? so I can understand it more easily. Thanks!:cute:
 
Level 9
Joined
Oct 11, 2009
Messages
477
  • Custom script: if (not ReloadGameCachesFromDisk()) then
  • Game - Display to all players "The game is online!"
  • Custom script: else
  • Game - Display to all players "The game is offline."
  • Custom script: endif

TriggerHappy, your recommendation is accurate but do you know another way of detecting Single Player without using game cache functions?
 
Level 11
Joined
Mar 31, 2009
Messages
732
meOme, could you post a GUI version of that JASS code? so I can understand it more easily. Thanks!:cute:

It cheats the "greedisgood" cheat, then checks the players gold. If the cheat worked (only works in singleplayer mode) then it gives them a defeat.

TriggerHappy, your recommendation is accurate but do you know another way of detecting Single Player without using game cache functions?

Yes we have all posted half a dozen methods in this thread already. Why do you want more, or what was wrong with the ones we provided you?


To check if its just one player in the game (single player), then count the number of human players in the game.

To check if its single player mode, then either mess with the gamecache, or try and force a cheat then check if it worked.
 
Level 9
Joined
Oct 11, 2009
Messages
477
It cheats the "greedisgood" cheat, then checks the players gold. If the cheat worked (only works in singleplayer mode) then it gives them a defeat.



Yes we have all posted half a dozen methods in this thread already. Why do you want more, or what was wrong with the ones we provided you?


To check if its just one player in the game (single player), then count the number of human players in the game.

To check if its single player mode, then either mess with the gamecache, or try and force a cheat then check if it worked.


I followed the other posts but some have bugs like when I test my map and it loads, it prevents the map from loading and I tried some but the map also initialize the trigger even when I test my map in Multiplayer mode.
 
Level 7
Joined
Jul 18, 2009
Messages
272
meOme, could you post a GUI version of that JASS code? so I can understand it more easily. Thanks!:cute:
Ok, I tried to make it the least custom script possible:
  • AntiSinglePlayerMode
    • Ereignisse
      • Zeit - Elapsed game time is 0.00 seconds
    • Bedingungen
    • Aktionen
      • Custom script: call Cheat("greedisgood 1000000")
      • Wait 0.01 game-time seconds
      • For each (Integer A) from 1 to 12, do (Actions)
        • Schleifen - Aktionen
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • 'IF'-Bedingungen
              • ((Player((Integer A))) Aktuelles Gold) Gleich 1000000
            • 'THEN'-Aktionen
              • Spiel - Defeat (Player((Integer A))) with the message: No Single-Player-Mode!
            • 'ELSE'-Aktionen
Of course you could also use other cheats, if you don't want the "1000000" popping up in the gold/lumber values.
 
Status
Not open for further replies.
Top