Manual:DIL Manual/check password()
Jump to navigation
Jump to search
check_password()
Function (integer). Tells whether a password is a player's password.
check_password(pc : unitptr, pwd : string) : integer
Hashes pwd the way set_password() does and compares it with the player's stored password. It works from any zone.
Parameters
| Name | Type | Meaning |
|---|---|---|
| pc | unitptr | The player. |
| pwd | string | The password to try, in plain text. |
Returns
TRUE when it is the password, FALSE when it isn't. Only the first 8 characters count, of the stored password and of pwd. It fails, and the zone log says "Unit must be a pc to check password", when pc is an NPC, object or room.
Notes
- Test
pcfor null first: on a unit variable that holds null the server crashes. - Nothing in the game uses it today.
Example
dilbegin ask_password();
var
good : integer;
code
{
if (self.type != UNIT_ST_PC)
quit;
sendtext("Type your password to go on:<br/>", self);
wait(SFB_CMD, self == activator);
block;
good := check_password(self, excmdstr_case);
if (good)
sendtext("Password accepted.<br/>", self);
else
sendtext("Wrong password.<br/>", self);
quit;
}
dilend
Asks the player for the password and checks it. The answer is typed as a command, so block keeps the game from running it; excmdstr_case keeps its case, as the password command in commands.zon does.