本文整理汇总了TypeScript中camelot-unchained.client.OnFriendlyTargetNameChanged方法的典型用法代码示例。如果您正苦于以下问题:TypeScript client.OnFriendlyTargetNameChanged方法的具体用法?TypeScript client.OnFriendlyTargetNameChanged怎么用?TypeScript client.OnFriendlyTargetNameChanged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类camelot-unchained.client
的用法示例。
在下文中一共展示了client.OnFriendlyTargetNameChanged方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: default
export default () => {
if (!hasClientAPI()) return;
/**
* Create a new Warband
*
* usage:
*
* 1. Create a temporary warband, this type of warband will go away after all members leave. This is the standard "Party".
* /createWarband
*
* 2. Create a permanent warband, this type of warband will live on until it is abandonded by all its members.
* /createWarband Friendship Warriors
*/
registerSlashCommand('createWarband', 'Create a Warband. Optionally, accepts a name if you wish to make this a permanent Warband.', (name: string = '') => {
webAPI.warbands.createWarband(client.shardID, client.characterID, false, name)
.then((response: any) => {
if (!response.ok) {
// something went wrong
console.error(response);
return;
}
// success
});
});
/**
* Invite a player to your warband you are invite
*
* usage: /invite mehuge
*/
let friendlyTargetName: string = '';
client.OnFriendlyTargetNameChanged((name: string) => {
friendlyTargetName = name;
});
registerSlashCommand('invite', 'Invite a player to your warband. Will use either your current friendly target, or a character name if you provide one.',
(name: string = '') => {
if (name.length > 0) {
webAPI.warbands.inviteCharacterToWarbandByName(client.shardID, client.characterID, name)
.then((response: any) => {
if (!response.ok) {
// something went wrong
console.error(response);
return;
}
// success
});
} else if (friendlyTargetName && friendlyTargetName !== '') {
webAPI.warbands.inviteCharacterToWarbandByName(client.shardID, client.characterID, friendlyTargetName)
.then((response: any) => {
if (!response.ok) {
// something went wrong
console.error(response);
return;
}
// success
});
} else {
systemMessage('No friendly target to invite. Provide a name or select a friendly target and try again.');
}
});
registerSlashCommand('joinWarband', 'Join an existing Warband.', (args: string) => {
let argv = yargs(args);
if (argv._.length === 1) {
// name only
webAPI.warbands.joinWarbandByName(client.shardID, argv._[0], client.characterID)
.then((response: any) => {
if (!response.ok) {
// something went wrong
console.error(response);
return;
}
// success
});
} else if (argv._.length === 2) {
// name and invite code
webAPI.warbands.joinWarbandByName(client.shardID, argv._[0], client.characterID, argv._[1])
.then((response: any) => {
if (!response.ok) {
// something went wrong
console.error(response);
return;
}
// success
});
} else {
//.........这里部分代码省略.........