Author Topic: Making it so that only admins can see and item.  (Read 2138 times)

Would it be possible to make it so that only admins can see certain items in the wrench gui?

I'm using a certain brick instead to make it easyer so I tryed to use onPlant but it dosen't set the client till after the brick's planted so what can I use?
« Last Edit: October 08, 2007, 12:10:39 PM by MrPickle »

Do a barrel roll, then everything will be clear.

onAdd is when the brick is created, such as when you shoot the floor with the Placer.

Loaded bricks won't have a client set, so be careful to add conditions for that or loads with these bricks will fail.

Do a barrel roll, then everything will be clear.

I done one but nothing be came clearer.

onAdd is when the brick is created, such as when you shoot the floor with the Placer.

Loaded bricks won't have a client set, so be careful to add conditions for that or loads with these bricks will fail.

I tried onAdd but it's not working.

Code: [Select]
function SWATSpawnPointData::onAdd(%brick)
{
%client = %brick.client;
if(%client.isAdmin || %client.isSuperAdmin){
$SWATSpawn = %brick.getTransform();
 Parent::onPlant(%this,%brick);
} else {
%brick.killBrick();
}
}

Code: [Select]
function SWATSpawnPointData::onAdd(%brick,%obj)
{
   %client = %obj.brickGroup.client;
   if(%client.isAdmin || %client.isSuperAdmin)
   {
      $SWATSpawn = %brick.getTransform();
      Parent::onPlant(%this,%brick);
   }
   else
   {
      %brick.delete();
   }
}

Thanks, I also forgot to change the parent D=.

Crashs blockland.
« Last Edit: October 08, 2007, 12:44:34 PM by MrPickle »


The source of the crashing is:

%client = %obj.brickGroup.client;

According to echos %obj.brickGroup or %obj.brickGroup.client dosen't exist.
« Last Edit: October 09, 2007, 11:37:09 AM by MrPickle »

Use this:

Code: [Select]
%client = %obj.getGroup().client;


function SWATSpawnPointData::onAdd(%brick,%obj)
{
   %client = %obj.brickGroup.client;
   if(%client.isAdmin || %client.isSuperAdmin)
   {
      $SWATSpawn = %brick.getTransform();
      Parent::onPlant(%this,%brick);
   }
   else
   {
      %obj.delete();
   }
}

%brick.delete(); deletes the brick datablock, not the object! No wonder it crashes...

Are you sure?

I thought it would be in the format of

Code: [Select]
function SWATspawnPointData::onAdd(%this,%obj)
{
     %client = %obj.getGroup().client;

     if(%client.isAdmin || %client.isSuperAdmin)
     {
          $SWATSpawn = %obj.getTransform();
          Parent::onPlant(%this,%obj);
     }
     else
     {
          %obj.delete();
     }
}

where %this is the datablock and %obj is the brick.
« Last Edit: October 09, 2007, 12:41:36 PM by Trader »

%brick is the datablock.

Why are you sending %this to the Parent when it isn't defined?