Hello. I have a script here, that gives the player a gift for each day he plays. At the moment, the gift is always +250.000 Money. How can I make a random function that gives the player every day an other gift, like the player gets 300.000 or 400.000 or 100.000 …
How can I do it, that the player recieves every day an other gift but randomly?
HERE IS MY SCRIPT:
_
var lastDay : int = System.DateTime.Now.get_Day();
var show : boolean = false;
var money : int;
var Design1 : GUIStyle;
var giftpic : Texture2D;
function Start () {
money = PlayerPrefs.GetInt("Total_Money");
if (System.DateTime.Now.get_Day() - lastDay == 1) {
Debug.Log("Have lotsa money!");
show = true;
money += 250000;
PlayerPrefs.SetInt("Total_Money", money);
}
}
function Update () {
}
function OnGUI () {
if(show == true){
GUI.Box(Rect(-10,-10,820,620),"");
GUI.Label(Rect(100,300,400,25),"You got a gift! +250000 money");
GUI.Box(Rect(280,150,300,300), giftpic, GUIStyle.none);
if(GUI.Button(Rect(350,500,100,40),"Accept gift", Design1)){
show = false;
}
}
}
Thank you for the help, but the lastDay variable is working in my game. I tested it many times. Or where to put the script than?
– worldofcars+1 , random int fallout strikes again!
– AlucardJayit I do this, I get the EQUALS 0 thing there. Can you write me exactly, where to put the script, also with this random gift? Please
– worldofcarsis this also working in Webplayer? my game is only in webplayer
– worldofcarsAh yes, if you look at the docs on it it explicitly says: In the web player it is called when the web view is closed. So, all good then. :)
– Kleptomaniac