-
Notifications
You must be signed in to change notification settings - Fork 5
Client Server Commands
Jason Stallings edited this page Dec 6, 2022
·
3 revisions
import { getPlayer } from "@asledgehammer/pipewrench"
import { onServerCommand } from "@asledgehammer/pipewrench-events"
onServerCommand.addListener((module, command, args) => {
if (module != "TestMod") return
if (command == "pong") {
getPlayer().Say("Received command pong!")
}
})
import { isClient, isServer, sendServerCommand, triggerEvent } from "@asledgehammer/pipewrench"
import { onClientCommand } from "@asledgehammer/pipewrench-events"
onClientCommand.addListener((module, command, player, args) => {
if (isClient()) return; // dont execute on clients
if (module != "TestMod") return
if (command == "ping") {
print("Server received command ping!")
if (isServer())
sendServerCommand(player, "TestMod", "pong", args) // send normally if server
else
triggerEvent("OnServerCommand", "TestMod", "pong", args) // send hack for single-player
}
})