Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Actor PDA2 : CustomInventory 10226
{
//$Category Itens
Height 16
Radius 11
Inventory.PickupMessage "You got someone's PDA..."
Inventory.PickupSound "Beep1"
States
{
Spawn:
RPDA B -1
Stop
Pickup:
TNT1 A 0 ACS_Execute (982, 0, args[0])
//TNT1 A 0 ACS_Execute (args[0], 0, 0)
Stop
}
}
This is a CustonInventory that should allow me to trigger the script 982 and pass its args[0] when picked up. But seems to always execute the script with args[0]=0. If I swap the command for that commented line, it'll try to execute "Script 0". It is impossible to make it this way? If so, how'd you make this?
CustomInventory's Pickup and Use states, like a Weapon's Ready, Fire, etc. states, aren't ran by the item itself, but whatever's picking up / using it. So, args[0] will always return 0 unless you set the player's args[0] to something else, because they're the one running the state.
Your best bet is to use ZScript, so you can actually reference the invoker ( aka, the CustomInventory actor ) or so you can just run the script via one of item's virtual functions, which will let you get away with just Inventory. Alternatively, you could give it the INVENTORY.TRANSFER flag and have it give itself a number of dummy inventory items equal to its args[0] in its Spawn state, which will then be given to the player and then you can count 'em with [wiki]CountInv[/wiki] in place of args[0]. Though, if ZScript isn't an option, then it's likely that INVENTORY.TRANSFER isn't one, either, in which case your only real option is to have a unique PDA actor for every possible ACS_Execute call.
Based on that, I'm guessing you're setting the args in a map-placed thing. If so, there's no need to even use a CustomInventory actor. Just make it inherit from Inventory directly, and set ACS_Execute as the thing's special in GZDoom Builder - inventory items execute their specials when picked up.
Actually, if the whole point of an item is to run a script and then disappear, [wiki=Classes:FakeInventory]FakeInventory[/wiki] is the best option, it has been designed for precisely this purpose. (This is the class being used by old-style DECORATE pickups