Author Topic: BanHammer v2  (Read 2517 times)

I'm working on the second version of the banhammer, which should have 3 modes: destructo, kick, and ban. However, no matter what mode it's in, it will never kill bricks and always tries to ban and then kick players. Here's the script. There are other scripts which set up the prefs, so I know it's not that the prefs aren't being registered. They are executing before this too, in fact, this is the last script to execute.
Also, the centerprint stuff isn't working. Not as big as an issue and I'm going to take care of that myself later.
Code: [Select]
function serverCmdbhmode(%client, %arg) //Server command "/bhmode modename"
{
   switch$(%arg) //For argument is "" perform action
   {
      case "": %client.centerPrint('5', '<color:ff0000>You need to enter a mode (destructo, kick, ban).', '');
      case "destructo":$Pref::BanHammer::Mode = 0;
      case "destroy":$Pref::BanHammer::Mode = 0; //I thought a lot of people would just type "destroy"
      case "kick":$Pref::BanHammer::Mode = 1;
      case "ban":$Pref::BanHammer::Mode = 2;
   }
}

function serverCmdbanhammer(%client) //Command /banhammer
{
%client.player.mountImage("BanHammerImage",0); //Gives them a banhammer. They will be checked for admin next.
}

function BanHammerImage::OnMount(%this, %obj) //When you switch to the hammer
{
    %client = %obj.client; //This lets me reference the mounter's client more easily
    if($Pref::BanHammer::SuperAdminOnly && !%client.isSuperAdmin) //If super admin only and client is not super admin..
    {
  %client.player.unMountImage("BanHammerImage"); //Unmount the hammer,
%client.centerPrint('5', '<color:ff0000>This tool is for super admins only.', ''); //And tell them why
    }
    else if(!%client.isAdmin) //Otherwise, check if they aren't an admin
    {
%client.player.unMountImage("BanHammerImage"); //If they aren't, unmount
%client.centerPrint('5', '<color:ff0000>This tool is for admins only.', ''); //Tell them it's admin only.
    }
    else //Neither of the above happened, so take no action.
Parent::OnMount(%this, %obj);
}

function BanHammerProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal) //When the projectile hits something.
{
   if($Pref::BanHammer::Mode = 0 && %col.getClassName() $="fxDTSBrick") //If it's a brick and you're in destructo mode...
   {
      %col.killBrick(); //Destroy it.
   }
   else if($Pref::BanHammer::Mode = 0 && %col.getClassName() $="WheeledVehicle" || %col.getClassName() $="AIplayer") //If it's a vehicle or a bot, and you're in destructo mode..
   {
      %col.kill(); //Destroy it.
   }
   else if($Pref::BanHammer::Mode = 1 && %col.getClassName() $="Player") //If it's a player and you're in kick mode
   {
      %client = %col.Client;
      %victimClientID = %client.getID();
      servercmdkick(%obj.client,%client,%victimBLID);
   }
   else if($Pref::BanHammer::Mode = 2 && %col.getClassName() $="Player") //If it's a player and you're in ban mode...
   {
      %client = %col.Client; //Again, easier reference of client
      %BLID = %client.BL_ID; //Get their Blockland ID, needed to ban
      %BanLength = $Pref::BanHammer::BanLength; //Use the ban length preference for the ban length
      %reason = $Pref::BanHammer::Reason; //Use the reason pref for the ban reason

      servercmdban(%obj.client,%client,%BLID,%BanLength,%reason); //Ban them, using the above variables
   }
}

Use == for the comparison checks.

if($Pref::BanHammer::Mode = 0 && %col.getClassName() $="fxDTSBrick") will set $Pref::BanHammer::Mode to zero, then check if (0) is greater than zero - which it isn't. It then moves onto the next check, where it sets $Pref::BanHammer::Mode to 1 and checks if it's greater than zero - which it is, so it tries to kick the player.

$Pref:: variables will apply to anyone in the server, so if someone keeps spamming /bhmode destructo then the tool will be stuck in that mode and therefore unable to kick or ban using it. Same for the ban reasons - no matter what you set, if someone else gets there first and uses the menus/commands/whatever to set it, that's what it will be for you.

I suggest that you make it always kill bricks when it hits them, kill the spawn bricks of bots/vehicles and then you set the kick/ban modes after that.

For the centerprints, the syntax would be:
%client.centerPrint("Message in double quotes",5);
for the message to display for five seconds.

You should make it so when you say kick or ban simply into the chat (not using "/" commands) it changes the mode of the hammer.

Also for centerPrint...
centerPrint(%client, "message", 5);

I rarely see the starting with %client...

I suggest using %client.centerPrint("Message in double quotes",5);

Thanks, I'll update the script and work on the other things to get it released.