Difference between revisions of "Manual:DIL Manual/isplayer()"
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: | ||
| + | = 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 (<code>plydir</code> in <code>server.cfg</code>), so a player made a moment ago counts once the character has been saved. |
| − | + | == Parameters == | |
| + | {| class="wikitable" | ||
| + | ! 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 [[Manual:DIL Manual/pc head()|pc_head()]]). | |
| − | + | * Give it a plain name. Text a player typed should be checked first: it is used to build a file name. | |
| − | |||
| − | |||
| − | |||
| − | + | == Example == | |
| − | + | <pre> | |
| − | + | 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 | ||
| + | </pre> | ||
| + | A command that tells whether a name belongs to a player, as the postman in mail.zon checks an address. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/findunit()|findunit()]] | |
| − | + | * [[Manual:DIL Manual/pc head()|pc head()]] | |
| − | + | * [[Manual:DIL Manual/delete player()|delete player()]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 23:17, 14 November 2026
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.