summaryrefslogtreecommitdiff
path: root/server/scripts/player_cache.md
blob: 416f38b298afa80116dc789c736b0bfb70502d19 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Player Cache System

The player cache keeps an in-memory copy of misc player data when they log in to the server to reduce the need to query the SQL database at runtime (which slightly adds lag). The player cache should be used whenever possible instead of writing queries.

Note: `WEAK` references are not guaranteed to always return the same result. The data returned depends on what is already present in the cache or on the last login time of the character.

## name2account

Returns the account id associated with a char name.

```c
"playerCache"::name2account("Reid")
```

## name2char

Returns the char id associated with a char name.

```c
"playerCache"::name2char("Reid")
```

## name2vault

Returns the Vault account id associated with a char name.

```c
"playerCache"::name2vault("Reid")
```

## char2account

Returns the account id associated with a char id.

```c
"playerCache"::char2account(.@charID)
```

## char2name

Returns the char name associated with a char id.

```c
"playerCache"::char2name(.@charID)
```

## char2vault

Returns the Vault account id associated with a char id.

```c
"playerCache"::char2vault(.@charID)
```

## account2char `[WEAK]`

Returns the char id associated with an account id.
**This is a weak reference**: an account id does not uniquely identify a character.

```c
"playerCache"::account2char(.@accountID)
```

## account2name `[WEAK]`

Returns the char name associated with an account id.
**This is a weak reference**: an account id does not uniquely identify a character.

```c
"playerCache"::account2name(.@accountID)
```

## account2vault

Returns the Vault account id associated with a game account id.

```c
"playerCache"::account2vault(.@accountID)
```

## vault2account `[WEAK]`

Returns the account id associated with a Vault account id.
**This is a weak reference**: a Vault account does not uniquely identify a game account.

```c
"playerCache"::vault2account(.@vaultID)
```

## vault2char `[WEAK]`

Returns the char id associated with a Vault account id.
**This is a weak reference**: a Vault account does not uniquely identify a game character.

```c
"playerCache"::vault2char(.@vaultID)
```

## vault2name `[WEAK]`

Returns the char name associated with a Vault account id.
**This is a weak reference**: a Vault account does not uniquely identify a game character.

```c
"playerCache"::vault2name(.@vaultID)
```