Hi, I know that i can reset the leaderboard entries from a User from the web php side.
But i want to do it from the Unity side... Is there any function?
There isn't such functionality built-in, but you can create your own custom add-on and add this action in its webservice, you can read how to create add-ons from the Blog section on this website at here.
For example, in your case you would have:
in your client.php
CloseConnection(); exit(); function wsDeleteScores() { global $WS_REQUEST, $LoggedAccount; $success = FALSE; $message = ""; if (!$LoggedAccount->IsLogged()) { $message = ErrorMessage::Get(ERROR_USER_NOT_AUTHENTICATED); } else { $idLeaderboard = isset($WS_REQUEST["IdLeaderboard"]) ? intval($WS_REQUEST["IdLeaderboard"]) : 0; if ($idLeaderboard > 0) { $scores = LeaderBoard_User::LoadAccount($LoggedAccount->Id, $idLeaderboard); foreach ($scores as $score) { $success = $score->Delete(); if (!$success) { $message = "Error deleting score " . $score->Id; break; } } } else { $message = "Invalid leaderboard"; } } Utils::EchoJson(Utils::JsonEncodeSuccessMessage($success, $message)); }
in your Unity addon class
namespace Combu.Addons.YourAddonName { public class YourAddonName { const string WEBSERVICE_ROOT = "addons/youraddonname/client.php"; public static string URL { get { if (CombuManager.isInitialized) { return CombuManager.instance.GetUrl(WEBSERVICE_ROOT); } return string.Empty; } } public static void DeleteScores(string idLeaderboard, Action<bool, string> callback) { CombuForm form = new CombuForm(); form.AddField("action", "delete_scores"); form.AddField("IdLeaderboard", idLeaderboard); CombuManager.instance.CallWebservice(URL, form, (string text, string error) => { bool success = false; if (string.IsNullOrEmpty(error) && !string.IsNullOrEmpty(text)) { Hashtable response = text.hashtableFromJson(); if (response != null && response.ContainsKey("success")) { bool.TryParse(response["success"] + "", out success); if (!success && !string.IsNullOrEmpty(response["message"] + "")) { error = response["message"].ToString(); } } } if (callback != null) callback(success, error); }); } } }
Of course this code is just an example and I didn't test it, but it's just there to give you something to start with (you'll need some PHP development knowledge to create add-ons, but it's not that hard to learn).
FRANCESCO CROCETTI @ SKARED CREATIONS
Thanks for your answer...
i will try it.. but right now i'm alleady confused the end of the unity script what does: </bool,> mean??
and what using directif i need for FromJson
thanks for you effort...
Ops.. I should have fixed the code, it was a copy&paste from another piece of code and forgot to remove the "FromJson" part, also the forum screwed up the code by adding arbitrary "</bool,>".
FRANCESCO CROCETTI @ SKARED CREATIONS
Thanks a lot... I'm still beginner in some way.. I'll give it a try...