SetUserVariablesRequest Class |
Namespace: Sfs2X.Requests
public class SetUserVariablesRequest : BaseRequest
The SetUserVariablesRequest type exposes the following members.
Name | Description | |
---|---|---|
SetUserVariablesRequest |
Creates a new SetUserVariablesRequest instance.
|
void SomeMethod() { sfs.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, OnUserVarsUpdate); // Create some User Variables List<UserVariable> userVars = new List<UserVariable>(); userVars.Add( new SFSUserVariable("avatarType", "SwedishCook") ); userVars.Add( new SFSUserVariable("country", "Sweden") ); userVars.Add( new SFSUserVariable("x", 10) ); userVars.Add( new SFSUserVariable("y", 5) ); sfs.Send( new SetUserVariablesRequest(userVars) ); } void OnUserVarsUpdate(BaseEvent evt) { List<String> changedVars = (List<String>)evt.Params["changedVars"]; User user = (User)evt.Params["user"]; // Check if the user changed his x and y User Variables if (changedVars.Contains("x") || changedVars.Contains("y")) { // Move the character to a new position... UpdateClientPosition(user); } }