Manual:DIL Manual/delunit()
Jump to navigation
Jump to search
delunit()
Function (integer). Deletes a unit file.
delunit(filename : string)
Deletes a file written by store(). A file that restore() has loaded is still there, and would be loaded again; delete it once it has served, as death.zon does with corpse files and mail.zon with parcels.
Parameters
| Name | Type | Meaning |
|---|---|---|
| filename | string | The file's name, as given to store(): letters, digits, _ and . only, at most 512 characters.
|
Returns
integer. As the server is now, FALSE (0) when the file was deleted and TRUE (1) when it wasn't (no such file); the opposite of what the name suggests. FALSE as well for a name with other characters. Don't rely on the value: no zone does, and it may be corrected.
Notes
- The file is in the
unitsfolder of the zone's DIL file directory (the last column of the zone's line invme/etc/zonelist), or ofdil_file_dirinserver.cfgwhen the zone has none. - Only zones with access level 10 or less (the fourth column of
zonelist) may use it. In other zones the program stops and the zone log says "attempt to violate system access security (delunit)". - A name with other characters (a
/, a space) is refused with a line in the zone log. store()removes the file itself when there is nothing to save, so emptying a container and storing it again is enough.
Example
dilbegin fetch_parcel(pc : unitptr);
var
fn : string;
u : unitptr;
i : integer;
code
{
fn := tolower(pc.name) + ".parcel";
u := restore(fn, pc);
if (u == null)
{
sendtext("There is no parcel for you.<br/>", pc);
return;
}
i := delunit(fn); // so it can't be fetched twice
act("You receive $2n.", A_ALWAYS, pc, u, null, TO_CHAR);
return;
}
dilend
Gives a player the parcel stored for them (see store()) and deletes the file.