Author Topic: Randomizer Script w/ blacklist  (Read 1404 times)

Yes I know there's an event, but I want something where I can also blacklist certain things, like tools. Maybe a whole other addon that's not an event with the blacklist included.



Are you really bumping this every half a hour?

Are you really bumping this every half a hour?
I shouldn't have to
But I know I'm being impatient, this does need to happen though.
« Last Edit: May 26, 2014, 05:13:49 PM by gr8dayseth »

this did happen
Code: [Select]
registerOutputEvent(Player, "addRandomItemBlacklisted", "");
$Pref::Server::AddRandomItemBlacklist = "Hammer  " TAB "Wrench" TAB "Printer" TAB "Duplorcator" TAB "Fill Can" TAB "Fill Printer" TAB "Fist" TAB "Self Delete Gun" TAB "Gun" TAB "Sword" TAB "Key Red" TAB "Key Blue" TAB "Key Yellow" TAB "Key Green" TAB "Pill" TAB "Wand" TAB "WaterFX Can" TAB "Rocket Launcher";

function checkIfToolBlacklisted(%uiname)
{
for( %i = 0 ; %i < getFieldCount( %bl = $Pref::Server::AddRandomItemBlacklist ) ; %i++ )
if( %uiName $= getField( %bl , %i ) ) { return 0; }

return 1;
}

function Player::addRandomItemBlacklisted(%player,%client)
{
   for(%i = 0; %i < DataBlockGroup.getCount(); %i++)
   {
      %obj = DataBlockGroup.getObject(%i);
      if(%obj.getClassName() $= "ItemData" && (%uiname = %obj.uiName) !$= "" && checkIfToolBlacklisted(%uiname)) //parser rape
         %item[%itemCount++] = %obj;
   }
   %randomitem = getRandom(0,%itemCount);
   if(%player.tool[0] $= %item[%randomitem] || %player.tool[1] $= %item[%randomitem] || %player.tool[2] $= %item[%randomitem] || %player.tool[3] $= %item[%randomitem] || %player.tool[4] $= %item[%randomitem])
   {
      return;
   }
   for(%i=0;%i<5;%i++)
   {
      %tool = %player.tool[%i];
      if(%tool == 0)
      {
         %player.tool[%i] = %item[%randomitem];
         %player.weaponCount++;
         messageClient(%client,'MsgItemPickup','',%i,%item[%randomitem]);
         break;
      }
   }
}
« Last Edit: May 26, 2014, 08:20:35 PM by Axo-Tak »

this did happen
Oh sweet
Sorry for asking the same question that lots of people ask (but I can't find the answer to), but how do you package addons again?
nvm I found out

Thanks again
« Last Edit: May 26, 2014, 07:33:07 PM by gr8dayseth »

For some reason the hammer still comes from it even though it's blacklisted

For some reason the hammer still comes from it even though it's blacklisted
oh yeah because the stupid UIName of the hammer is screwed up...

oh yeah because the stupid UIName of the hammer is screwed up...
Actually I think it was because it was first on the list for whatever reason, I put hammer in there again and replaced the first one with NONE, and it fixed it, but there's a better chance of no item.
Nope, I was just really lucky I didn't get it when I was testing it.
Oh well, I'll live.
« Last Edit: May 26, 2014, 08:47:55 PM by gr8dayseth »

this did happen
Why not just add a string to the event and have that be the blacklist?
Actually I think it was because it was first on the list for whatever reason, I put hammer in there again and replaced the first one with NONE, and it fixed it, but there's a better chance of no item.
Nope, I was just really lucky I didn't get it when I was testing it.
Oh well, I'll live.
Just change
$Pref::Server::AddRandomItemBlacklist = "Hammer  " TAB "Wrench" TAB "Printer" TAB "Duplorcator" TAB "Fill Can" TAB "Fill Printer" TAB "Fist" TAB "Self Delete Gun" TAB "Gun" TAB "Sword" TAB "Key Red" TAB "Key Blue" TAB "Key Yellow" TAB "Key Green" TAB "Pill" TAB "Wand" TAB "WaterFX Can" TAB "Rocket Launcher";
to
$Pref::Server::AddRandomItemBlacklist = "Hammer " TAB "Wrench" TAB "Printer" TAB "Duplorcator" TAB "Fill Can" TAB "Fill Printer" TAB "Fist" TAB "Self Delete Gun" TAB "Gun" TAB "Sword" TAB "Key Red" TAB "Key Blue" TAB "Key Yellow" TAB "Key Green" TAB "Pill" TAB "Wand" TAB "WaterFX Can" TAB "Rocket Launcher";

The two spaces after "Hammer" was the problem.

There was one too many spaces after "Hammer". Nice going Badspot, the Hammer's UI name is "Hammer " -_-
« Last Edit: May 27, 2014, 06:58:47 PM by jes00 »

Nice going Badspot, the Hammer's UI name is "Hammer " -_-
There's probably a reason for that.

There was one too many spaces after "Hammer". Nice going Badspot, the Hammer's UI name is "Hammer " -_-
Ah ok, thanks, that worked.
And for future reference, "Rocket Launcher" is actually "Rocket L.", I already knew this, that's why I didn't mention it earlier.

Thanks guys, locking.