I need a getUserVariables example for the iPhone client
I need a getUserVariables example for the iPhone client
Could someone give me an example of getUserVariables? I don't see that in the provided iPhone examples. Specifically, I am setting a score variable in each client. And then at a specific time all clients call getUserVariables, loop through all the clients, and see all clients scores. Many thanks in advance for your help.
here you can get it like this
INFSmartFoxUser *user = //get user form somewhere as per your requirement
[user getVariable:@"Key"];
Here key = The Key you have used when updating user variable
Here in my case I'm updating it like this
Then I call my created function
Here is the method I've created
The above code is an example of working iPhone app.
INFSmartFoxUser *user = //get user form somewhere as per your requirement
[user getVariable:@"Key"];
Here key = The Key you have used when updating user variable
Here in my case I'm updating it like this
Code: Select all
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:your_Object,@"key",nil];
Then I call my created function
Code: Select all
[self setAdditionalDetailsForSFSUser:params roomID:[SFSRoom getId]];
Here is the method I've created
Code: Select all
- (void)setAdditionalDetailsForSFSUser:(NSDictionary*)object roomID:(NSInteger)roomID {
[self.smartFox setUserVariables:object roomId:roomID];
}
The above code is an example of working iPhone app.
Thanks & Regards,
Rahul Vyas,
iPhone Developer.
Rahul Vyas,
iPhone Developer.
What do you want to create?
A Game or something else?
You can do it like this way
Suppose you are creating a card game. And you need to pass turn each time a player plays his card. So you can do this. First Update a room variable named turnToThrow like 1,2,3 for each player the id will be different as you enter in the room each player will get different id. Now when player 1 who has id 1 got the first chance he can play his card. To play his card update p1Card named room variable with his card value. then when you receive onRoomVariablesUpdate display on screen through a method.Also in that method update turnToThrow by increasing id number. I hope you understand.
A Game or something else?
You can do it like this way
Suppose you are creating a card game. And you need to pass turn each time a player plays his card. So you can do this. First Update a room variable named turnToThrow like 1,2,3 for each player the id will be different as you enter in the room each player will get different id. Now when player 1 who has id 1 got the first chance he can play his card. To play his card update p1Card named room variable with his card value. then when you receive onRoomVariablesUpdate display on screen through a method.Also in that method update turnToThrow by increasing id number. I hope you understand.
Thanks & Regards,
Rahul Vyas,
iPhone Developer.
Rahul Vyas,
iPhone Developer.
Thank you for taking the time to respond.
My game is a little different and onUserVariablesUpdate isn't appropriate for what I'm doing.
My task is to display a scoreboard at a certain time in the game.
The scoreboard will display the scores of all players in the room.
There will be 10 players.
So at that time the game has run a loop that will go through all the users in the room, get their score variable and save that into an array.
My game is a little different and onUserVariablesUpdate isn't appropriate for what I'm doing.
My task is to display a scoreboard at a certain time in the game.
The scoreboard will display the scores of all players in the room.
There will be 10 players.
So at that time the game has run a loop that will go through all the users in the room, get their score variable and save that into an array.
Return to “iPhone Objective-C API”
Who is online
Users browsing this forum: No registered users and 15 guests