This is what I use for keybinds. It looks huge but it's good for adding keybinds to existing categories.
function SlayerClient_Support::addKeyBind(%div,%name,%cmd,%device,%action,%overWrite)
{
%divIndex = -1;
for(%i = 0; %i < $RemapCount; %i ++)
{
if($RemapDivision[%i] $= %div)
{
for(%e = %i; %e < $RemapCount; %e ++)
{
if($RemapDivision[%e] !$= $RemapDivision[%i] && $RemapDivision[%e] !$= "")
{
break;
}
if($RemapName[%e] $= %name)
{
warn("Blocking duplicate keybind:" SPC %div TAB %name);
return;
}
}
%divIndex = %i;
break;
}
}
if(%divIndex >= 0)
{
for(%i=$RemapCount-1; %i > %divIndex; %i--)
{
$RemapDivision[%i+1] = $RemapDivision[%i];
$RemapName[%i+1] = $RemapName[%i];
$RemapCmd[%i+1] = $RemapCmd[%i];
}
$RemapDivision[%divIndex+1] = "";
$RemapName[%divIndex+1] = %name;
$RemapCmd[%divIndex+1] = %cmd;
$RemapCount ++;
}
else
{
$RemapDivision[$RemapCount] = %div;
$RemapName[$RemapCount] = %name;
$RemapCmd[$RemapCount] = %cmd;
$RemapCount ++;
}
if(%device !$= "" && %action !$= "")
{
if(moveMap.getCommand(%device,%action) $= "" || %overWrite)
moveMap.bind(%device,%action,%cmd);
}
}