Author Topic: How does $weaponAmmoLoaded go into the dropped item in Support_AmmoGuns?  (Read 603 times)

Code: [Select]
function servercmdDropTool(%client,%slot)
{
if(!isObject(%client.player))
return Parent::servercmdDropTool(%client,%slot);

if(!isObject(%client.player.tool[%slot]) || %client.player.tool[%slot].maxAmmo <= 0)
return Parent::servercmdDropTool(%client,%slot);

$weaponAmmoLoaded = %client.player.toolAmmo[%client.player.currTool];
%client.player.toolAmmunition[%client.player.currTool] = "";
return Parent::servercmdDropTool(%client,%slot);
}

I'm sorry for being stupid but how exactly is $weaponAmmoLoaded being imported into the dropped item? Is it automatically done if theres no, well, for lack of a better word and for existence of high levels of ignorance, 'prefix'?

Code: [Select]
package AmmoGuns2
{
...

function ItemData::onAdd(%this,%obj)
{
if($weaponAmmoLoaded !$= "")
{
%obj.weaponAmmoLoaded = $weaponAmmoLoaded;
$weaponAmmoLoaded = "";
}
Parent::onAdd(%this,%obj);
}

...
};
It's a storage because I don't want to break mods that affect how servercmdDropTool works. When you drop an item its current ammo is stored in the global variable, then the next item that is created has a local variable set on it and the global one cleared.

How could I have missed that!?
Jesus, I am thick.


Anyway, thanks and thanks for the explanation.
« Last Edit: September 01, 2010, 03:57:33 PM by The Titanium »