Team Spartan Cookies & Milk Forums
Spawning from the shared area - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: Spawning from the shared area (/thread-1441.html)

Pages: 1 2


Spawning from the shared area - Person8880 - 08-11-2015

I've added a new feature for Starfall which lets you spawn a chip using code directly from the shared area (i.e. no uploading involved). To load a shared file onto your tool, right click it and choose "Load to Tool":
   

Then, pressing use and primary fire will spawn a chip/screen/HUD/emitter using the selected file as its mainfile, and all included files directly from the shared area.

Alongside this, is a new shared area permission type, execute permissions. Anyone granted execute permissions to a file can spawn them from the shared area, but cannot read the source code. Granting these permissions works the same way as the existing read/write.
   
Note that you only need to grant execute permissions for the main file of your code. Includes will be loaded regardless of whether the player has access to them or not.

Strict mode
Note however, that because players are unable to view the source code, code run from the shared area in this way runs in a more secure mode. In this mode, certain actions (such as spawning/removing entities and changing the owner's position) are locked behind user-granted permission rights. Note that chips spawned from the source code do not run in this mode, only those run from the shared area directly that you are not the author of.

Permission control
To grant/revoke these rights, there's a new tab under the shield button at the top right of the editor window.
   

In this tab, a list of current players and entities are available.
   
You can see a list of possible rights that can be granted to the entity/player. For the moment, only server-side permissions exist. In the future there may be client-side permissions too.

Granting rights
Granting rights under your player entry grants them for every chip you spawn. Granting for a specific chip grants it only to that entity. Rights granted to your player are saved, while those granted to entities are only valid for the entity's life, and are not connected to the code on it.

Requesting rights
If you are making a chip, then in order to be granted rights to perform actions, you must first register which rights you need. This is accomplished using the "permissions" library.
-- Register the need for the SPAWN_ENTITY permission.
permissions.register( permissions.SPAWN_ENTITY )
If you do not register access, you cannot be granted it, and the button to grant in the permissions control tab will be disabled.

To check if you have been granted access, do the following:
if permissions.canPerformAction( permissions.SPAWN_ENTITY ) then
-- Spawn props
end
If you attempt to perform an action without permission, then generally the action will silently fail. For example, attempting to spawn a prop without permission will just return nil. You should always check for permission to avoid confusion.


RE: Spawning from the shared area - TheOneAndOnlyTee - 08-11-2015

Nice, though I'd suggest a permission for channels usage to prevent people adding 'hidden' backdoors.


RE: Spawning from the shared area - Person8880 - 08-11-2015

(08-11-2015, 03:32 PM)T-17 Wrote: Nice, though I'd suggest a permission for channels usage to prevent people adding 'hidden' backdoors.
Backdoors can be added regardless of channels or not. You could happily include commands that run for the author that change everything without needing a channel.

The only things that need permissions are the actual actions these "backdoors" would perform. If you can think of anything that's potentially bad that's not spawning/removing entities or setting the player's position, then I can add rights for those.


RE: Spawning from the shared area - TheOneAndOnlyTee - 08-11-2015

True, at the moment I can only think of printColor() because of impersonation.
Most of the possible exploits i come up with require wirelinks to function but requiring permission for that is pointless given that's what almost all chips use.


RE: Spawning from the shared area - Person8880 - 08-11-2015

I'll just add an "<SF>" tag to the front of printColor output, rather than a permission.


RE: Spawning from the shared area - SuperPlayer - 08-11-2015

Cool new feature, gonna try that when i am on next. But one thing that should be blocked is the error() because you could crash a chip on purpose.


RE: Spawning from the shared area - Person8880 - 08-11-2015

I don't think the chip "crashing" because of the error function is really a bad thing. It's more about actions that are not easily reversible and can affect things outside the chip, rather than just randomly shutting the chip off.


RE: Spawning from the shared area - TheOneAndOnlyTee - 08-11-2015

well you couldn't crash another chip with it


RE: Spawning from the shared area - TheOneAndOnlyTee - 09-11-2015

Just had an idea, is it possible to add people to the white/black list via Steam ID?


RE: Spawning from the shared area - Person8880 - 09-11-2015

There's no way to do it through the UI at the moment. I'll add a way when I get the chance.