Skip to content

[VScript] Add ability to send UserMessages #1210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

horiuchii
Copy link

Description

This PR adds the CScriptUserMessage class which allows VScript to write data to an instance of this class and then call a member function to execute the message inside.
This would allow scripters to call User Messages only called by certain entities like game_text, game_text_tf, env_shake without the need to spawn them or messages that are currently impossible to call with VScript like ShowMenu, VGUIMenu and various others.

Usage

To execute a User Message in VScript, the user will call the global function UserMessageBegin() which takes a parameter for the message name.
After that, they can write any data they wish and then call the Execute() member function with a filter parameter.
This way, User Messages can be stored, modified and executed at any point in time.

Example Script

local UserMessage = UserMessageBegin("KeyHintText")
UserMessage.WriteByte(1)
local UserMessageInstance = UserMessage

UserMessage.WriteString("%+attack% Press this key.")
UserMessageInstance.WriteString("%+attack2% Or this key.")

UserMessage.Execute({
	filter_type = RECIPIENT_FILTER_SINGLE_PLAYER
	filter_entity = GetPlayerFromUserID(2)
})

UserMessage.Execute({
	filter_type = RECIPIENT_FILTER_SINGLE_PLAYER
	filter_entity = GetPlayerFromUserID(3)
})

UserMessageInstance.Execute({
	filter_type = RECIPIENT_FILTER_SINGLE_PLAYER
	filter_entity = GetPlayerFromUserID(4)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant