Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): add DOES_PLAYER_EXIST native
this should replace the need to use GetPlayerPing and other natives which rely on implementation details
- Loading branch information
1 parent
3800625
commit 443585a
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
ns: CFX | ||
apiset: server | ||
--- | ||
## DOES_PLAYER_EXIST | ||
|
||
```c | ||
BOOL DOES_PLAYER_EXIST(char* playerSrc); | ||
``` | ||
Returns whether or not the player exists | ||
## Return value | ||
True of the player exists, false otherwise | ||
This comment has been minimized.
Sorry, something went wrong. |
||
## Examples | ||
```lua | ||
local deferralMessages = { "Isn't this just magical!", "We can defer all day!", "You'll get in eventually", "You're totally not going to sit here forever", "The Fruit Tree is a lie" } | ||
AddEventHandler("playerConnecting", function(name, setKickReason, deferrals) | ||
local source = source | ||
deferrals.defer() | ||
Wait(0) | ||
local messageIndex = 0 | ||
repeat | ||
Wait(2000) | ||
if messageIndex >= #deferralMessages then | ||
deferrals.done() | ||
else | ||
messageIndex = messageIndex + 1 | ||
end | ||
deferrals.update(deferralMessages[messageIndex]) | ||
until not DoesPlayerExist(source) | ||
end) | ||
``` |
Typo. Should be "if".