Difference between revisions of "User:AdminSR1/Scripting Protecting Plug-in Files"
imported>CraftySentinel (→Script) |
imported>CraftySentinel |
||
Line 1: | Line 1: | ||
==Script== | ==Script== | ||
This is an example script. It can be used to prevent access to a plugin file by displaying a series of messages and menus that will either let the player into the game with the plug-in or take them back to the main menu where they can uninstall the plug-in file. | This is an example script. It can be used to prevent access to a plugin file by displaying a series of messages and menus that will either let the player into the game with the plug-in or take them back to the main menu where they can uninstall the plug-in file. | ||
Line 41: | Line 26: | ||
Message Property FailMessage01 Auto Const | Message Property FailMessage01 Auto Const | ||
{Message To Show If User Has Plugin Installed} | {Message To Show If User Has Plugin Installed} | ||
Message Property WarningMessage01 Auto Const | Message Property WarningMessage01 Auto Const | ||
Line 59: | Line 41: | ||
Event OnQuestInit() | Event OnQuestInit() | ||
If (Game.IsPluginInstalled("ExamplePlugin01.esp")) | If (Game.IsPluginInstalled("ExamplePlugin01.esp")) | ||
Menu() | Menu() | ||
Else | Else | ||
FailMessage01.Show() | |||
Self.Stop() | Self.Stop() | ||
Self.Reset() | Self.Reset() | ||
Line 106: | Line 81: | ||
</source> | </source> | ||
Revision as of 01:28, 2 October 2018
Script
This is an example script. It can be used to prevent access to a plugin file by displaying a series of messages and menus that will either let the player into the game with the plug-in or take them back to the main menu where they can uninstall the plug-in file.
EXPLANATION:
The first part of the script uses the Group Function. This is used to group properties together and make a cleaner look to the script. Note that groups, like other functions have to be ended using EndGroup. Group Functions can be named which is what is after the word Group, the first group is named Reqiured_Properties. Group names can not have spaces so underscores will have to do. Once a group has been created, script properties can be put inside them. Using {} underneath either a group or a property will allow you to add a note so that you can refer back to it later.
The next part of the script after all properties have been declaired is the Requirements Section, which is where you can define what should be true, or even false in this case. We are using Game.IsPluginInstalled() to check if a plugin is installed and enabled in the players game. If so a message will be showed.
The Self.Reset() and Self.Stop() Functions are part of the Quest scripting and stop and restart the quest so that the message will be displayed if the player go to the menu and loads the game again.
The functions below all of this are what control happens with messages and menus where aiButton is the integer that will correspond with what button is pressed in the message box and then will follow out set instructions. These functions are then called such as how the first function called Menu() is called when the user has met the reqiurments of the script.
To learn more about menu's and buttons please see this tutorial by TheDarkFox127: https://www.youtube.com/watch?v=Hm8GBbTLQAs
Scriptname PluginProtector extends Quest
Group Required_Properties
{Messages and Holotape Required For Script To Run}
Message Property StartUpMessage01 Auto Const
{Message To Show When Menu Function Is Called}
Message Property FailMessage01 Auto Const
{Message To Show If User Has Plugin Installed}
Message Property WarningMessage01 Auto Const
{Message To Show Player When Important Button Is Pressed}
Message Property Contributors01 Auto Const
{Lists Current QAT's}
ObjectReference Property TpMarker01 Auto Const
{Place To Send Player}
EndGroup
; -------------------------------------------------- Does User Meet Requirements? This section will check if the player / user meets requiremets to access the plugin file.
Event OnQuestInit()
If (Game.IsPluginInstalled("ExamplePlugin01.esp"))
Menu()
Else
FailMessage01.Show()
Self.Stop()
Self.Reset()
Game.QuitToMainMenu()
EndIf
EndEvent
; -------------------------------------------------- Main Message Menu This section will control what happens when the player presses a button in the message pop-up
Function Menu(int aiButton = 0)
aiButton = StartUpMessage01.Show()
If aiButton == 0
Self.Stop()
Self.Reset()
Game.QuitToMainMenu()
ElseIf aiButton == 1
Game.FastTravel(TpMarker01)
ElseIf aiButton == 2
ImportantMenu()
ElseIf aiButton == 3
QATs()
EndIf
EndFunction
; -------------------------------------------------- Warning Message Menu This section will display any other information that is important or relevant
Function ImportantMenu(int aiButton = 0)
aiButton = WarningMessage01.Show()
If aiButton == 0
Menu()
EndIf
EndFunction
; -------------------------------------------------- Contributors & QAT's This section will display current testers of this Alpha Release mod in the form of a message
Function QATs(int aiButton = 0)
aiButton = Contributors01.Show()
If aiButton == 0
Menu()
EndIf
EndFunction