Sign In Register

How can we help you today?

Start a new topic
Answered

Add fake player

Hello Sir,
        I want to automatically add one fake player in match on No Match found message when any player dont find match. 

Best Answer

 Hey Ram,

You can also manually create a matchmaking request for your player and then another for the dummy player who's ID you know...

// find match as me //
var matchReq1 = new SparkRequests.MatchmakingRequest()
matchReq1.matchShortCode = "level_a";
matchReq1.matchGroup = "player1_friends";
matchReq1.skill = 0;
matchReq1.Send();
// // find match as dummy //
var matchReq1 = new SparkRequests.MatchmakingRequest()
matchReq1.matchShortCode = "level_a";
matchReq1.matchGroup = "player1_friends";
matchReq1.skill = 0;
matchReq1.SendAs("588072be23791d04bdab1313");


Hi Ram, 


You can use the following to do this in the user MatchNotFoundMessage.


//this will add the current player and the fake player to a match. The fake playerid is from my game you need to sub it for a bot player from your game for this to work.
Spark.getMultiplayer().createMatchById([Spark.getPlayer().getPlayerId(),"5877bc0c23791d04bd0ecf33"]);

 

Try that and let us know if you have any further questions.


Thanks,

Liam


HI,
           But it is creating match without any short code. Now I want to add short code into that match. Is that possible ?


 

Thanks
Ram Lalu

Hi Ram,


You won't need the shortCode as the players have been matched manually. No matchmaking will be taking place here so the shortCode is not required.


Thanks,

Liam 

Answer

 Hey Ram,

You can also manually create a matchmaking request for your player and then another for the dummy player who's ID you know...

// find match as me //
var matchReq1 = new SparkRequests.MatchmakingRequest()
matchReq1.matchShortCode = "level_a";
matchReq1.matchGroup = "player1_friends";
matchReq1.skill = 0;
matchReq1.Send();
// // find match as dummy //
var matchReq1 = new SparkRequests.MatchmakingRequest()
matchReq1.matchShortCode = "level_a";
matchReq1.matchGroup = "player1_friends";
matchReq1.skill = 0;
matchReq1.SendAs("588072be23791d04bdab1313");

Hello,


     I Added fake Player In match using Below Code:


 var matchReq1 = new SparkRequests.MatchmakingRequest()

 matchReq1.matchShortCode = matchCode;

 matchReq1.skill = 0;

 matchReq1.Send();

 

 // // find match as dummy //

 var matchReq1 = new SparkRequests.MatchmakingRequest()

 matchReq1.matchShortCode = matchCode;

 matchReq1.skill = 0;

 matchReq1.SendAs("588eee000000000000000001");

 

 // search pending matches as dummy //

 var request = new SparkRequests.FindPendingMatchesRequest();

 request.matchShortCode = matchCode;

 request.maxMatchesToFind = 1;

 var response = request.SendAs("588eee000000000000000001");

 var pendingMatchId = response.pendingMatches[0].id;

 

 // join dummy into player1 match //

 var joinReq = new SparkRequests.JoinPendingMatchRequest();

 joinReq.pendingMatchId = pendingMatchId;

 //joinReq.matchShortCode = matchCode;

 joinReq.SendAs("588eee000000000000000001”);


Now fake Player Added in match but the real Player is left the Match, this match is not removed from the "pending Match" Collection. How to Remove this Match from the "pending Match" Collection?

Login to post a comment