void sandbox_ObjectFunction_Think(entity this)
{
// decide if and how this object can be grabbed
- if(autocvar_g_sandbox_readonly)
+ if(autocvar_g_sandbox_readonly || MUTATOR_CALLHOOK(Sandbox_DragAllowed, this))
this.grab = 0; // no grabbing
else if(autocvar_g_sandbox_editor_free < 2 && this.crypto_idfp)
this.grab = 1; // owner only
parent = e; // mark parent objects as such
}
// properties stored for all objects
- SANDBOX_GETARG; _setmodel(e, arg);
+ SANDBOX_GETARG; precache_model(arg); _setmodel(e, arg);
SANDBOX_GETARG; e.skin = stof(arg);
SANDBOX_GETARG; e.alpha = stof(arg);
SANDBOX_GETARG; e.colormod = stov(arg);
void sandbox_Database_Save()
{
+ if(MUTATOR_CALLHOOK(Sandbox_SaveAllowed))
+ return;
+
// saves all objects to the database file
string file_name;
float file_get;
{
if(autocvar_g_sandbox_info > 0)
LOG_INFO("^3SANDBOX - SERVER: ^7could not find storage file ^3", file_name, "^7, no objects were loaded");
+ return;
}
else
{
if(cmd_name == "g_sandbox")
{
- if(autocvar_g_sandbox_readonly)
+ if(autocvar_g_sandbox_readonly || MUTATOR_CALLHOOK(Sandbox_EditAllowed, player))
{
print_to(player, "^2SANDBOX - INFO: ^7Sandbox mode is active, but in read-only mode. Sandbox commands cannot be used");
return true;
}
e = sandbox_ObjectSpawn(player, false);
+ precache_model(argv(2));
_setmodel(e, argv(2));
if(autocvar_g_sandbox_info > 0)
/** player */ i(entity, MUTATOR_ARGV_0_entity) \
/**/
MUTATOR_HOOKABLE(W_PlayStrengthSound, EV_W_PlayStrengthSound);
+
+/** Return true to prevent sandbox objects from being dragged */
+#define EV_Sandbox_DragAllowed(i, o) \
+ /** object */ i(entity, MUTATOR_ARGV_0_entity) \
+ /**/
+MUTATOR_HOOKABLE(Sandbox_DragAllowed, EV_Sandbox_DragAllowed);
+
+/** Return true to prevent writing sandbox changes to storage */
+MUTATOR_HOOKABLE(Sandbox_SaveAllowed, EV_NO_ARGS);
+
+/** Return true to prevent the player from editing sandbox objects with commands */
+#define EV_Sandbox_EditAllowed(i, o) \
+ /** player */ i(entity, MUTATOR_ARGV_0_entity) \
+ /**/
+MUTATOR_HOOKABLE(Sandbox_EditAllowed, EV_Sandbox_EditAllowed);