forked from azerothcore/acore-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Example with arrow function | ||
* | ||
* This is just an Hello World | ||
*/ | ||
export const OnPlayerLogin: player_event_on_login = (event, player) => { | ||
player.SendChatMessageToPlayer( | ||
ChatMsg.CHAT_MSG_WHISPER, | ||
Language.LANG_UNIVERSAL, | ||
"Hello World", | ||
player | ||
); | ||
}; | ||
|
||
RegisterPlayerEvent(PlayerEvents.PLAYER_EVENT_ON_LOGIN, (...args) => | ||
OnPlayerLogin(...args) | ||
); | ||
|
||
/** | ||
* | ||
* This is an example of how to use TypeScript classes | ||
* and implement hook methods inside it. | ||
* | ||
* A class can be useful to implement more complex | ||
* scripts that can be instantiated or extended | ||
* | ||
*/ | ||
export class PlayerChat { | ||
previousMessage: string; | ||
|
||
/** | ||
* | ||
* @param firstMessage The first message to display | ||
*/ | ||
constructor(firstMessage: string) { | ||
this.previousMessage = firstMessage; | ||
} | ||
|
||
OnPlayerChat: player_event_on_chat = ( | ||
event: number, | ||
player: Player, | ||
msg: string | ||
): string | boolean => { | ||
const sanitized = msg; | ||
|
||
msg = sanitized != msg ? `${sanitized} (Sanitized)` : msg; | ||
|
||
player.SendChatMessageToPlayer( | ||
ChatMsg.CHAT_MSG_WHISPER, | ||
Language.LANG_UNIVERSAL, | ||
`Previous message: ${this.previousMessage}, current message: ${msg}`, | ||
player | ||
); | ||
|
||
this.previousMessage = msg; | ||
|
||
return true; | ||
}; | ||
} | ||
|
||
const playerChat = new PlayerChat("First Message"); | ||
|
||
RegisterPlayerEvent(PlayerEvents.PLAYER_EVENT_ON_CHAT, (...args) => | ||
playerChat.OnPlayerChat(...args) | ||
); |