Author Topic: Script_ClientKills  (Read 1134 times)

Is there some way that I can optimize this? I have a feeling there's something exremely simple right in front of me and I'm missing it.

Code: [Select]
// ==============================
// Support_ClientKills.cs (client-sided)
// ==============================
// Author: Flaw (BL_ID: 2107)
// Project: Scripting Utilities
// ==============================
// Evaluates a callback every time a kill message is sent to us.
// ==============================

if($isLoaded["Support_ClientKills"])
   return;

package clientKills {
   function clientCmdServerMessage(%callback, %msg, %a, %b, %c, %d, %e, %f, %g, %h, %i, %j, %k, %l, %m, %n) {
      parent::clientCmdServerMessage(%callback, %msg, %a, %b, %c, %d, %e, %f, %g, %h, %i, %j, %k, %l, %m, %n);
      if(isMurderMessage(%msg, 8))
         onMurderMessage(%a, trim(strReplace(strReplace(%msg, "%2", ""), "%1", "")), %b);
      else if(isSelf DeleteMessage(%msg, 8))
         onSelf DeleteMessage(trim(strReplace(%msg, "%2", "")), %b);
   }
};
activatePackage(clientKills);

function isMurderMessage(%message, %bitmapTolerance) {
   return (strPos(%message, "%1") > -1 && strPos(%message, "<bitmap:") > 2 && strPos(%message, ">") > 11 + %bitmapTolerance && strPos(%message, "%2") > 12 + %bitmapTolerance);
}
function isSelf DeleteMessage(%message, %bitmapTolerance) {
   return (strPos(%message, "<bitmap:") > -1 && strPos(%message, ">") > 8 + %bitmapTolerance && strPos(%message, "%2") > 9 + %bitmapTolerance);
}

function onMurderMessage(%killer, %type, %victim) {
}
function onSelf DeleteMessage(%type, %victim) {
}

$isLoaded["Support_ClientKills"] = true;

if %callback == 'MsgClientKilled'

FFFFFFFFFFFFUU-

but uh, that callback didn't show up in the list generated by this test:
Code: [Select]
$f = new fileObject();
$f.openForWrite("config/taggedStrings.txt");
$i = 0;
while(strLen($t = getTaggedString($i++)) > 0)
   $f.writeLine($t);
$f.close();
$f.delete();

FFFFFFFFFFFFUU-

but uh, that callback didn't show up in the list generated by this test:
Code: [Select]
$f = new fileObject();
$f.openForWrite("config/taggedStrings.txt");
$i = 0;
while(strLen($t = getTaggedString($i++)) > 0)
   $f.writeLine($t);
$f.close();
$f.delete();
Then it was never called.

Self Delete then try again.