So a while ago I found a script made by Pecon that fixes the onItemPickup add-on not working for T+T ammunition pickups, supposedly. The problem is that now I can only pick up T+T Ammo items and nothing else. Weirdly though, if I event a brick to set it's item to NONE after picking up a weapon, it will successfully set the item to NONE when I walk through the item, but it doesn't give me the item. Unfortunately the topic the fix was posted in now too old, so I'm making a thread for everyone to comment in.
Here is the code:
registerInputEvent(fxDTSBrick,onItemPickup,"Self fxDTSBrick" TAB "Player Player" TAB "Client GameConnection" TAB "MiniGame Minigame");
package AAitemPickup
{
function Player::pickup(%this,%item)
{
if(%this.skipPickup)
{
%this.skipPickup = false;
return 0;
}
%brick = %item.spawnBrick;
%val = Parent::pickup(%this,%item);
if(%val == 1 && isObject(%brick) && %this.getClassName() $= "Player" && isObject(%this.client))
{
%client = %this.client;
$InputTarget_["Self"] = %brick;
$InputTarget_["Player"] = %client.player;
$InputTarget_["Client"] = %client;
if($Server::LAN)
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%client);
}
else
{
if(getMiniGameFromObject(%brick) == getMiniGameFromObject(%client))
$InputTarget_["MiniGame"] = getMiniGameFromObject(%brick);
else
$InputTarget_["MiniGame"] = 0;
}
%brick.processInputEvent(onItemPickup,%client);
}
return %val;
}
function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
{
if(%col.getType() & $typeMasks::ItemObjectType && minigameCstar fishe(%obj.client, %col) && %col.canPickup && %obj.getDamagePercent() < 1.0)
{
%brick = %col.spawnBrick;
if(isObject(%brick) && %obj.getClassName() $= "Player" && isObject(%obj.client))
{
%client = %obj.client;
$InputTarget_["Self"] = %brick;
$InputTarget_["Player"] = %client.player;
$InputTarget_["Client"] = %client;
if($Server::LAN)
{
$InputTarget_["MiniGame"] = getMiniGameFromObject(%client);
}
else
{
if(getMiniGameFromObject(%brick) == getMiniGameFromObject(%client))
$InputTarget_["MiniGame"] = getMiniGameFromObject(%brick);
else
$InputTarget_["MiniGame"] = 0;
}
%brick.processInputEvent(onItemPickup,%client);
%obj.skipPickup = 1;
}
}
return parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
}
};
activatePackage(AAitemPickup);
Here is the original onPickupItem code, which works for all my items except the ammo pickups:
http://pastebin.com/f5V7nhyG