- 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!!!!!

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)
bj_isSinglePlayer
doesn't show in the Jasshelper function/constant listing.Hmm. For some reason thatbj_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.
Other constants show in that listing if I change it to list constants instead of functions. That one isn't there though.
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!!!![]()
That link you posted is 2 years old and will no longer work as of a patch a while ago.
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
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
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
meOme, could you post a GUI version of that JASS code? so I can understand it more easily. Thanks!![]()
TriggerHappy, your recommendation is accurate but do you know another way of detecting Single Player without using game cache functions?
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.
Ok, I tried to make it the least custom script possible:meOme, could you post a GUI version of that JASS code? so I can understand it more easily. Thanks!![]()
But if you input this JASS code, you don't have to do anything with it, it's complete in itself: it'l just defeat the player in singleplayer
![]()
But if you input this JASS code, you don't have to do anything with it, it's complete in itself: it'l just defeat the player in singleplayer
![]()