Blockland Forums > Modification Help

How does $weaponAmmoLoaded go into the dropped item in Support_AmmoGuns?

Pages: (1/1)

The Titanium:


--- Code: ---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);
}
--- End code ---

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'?

Space Guy:


--- Code: ---package AmmoGuns2
{
...

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

...
};
--- End code ---
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.

The Titanium:

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


Anyway, thanks and thanks for the explanation.

Pages: (1/1)

Go to full version