General > Developers Corner

How to make a toggle in ULX

(1/2) > >>

imSEnsE:
Hey! I have been working on this add-on, so if i pick up a player with my physgun i can freeze them.. I'm done with that.. But I want to make a ULX command to toggle it.

But I am kinda stuck. How do i do this?

JamminR:
Though we're more than happy to help people code, you do realize some of the ability you speak of is included in ULX, correct?
https://github.com/TeamUlysses/ulx/blob/ecd205e771bdbe7be6a09dea7567ac33eca1fc12/lua/ulx/modules/sh/util.lua#L455
Admins and Players with "ulx physgunplayer" can use physgun other players and freeze them (if IsSandbox according to our checks)

Now, on to your own project.
Where exactly are you getting stuck?

What exactly are you trying to toggle?
Are you trying to toggle the ability of the physgun to freeze a player or not?
Or are you trying to toggle the person(s) freeze state after they've been frozen?

imSEnsE:
I have made the add-on, but i just have an new update idea which i am little confused on... I wan't to make a command that toggles the add-on, that i've made.

JamminR:
https://github.com/TeamUlysses/ulx/blob/ecd205e771bdbe7be6a09dea7567ac33eca1fc12/lua/ulx/modules/sh/util.lua#L171
Good example of a toggle. For us, it allows noclip for a player, or disables.
In the example code, it passes a single player, or multiple, in a table #target_plys.
PlayersArg

You could do single only with PlayerArg.

imSEnsE:
I see how this might work. In the moment of typing this I am opening Garry's Mod.

Navigation

[0] Message Index

[#] Next page

Go to full version