HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Disabling Single Player Mode?

08-27-2008, 10:17 PM#1
Zero
So, I want to make it so you cannot play my map in single player mode, but i do want it to be able to be played over a lan game single player.

This is to disable cheats.

So, @ the start of the map I set up a number of functions that say:

If player X = playing and slot status = used, then set (variable) true

If variable = true, fire intro trigger, if not end game with message and defeat.

This works fine if I wanted it to be NOT single player mode @ all.

How do I set up something to say, if player 1 is only player in game, and is not threw custom game, then allow play?
08-27-2008, 10:21 PM#2
TheDamien
bj_isSinglePlayer

Seems suspiciously easy, but I recall it working.

If not: http://www.wc3jass.com/viewtopic.php?t=288
08-27-2008, 10:57 PM#3
Captain Griffen
There are several ways to do this, basically based on functions acting differently. Gamecache has at least one I think, some returns boolean, probably to do with saving them, but I can't remember exactly which function.
08-27-2008, 11:15 PM#4
Zero
Ok, I have no idea how to read jass... So in that link does that save if in "single player mode" to a boolean variable?

If it does, whats the name of it and how do I add that into a trigger?

For Captain = I'll look into gamecache as well...
08-28-2008, 12:22 AM#5
TheDamien
Add this code:

Collapse JASS:
function isSinglePlayer takes nothing returns boolean
   local gamecache gc=InitGameCache("gc.w3v")
   call StoreInteger(gc,"test","test",9)
   return SaveGameCache(gc)
endfunction

To your map header, then create a variable called "SinglePlayer" or something. Now on map initialization have some custom script run like:
Trigger:
Custom script: set udg_SinglePlayer = isSinglePlayer()

After it has been set SinglePlayer will be true if the game is in single player mode, false otherwise.
08-28-2008, 03:25 AM#6
Zero
Um.. Ok I did that and now I get:

08-28-2008, 03:29 AM#7
Ammorth
Check the previous line that has code (not a blank line or comment // comment). Sometimes the Syntax Checker marks the wrong line and the error is actually on the line before.
08-28-2008, 03:37 AM#8
Zero
Well... I have a shit load of JASS stuff on the map and I think it's making it so I can't add anymore. I came to this conclusion by removing all the code and it worked, but I need the code that's in there for GUI triggers I have set up...

I use WE Unlimited latest version and I have enabled the advanced triggers.

..I would show u all the crap but it's over 370060 characters and I can't post it...

Does anyone know if you can convert this JASS trigger into a GUI one?
08-28-2008, 04:19 AM#9
DioD
There is no reason to ignore "bj_isSinglePlayer" variable.
08-28-2008, 04:21 AM#10
Zero
What do you mean?
08-28-2008, 04:38 AM#11
DioD
This function is useless:
Code:
function isSinglePlayer takes nothing returns boolean
   local gamecache gc=InitGameCache("gc.w3v")
   call StoreInteger(gc,"test","test",9)
   return SaveGameCache(gc)
endfunction
08-28-2008, 04:42 AM#12
Zero
Ok... Then can u post code or a trigger that accomplishes what I'm trying to do?
08-28-2008, 05:38 AM#13
DioD
This is GUI version of function posted above:

Trigger:
Untitled Trigger 001
Collapse Events
Time - Elapsed game time is 5.00 seconds
Conditions
Collapse Actions
Game Cache - Create a game cache from MapName.w3v
Game Cache - Store 0.00 as a of a in (Last created game cache)
Game Cache - Save (Last created game cache)
Game Cache - Clear (Last created game cache)
Game Cache - Create a game cache from MapName.w3v
Collapse Game Cache - Reload all game cache data from disk
Collapse Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(a is stored as a Real of a in (Last created game cache)) Equal to (==) True
Collapse Then - Actions
Game - Display to (All players) the text: SINGLE
Collapse Else - Actions
Game - Display to (All players) the text: NOT
08-28-2008, 05:58 AM#14
Ammorth
no, the save native returns a boolean telling if it saved the cache sucessfully, something that cannot be achieved in GUI (except with custom script).

Since you can't save caches on battle.net or lan, it will return false (cache never saved) so you can then assume the game is played in an environment that has cheats disabled.

There is an issue though, if your cache data is full, you can't save another cache. The value was 255 caches, but the data system has since been changed, so it might be more or less.

The point is, there is no 100% guarantee that a map is being played on battle.net with only 1 person.
08-28-2008, 06:27 AM#15
Zero
Um, so I set it up like this:
Trigger:
Intro Setup Copy Copy 2 Copy
Collapse Events
Time - Elapsed game time is 1.00 seconds
Conditions
Collapse Actions
Game Cache - Create a game cache from MapName.w3v
Game Cache - Store 0.00 as a of a in (Last created game cache)
Game Cache - Save (Last created game cache)
Game Cache - Clear (Last created game cache)
Game Cache - Create a game cache from MapName.w3v
Game Cache - Reload all game cache data from disk
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(a is stored as a Real of a in (Last created game cache)) Equal to True
Collapse Then - Actions
Game - Display to Player 1 (Red), at offset (0.00, 0.00) the text: |c0096ecf5Single Pl...
Wait 8.00 seconds
Game - Defeat Player 1 (Red) with the message: Single Player Mode ...
Collapse Else - Actions
Dialog - Clear Intro
Dialog - Change the title of Intro to Watch the Intro?
Dialog - Create a dialog button for Intro labelled |c00008000Watch|r
Set Watch = (Last created dialog Button)
Dialog - Create a dialog button for Intro labelled |c00ea0000Skip|r
Set Skip = (Last created dialog Button)
Wait 1.00 seconds
Game - Display to Player 1 (Red), at offset (0.00, 0.00) the text: |c0096ecf5Single Pl...
Wait 8.00 seconds
Game - Defeat Player 1 (Red) with the message: Single Player Mode ...
Game - Display to (All players) for 15.00 seconds the text: |c00afafd8Welcome t...
Wait 16.00 game-time seconds
Dialog - Show Intro for Player 1 (Red)
Trigger - Destroy (This trigger)
It kicks me out of a lan game when playing... Is this not set up right?

Btw the bj_isSinglePlayer variable only detects if their is 1 player in the game not if in custom game or over bnet/lan.
Tested with this trigger:
Trigger:
Detect Single Player Mode
Collapse Events
Time - Elapsed game time is 1.00 seconds
Conditions
Collapse Actions
Custom script: if bj_isSinglePlayer then
Custom script: call EndGame(false)
Custom script: endif
Trigger - Destroy (This trigger)
You know the original JASS trigger works perfectly... The only thing is, I can't add it to my map....