Ulysses
Home
Help
Ulysses
»
General
»
Developers Corner
»
Running clientside code on ULX
« previous next »
Print
Pages: [
1
]
Go Down
Author
Topic: Running clientside code on ULX (Read 6938 times)
0 Members and 1 Guest are viewing this topic.
Blizzard098
Newbie
Posts: 3
Karma: 0
Running clientside code on ULX
«
on:
July 05, 2019, 09:54:46 pm »
Hey guys,
I'm trying to run some Derma through a ULX command. I've done an "if CLIENT then" statement but that didn't seem to work. It's a very small piece of derma so I don't feel like making a separate file. Any thoughts?
Logged
Timmy
Ulysses Team Member
Sr. Member
Posts: 252
Karma: 168
Code monkey
Re: Running clientside code on ULX
«
Reply #1 on:
July 06, 2019, 08:47:11 am »
The callback function of a ULX command always runs on the server-side.
ULX commonly uses
ULib.clientRPC
to make players run client-side code. While ULX separates these client-side functions into a different file, it is not strictly required.
The example below uses ULib.clientRPC to call ulx.rcvNotify on the client-side - all in one file.
Code: Lua
-- lua/ulx/modules/sh/my_command.lua
function
ulx
.
rcvNotify
(
message
)
notification
.
AddLegacy
(
message
,
NOTIFY_GENERIC
,
3
)
surface
.
PlaySound
(
"buttons/button14.wav"
)
end
function
ulx
.
notify
(
calling_ply
,
target_plys
,
message
)
ULib
.
clientRPC
(
target_plys
,
"ulx.rcvNotify"
,
message
)
ulx
.
fancyLogAdmin
(
calling_ply
,
"#A sent a notification to #P"
,
target_plys
)
end
local
notify
=
ulx
.
command
(
"Example"
,
"ulx notify"
,
ulx
.
notify
,
"!notify"
)
notify
:
addParam
{
type
=
ULib
.
cmds
.
PlayersArg
}
notify
:
addParam
{
type
=
ULib
.
cmds
.
StringArg
,
hint
=
"message"
,
ULib
.
cmds
.
takeRestOfLine
}
notify
:
defaultAccess
(
ULib
.
ACCESS_ADMIN
)
notify
:
help
(
"Send notification to target(s)."
)
Logged
Print
Pages: [
1
]
Go Up
« previous next »
Ulysses
»
General
»
Developers Corner
»
Running clientside code on ULX