- Home /
How Can I submit and use statics in Kongregate API
Hi, I need some help.
I'm having problem working with the Kongregate Statics.
I have used this scrip that I've found in Unity-Answers.
I have submitted the same named statics in my script in the Kongregate Statics API
and attached the script to a Gui.text object named KongregateAPI, to show info.
Username found but my problem is nothing was happened with statics variables.
I need to save statics of user and load them for next play.
Such as the level is completed and we can play next level.
Thank you for your help.
var isKongregate = false; var userId = 0; static var username = "Guest"; var gameAuthToken = "";
var texts = ""; static var score = 0; // static 1 static var kills = 0; // static 2 static var gameComplete = 0; // static 3
function OnKongregateAPILoaded(userInfoString){ // We now know we're on Kongregate isKongregate = true; Debug.Log("ON KONG");
// Split the user info up into tokens var params = userInfoString.Split("|"[0]); userId = parseInt(params[0]); username = params[1]; gameAuthToken = params[2]; }
function Awake() { // This game object needs to survive multiple levels DontDestroyOnLoad (this);
// Begin the API loading process if it is available
Application.ExternalEval( "if(typeof(kongregateUnitySupport) != 'undefined'){" + " kongregateUnitySupport.initAPI('KongregateAPI', 'OnKongregateAPILoaded');" + "}" );
}
function Update () {
if (Input.GetButtonDown ("Jump")) {
Application.ExternalCall("kongregate.stats.submit","score",1334);
Application.ExternalCall("kongregate.stats.submit","kills",6);
Application.ExternalCall("kongregate.stats.submit","gameComplete",1);
}
if (isKongregate) texts = "v5 \nKONG is available\nUsernam is : " +username+"\nscore = "+score+"\nkills " +kills+"\ngameComplete : "+gameComplete+"\nPress Space to submit new statics"; else texts = "Not available";
guiText.text = texts; }
Am I correct that you want to use $$anonymous$$ongregates stat submit function to store and retrieve player data? Interesting, never thought of saving your game like that. I'm curious if it's possible, I've never tried to retrieve data from the $$anonymous$$ong API, only submit.