- Home /
Make an area that is only accessible through buying a game addon?
So basically, I am quite new to scripting and I REALLY need some hints and tips here guys. I want to make an area of my map blocked off, until say... They purchase the addon which unlocks the next area... How would I go about doing this... I was thinking if anyone new any codes that would check a directory for a file and if it's there it will remove the invisible barrier and allow access through the city? I'm sure this is a much asked question for people who have just started, so please reply fast.
OUTLINE OF WHAT I NEED/IDEA
Help with writing a script that will check the system directory... (eg. C:\Users\Desktop\Addon.dll, Obviously I can encrypt the DLL file so you can't just make it yourself) and then if that file exists and contains a certain text inside... Then a gameobject that will be blocking the way (or multiple game objects) will then allow access.
CAN ANYONE HELP ME?!
So far I have this for my checking of the file code...
function Start () {
}
function Update () {
if (System.IO.File.Exists("D:\Addon\AddonCheck.txt")) {
//Remove or disable gameObject. THIS IS WHAT I DON'T KNOW HOW TO DO.
}
}
Also this only checks if the file exists, not if the file has a certain string in it. I need it to check the file and see if it contains the string of say... "addon 1.1 = true" And if it says this then it will unlock a certain gameObject allowing the player to walk through...
May I add that the text file will be able to contain different addons if they have more than one... So it should check for all of them...
Thanks! -Aaron
Answer by dorpeleg · Jan 24, 2013 at 10:24 PM
Here is an example I found on the forums:
http://forum.unity3d.com/threads/99427-Step-by-step-tutorial-for-c-.net-dll-and-Unity3D(Pro-only).
It states there how to load the dll and access functions inside it.
I think that is what you are looking for.
After checking if the file in there, load it, then use some function to make sure this is your real addon file.
Thanks for this!:) The only problem is, now I have this in my project, do you know of any functions to remove or disable a game object?
Disabling an object is easy.
Just use gameobject.active = false;
This is not done inside the dll.
In the dll you need to make up your own function that will eventually return true or false (this is just an example) of if the addon is genuine or not.
In the example shown in the link, he is creating a function to return a string.
I'm not sure how to build a function to check if the addon is genuine or not, but in unity you should run the function and if it returns true (addon is genuine) then use the code I mentioned above.
Cheers man, do you have skype where I can quick chat you? Just to make it easier... I want to show you my code in more detail and it's faster than on here?
azerbijon123 (Add me)
Hey Dorpeleg! Please add me on Skype again! aarongregory97
sure, sup? you can still reach me on the same skype account if you want
Not much man you? I don't have Skype anymore, but I can add you on S$$anonymous$$m if you have it?
Your answer
![](https://koobas.hobune.stream/wayback/20220613091534im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Variable doesn't change when box hit trigger area 3 Answers
How to Stop running after a few Seconds ? 1 Answer
How can i create anouther jump script? 0 Answers
i need some code suggestions 1 Answer