Manual:DIL Manual/isplayer()
Jump to navigation
Jump to search
isplayer()
Function (integer). Tells whether a player character of that name exists.
isplayer(pname : string) : integer
Checks whether a saved player of that name exists, whether the player is in the game or not. Case doesn't matter. It looks for the player's file in the player directory (plydir in server.cfg), so a player made a moment ago counts once the character has been saved.
Parameters
| Name | Type | Meaning |
|---|---|---|
| pname | string | The player's name. |
Returns
TRUE when the player exists, FALSE when not. An empty string gives FALSE (and the line "Empty string in find_player_id." in the log). A string variable that has never been given a value makes the call fail.
Notes
- It says nothing about whether the player is online; for that, look for the player in the game (see pc_head()).
- Give it a plain name. Text a player typed should be checked first: it is used to build a file name.
Example
dilbegin do_whois(arg : string);
var
pname : string;
code
{
pname := getword(arg);
if (pname == "")
{
sendtext("Whose name?<br/>", self);
quit;
}
if (not isplayer(pname))
sendtext("There is no player called " + pname + ".<br/>", self);
else
sendtext(pname + " is a player of this realm.<br/>", self);
quit;
}
dilend
A command that tells whether a name belongs to a player, as the postman in mail.zon checks an address.