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

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

You've all been calling ::OnPlant but i've changed that in my code.

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

Gives me a buffer overun, tried moving the parent about.
« Last Edit: October 09, 2007, 12:54:17 PM by MrPickle »

You cannot delete an object from within its own onAdd method.

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

     if(%client.isAdmin || %client.isSuperAdmin)
     {
          $SWATSpawn = %obj.getTransform();
          Parent::OnAdd(%this,%obj);
     }
     else
     {
          schedule(50,0,"deleteSWATspawn",%obj);
     }
}

function deleteSWATspawn(%obj)
{
     %obj.delete();
}

Ok, it's stopped crashing but %client isn't being recognized, it's echoing as nothing.

Code: [Select]
function SWATSpawnPointData::onAdd(%brick,%obj){
%client = %obj.getGroup().client;
echo(%client);
  if(%client.isAdmin || %client.isSuperAdmin){
      $SWATSpawn = %brick.getTransform();
Parent::OnAdd(%this,%obj);
   } else {
     schedule(100,0,"deleteSpawn",%obj);
}
}

function deleteSpawn(%obj){
%obj.delete();
}

Try it like this:

Code: [Select]
function SWATSpawnPointData::onAdd(%this,%obj)
{
     Parent::OnAdd(%this,%obj);
     schedule(50,0,"checkSwatSpawn",%obj);
}

function checkSwatSpawn(%obj)
{
     %client = %obj.getGroup().client;

     if(%client.isAdmin || %client.isSuperAdmin)
     {
          $SWATSpawn = %obj.getTransform();
     }
     else
     {
          %obj.delete();
     }
}

Works thanks but it's saying in console "unkown command getTransform" but it's still getting the position n all that stuff?

It's calling getTransform on the "swirlPaintDropletParticle" and "SWATSpawnPointData" datablocks?
« Last Edit: October 09, 2007, 02:25:49 PM by MrPickle »

Yeah, you have to pass it a valid in-game object, not a datablock.

Please use exactly my code and try again.  It really should be in the format of %this, %obj.

I am using your exact code.

Try using this:

Code: [Select]
function SWATSpawnPointData::onAdd(%a,%b,%c,%d,%e,%f)
{
     echo(%a SPC %b SPC %c SPC %d SPC %e SPC %f);
     Parent::OnAdd(%this,%obj);
     schedule(50,0,"checkSwatSpawn",%b);
}

If there are any other arguments being passed, revise the onAdd method to include them.  Also, trying performing a .dump() on each argument to see what exactly it is.  .getTransform() can only be performed on valid objects.

Try using this:

Code: [Select]
function SWATSpawnPointData::onAdd(%a,%b,%c,%d,%e,%f)
{
     echo(%a SPC %b SPC %c SPC %d SPC %e SPC %f);
     Parent::OnAdd(%this,%obj);
     schedule(50,0,"checkSwatSpawn",%b);
}

If there are any other arguments being passed, revise the onAdd method to include them.  Also, trying performing a .dump() on each argument to see what exactly it is.  .getTransform() can only be performed on valid objects.

Doesn't matter, appears to of fixed itself.

 :cookieMonster:

Good.  I was pretty sure my code was correct.