Difference between revisions of "Manual:DIL Manual/paycheck()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bfpaychk"></span>
+
= paycheck() =
−
integer paycheck( u1 : unitptr, u2:unitptr)
+
'''Function''' (integer). Tells whether a player's account allows them into the zone of a unit.
−
    u1 : unit to check against
 
−
    u2 : player to check access for
 
−
    return: TRUE if the player u2 has pay access to the location
 
−
in which the unit u1 is located. FALSE if the player does not
 
−
have access. Using non-players as u2 will return TRUE. The
 
−
function checks if the player has pay-access (if needed) to
 
−
the zone in which u1 is located.
 
  
−
  ---~---~---~---~---~---~---~---~---
+
  paycheck(pc : unitptr, place : unitptr)
−
<span id="bfpaychk"></span>
 
−
integer paycheck( u1 : unitptr, u2:unitptr)
 
−
    u1 : unit to check against
 
−
    u2 : player to check access for
 
−
    return: TRUE if the player u2 has pay access to the location
 
−
in which the unit u1 is located. FALSE if the player does not
 
−
have access. Using non-players as u2 will return TRUE. The
 
−
function checks if the player has pay-access (if needed) to
 
−
the zone in which u1 is located.
 
  
−
---~---~---~---~---~---~---~---~---
+
For servers that charge for play (accounting on in <code>server.cfg</code>). A zone can be
 +
marked pay-only with its [[Manual:DIL Manual/payonly|payonly]] value; this checks that value for
 +
the zone <code>place</code> belongs to against the player's account. Use it before moving a
 +
player somewhere, as the movement code in skills.zon does with the room an exit leads to.
 +
 
 +
== Parameters ==
 +
{| class="wikitable"
 +
! Name !! Type !! Meaning
 +
|-
 +
| pc || unitptr || The character to check. Must be a character.
 +
|-
 +
| place || unitptr || A unit of the zone to check, usually the room the player is going to.
 +
|}
 +
 
 +
== Returns ==
 +
Integer: <code>TRUE</code> when the player may go there, <code>FALSE</code> when not. When it
 +
says no, the player has already been sent the server's pay message.
 +
 
 +
<code>TRUE</code> always when accounting is off (most servers), and for non-players, gods,
 +
players connected from the local network and zones that aren't pay-only. A zone's
 +
<code>payonly</code> 1 needs credit on the account, 2 a flat rate that hasn't run out, and 3 is
 +
for players who have neither.
 +
 
 +
It fails when <code>pc</code> is null or not a character, or <code>place</code> is null; with
 +
accounting off it gives <code>TRUE</code> without looking at the arguments.
 +
 
 +
== Notes ==
 +
* The player comes first. The old manual had the arguments the other way round.
 +
* The zone is the one <code>place</code> was defined in, not the zone it is in now: pass a
 +
  room, not an object or a character who may have walked elsewhere.
 +
 
 +
== Example ==
 +
<pre>
 +
dilbegin go_to(pc : unitptr, room : unitptr);
 +
code
 +
{
 +
  if (not paycheck(pc, room))
 +
  {
 +
      act("You don't have access to that location.", A_ALWAYS, pc, null, null, TO_CHAR);
 +
      quit;
 +
  }
 +
  link(pc, room);
 +
  quit;
 +
}
 +
dilend
 +
</pre>
 +
Moves a player to a room only if their account allows it, as the movement code in skills.zon
 +
does.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/payonly|payonly]]
 +
* [[Manual:DIL Manual/acc balance|acc_balance]]
 +
* [[Manual:DIL Manual/acc modify()|acc_modify()]]
 +
* [[Manual:DIL Manual/link()|link()]]

Latest revision as of 23:20, 14 November 2026

paycheck()

Function (integer). Tells whether a player's account allows them into the zone of a unit.

paycheck(pc : unitptr, place : unitptr)

For servers that charge for play (accounting on in server.cfg). A zone can be marked pay-only with its payonly value; this checks that value for the zone place belongs to against the player's account. Use it before moving a player somewhere, as the movement code in skills.zon does with the room an exit leads to.

Parameters

Name Type Meaning
pc unitptr The character to check. Must be a character.
place unitptr A unit of the zone to check, usually the room the player is going to.

Returns

Integer: TRUE when the player may go there, FALSE when not. When it says no, the player has already been sent the server's pay message.

TRUE always when accounting is off (most servers), and for non-players, gods, players connected from the local network and zones that aren't pay-only. A zone's payonly 1 needs credit on the account, 2 a flat rate that hasn't run out, and 3 is for players who have neither.

It fails when pc is null or not a character, or place is null; with accounting off it gives TRUE without looking at the arguments.

Notes

  • The player comes first. The old manual had the arguments the other way round.
  • The zone is the one place was defined in, not the zone it is in now: pass a
 room, not an object or a character who may have walked elsewhere.

Example

dilbegin go_to(pc : unitptr, room : unitptr);
code
{
   if (not paycheck(pc, room))
   {
      act("You don't have access to that location.", A_ALWAYS, pc, null, null, TO_CHAR);
      quit;
   }
   link(pc, room);
   quit;
}
dilend

Moves a player to a room only if their account allows it, as the movement code in skills.zon does.

See also