assistance with a /save command
function ccSave(%sender, %args)
{
%group = nameToID("MissionCleanup/Deployables");
%count = %group.getCount();
for (%i=0;%i<%count;%i++) {
%obj = %group.getObject(%i);
if (%obj.getOwner() == %sender)
%title = getword(%args, 0);
%file = %sender.nameBase @ "/" @ %title;
}
SaveBuilding(%sender, %obj, %file, 1, 0);
messageAll('MsgAdminForce', "\c3"@%sender.nameBase@"\c2 is saving his buildings.");
messageClient(%sender, "", "\c2Building saved to "@$SaveBuilding::LastFile@".");
}
the issue is it saves everyones pieces, not just %sender 's
how do i fix this?
thanks

Comments
Essentially what you're trying to do, you would do with
new fileObject("Building"); Building.openForWrite(%file); %group = nameToID("MissionCleanup/Deployables"); %count = %group.getCount(); for (%i=0;%i<%count;%i++) { %obj = %group.getObject(%i); if (%obj.getOwner() == %cl) { %cmp = writeBuildingComponent(%obj); if (%cmp !$= "") Building.writeLine(%cmp); } } Building.close(); Building.delete();Also, don't put your title/filename selection in the loop, or it will set it every time untill it's finished.
Plus, only setting %title as %args if it finds a piece belonging to the sender with "if (%obj.getOwner() == %sender) %title = getword(%args, 0);" is a bit silly.
function ccSave(%sender, %args) { new fileObject("Building"); Building.openForWrite(%file); %group = nameToID("MissionCleanup/Deployables"); %count = %group.getCount(); for (%i=0;%i<%count;%i++) { %obj = %group.getObject(%i); if (%obj.getOwner() == %sender) { %cmp = writeBuildingComponent(%obj); if (%cmp !$= "") { Building.writeLine(%cmp); } } Building.close(); Building.delete(); %title = getword(%args); %file = %sender.nameBase @ "/" @ %title; } messageAll('MsgAdminForce', "\c3"@%sender.nameBase@"\c2 is saving his buildings."); messageClient(%sender, "", "\c2Building saved to "@$SaveBuilding::LastFile@"."); }and it doesnt save anything.
is it openforappend?
// By Eolk function ccSave(%sender, %args) { %title = getword(%args); %file = $SaveBuilding::SaveFolder @ "/" @ %sender.nameBase @ "/" @ %title; new fileObject("Building"); Building.openForWrite(%file); %group = nameToID("MissionCleanup/Deployables"); %count = %group.getCount(); for (%i=0;%i<%count;%i++) { %obj = %group.getObject(%i); if (%obj.getOwner() == %sender) { %cmp = writeBuildingComponent(%obj); if (%cmp !$= "") { Building.writeLine(%cmp); } } Building.close(); Building.delete(); } messageAll('MsgAdminForce', "\c3"@%sender.nameBase@"\c2 is saving his buildings."); messageClient(%sender, "", "\c2Building saved to "@$SaveBuilding::LastFile@"."); }if (%cmp !$= "") {to and it will work fine. Didn't notice that when I threw it up.function ccSave(%sender, %args) { %title = getword(%args); %file = $SaveBuilding::SaveFolder @ "/" @ %sender.nameBase @ "/" @ %title; new fileObject("Building"); Building.openForWrite(%file); %group = nameToID("MissionCleanup/Deployables"); %count = %group.getCount(); for (%i=0;%i<%count;%i++) { %obj = %group.getObject(%i); if (%obj.getOwner() == %sender) { %cmp = writeBuildingComponent(%obj); if (%cmp !$= "") Building.writeLine(%cmp); } Building.close(); Building.delete(); } messageAll('MsgAdminForce', "\c3"@%sender.nameBase@"\c2 is saving his buildings."); messageClient(%sender, "", "\c2Building saved to "@$SaveBuilding::LastFile@"."); }Still UE's, and saves nothing...
%title = getword(%args,0); %file = $SaveBuilding::SaveFolder @ %sender.nameBase @ "/" @ %title; new fileObject("Building"); Building.openForWrite(%file); %group = nameToID("MissionCleanup/Deployables"); %count = %group.getCount(); for (%i=0;%i<%count;%i++) { %obj = %group.getObject(%i); if (%obj.getOwner() == %sender) { %cmp = writeBuildingComponent(%obj); if (%cmp !$= "") Building.writeLine(%cmp); } } Building.close(); Building.delete(); messageAll('MsgAdminForce', "\c3"@%sender.nameBase@"\c2 is saving his buildings."); messageClient(%sender, "", "\c2Building saved to "@%file@".");Edit: Well, actually, I think that one was modified a bit by Blnukem, but yeah.