Difference between revisions of "Manual:DIL Manual/acc modify()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
 
(checked against the compiler and the interpreter; example compiles)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 +
= acc_modify() =
 +
'''Procedure.''' Pays money into a player's account or takes it out.
  
 +
acc_modify(pc : unitptr, amount : integer)
  
−
<span id="bpacc_mod"></span>
+
Only does something when the game runs with accounting (<code>accounting = 1</code> in server.cfg; it is off by default). A positive <code>amount</code> is paid in: the balance ([[Manual:DIL Manual/acc balance|acc_balance]]) and the total paid in ([[Manual:DIL Manual/acc total|acc_total]]) go up. A negative one is taken out: both go down, the total no further than 0. Amounts are in cents: 100 is one unit of money.
−
acc_modify( u : unitptr, i : integer )
 
−
    u : A player
 
−
    i : An amount in 1/100s, for example 100 would equal $1.00, and
 
−
        -100 would equal -$1.00.
 
  
−
      Access only allowed with 'root' access and all transactions are
+
Every change is written to vme.log ("... inserted 100 on account ...") and to the account log, <code>account.log</code> in the log directory, under the name of the unit running the program.
−
    registered in the specially encrypted account log file. Use with
+
 
−
    great caution, and always test thoroughly before using.
+
Only a program started in a zone with access level 0 (the fourth column of <code>vme/etc/zonelist</code>) can use it. What counts is the zone of the program's first template, the one that was <code>dilcopy</code>'d or run as a command. Elsewhere the zone log gets "attempt to violate system access security (amod)" and the program stops.
−
    Use without prior permission may cause deletion of god / zone.
+
 
 +
== Parameters ==
 +
{| class="wikitable"
 +
! Name !! Type !! Meaning
 +
|-
 +
| pc || unitptr || The player.
 +
|-
 +
| amount || integer || Cents to pay in (positive) or take out (negative).
 +
|}
 +
 
 +
== Notes ==
 +
* Nothing happens with accounting off, for a unit that isn't a player, or for null; in those cases there is no access check either. An amount of 0 changes nothing.
 +
* Nothing in the game uses it today.
 +
 
 +
== Example ==
 +
<pre>
 +
dilbegin give_credit(pc : unitptr, cents : integer);
 +
code
 +
{
 +
  if (pc.type != UNIT_ST_PC)
 +
      return;
 +
  acc_modify(pc, cents);
 +
  sendtext("Your account now holds " + itoa(pc.acc_balance) + " cents.<br/>", pc);
 +
}
 +
dilend
 +
</pre>
 +
Pays an amount into a player's account and tells the player the new balance.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/acc balance|acc_balance]]
 +
* [[Manual:DIL Manual/acc total|acc_total]]
 +
* [[Manual:DIL Manual/access|access]]

Latest revision as of 23:17, 14 November 2026

acc_modify()

Procedure. Pays money into a player's account or takes it out.

acc_modify(pc : unitptr, amount : integer)

Only does something when the game runs with accounting (accounting = 1 in server.cfg; it is off by default). A positive amount is paid in: the balance (acc_balance) and the total paid in (acc_total) go up. A negative one is taken out: both go down, the total no further than 0. Amounts are in cents: 100 is one unit of money.

Every change is written to vme.log ("... inserted 100 on account ...") and to the account log, account.log in the log directory, under the name of the unit running the program.

Only a program started in a zone with access level 0 (the fourth column of vme/etc/zonelist) can use it. What counts is the zone of the program's first template, the one that was dilcopy'd or run as a command. Elsewhere the zone log gets "attempt to violate system access security (amod)" and the program stops.

Parameters

Name Type Meaning
pc unitptr The player.
amount integer Cents to pay in (positive) or take out (negative).

Notes

  • Nothing happens with accounting off, for a unit that isn't a player, or for null; in those cases there is no access check either. An amount of 0 changes nothing.
  • Nothing in the game uses it today.

Example

dilbegin give_credit(pc : unitptr, cents : integer);
code
{
   if (pc.type != UNIT_ST_PC)
      return;
   acc_modify(pc, cents);
   sendtext("Your account now holds " + itoa(pc.acc_balance) + " cents.<br/>", pc);
}
dilend

Pays an amount into a player's account and tells the player the new balance.

See also