Blockland Forums > Modification Help
ReplaceItem ?
Deathwishez:
Damn. New problem.
This is under the same function that the first snippet was.
I'm now replacing all Frags with HE's on the trigger. All.
When the trigger is executed under the correct circumstances, I'm given an HE grenade, but the others in my inventory remain Frags.
Snippet:
--- Code: ---for(%i=0;%i<%player.getDatablock().maxTools;%i++)
{
%tool = IDToName(%player.tool[%i]);
if(%tool == HEGrenadeItem)
{
%newGun = nameToID("FragGrenadeItem");
%player.tool[%i] = %newGun;
messageClient(%killer,'MsgItemPickup','',%i, %newGun);
}
if(%tool == 0)
{
%newGun = nameToID("FragGrenadeItem");
%player.tool[%i] = %newGun;
%player.weaponCount++;
messageClient(%killer,'MsgItemPickup','',%i, %newGun);
break;
}
}
if(!%player.givenFrag)
{
%killer.medals += 1;
messageClient(%killer,"","\c3You have been awarded the\c4 Frag Grenade\c3 for outstanding skill!");
%player.givenFrag = true;
}
--- End code ---
I'm still trying a variation of things, but to no avail.
Please help.
lordician:
Your last post contains errors.
However, you DO know that Space Guy did about the same thing for his L4D survivor playertype?
rkynick:
--- Quote from: Deathwishez on February 03, 2011, 09:43:32 AM ---
--- Code: ---Damn. New problem.
This is under the same function that the first snippet was.
I'm now replacing all Frags with HE's on the trigger. All.
When the trigger is executed under the correct circumstances, I'm given an HE grenade, but the others in my inventory remain Frags.
Snippet:
[code]
for(%i=0;%i<%player.getDatablock().maxTools;%i++)
{
%tool = IDToName(%player.tool[%i]);
if(%tool == HEGrenadeItem)
{
%newGun = nameToID("FragGrenadeItem");
%player.tool[%i] = %newGun;
messageClient(%killer,'MsgItemPickup','',%i, %newGun);
}
if(%tool == 0)
{
%newGun = nameToID("FragGrenadeItem");
%player.tool[%i] = %newGun;
%player.weaponCount++;
messageClient(%killer,'MsgItemPickup','',%i, %newGun);
break;
}
}
if(!%player.givenFrag)
{
%killer.medals += 1;
messageClient(%killer,"","\c3You have been awarded the\c4 Frag Grenade\c3 for outstanding skill!");
%player.givenFrag = true;
}
--- End code ---
I'm still trying a variation of things, but to no avail.
Please help.
[/code]
--- End quote ---
Get rid of the "break;"
Deathwishez:
Didn't work.
Now every time I kill someone with a frag (after meeting the IF requirements it's in), a get an HE. Before it just happened once, and that was the purpose.
Bauklotz:
--- Code: ---function Player::pickup(%this, %item) {
if((%gun = %item.getID()) $= akimboGunItem.getID()) for(%i=0;%i<%this.getDatablock().maxtools;%i++) {
if(%this.tool[%i].getID() == GunItem.getID()) {
%this.tool[%i] = %gun;
messageClient(%this.client, 'MsgItemPickup', '', %i, %gun);
return;
}
}
Parent::pickup(%this, %item);
}
--- End code ---