Skip to content

Commit 89fd09c

Browse files
committed
Release 2.0.0
2 parents d75d17b + 107d754 commit 89fd09c

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Allows you to respawn the player
2323

2424
Respawn the `client`
2525

26+
Returns `true` on success and `false` if the player does not have a team or class
27+
2628
```sourcepawn
27-
native void RespawnPlayer(int client);
29+
native bool RespawnPlayer(int client);
2830
```

scripting/include/player-respawn/api.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
#endif
44
#define _player_respawn_api_included
55

6-
native void RespawnPlayer(int client);
6+
native bool RespawnPlayer(int client);

scripting/modules/native.sp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
static const int VOID = 0;
2-
31
void Native_Create() {
42
CreateNative("RespawnPlayer", Native_RespawnPlayer);
53
RegPluginLibrary("player-respawn");
@@ -8,7 +6,5 @@ void Native_Create() {
86
any Native_RespawnPlayer(Handle plugin, int numParams) {
97
int client = GetNativeCell(1);
108

11-
SdkHook_Respawn(client);
12-
13-
return VOID;
9+
return UseCase_RespawnSilently(client);
1410
}

scripting/modules/use-case.sp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
bool UseCase_Respawn(int client, int target) {
2-
bool noTeam = GetClientTeam(target) < TEAM_ALLIES;
3-
bool noClass = UseCase_GetDesiredPlayerClass(target) == NO_DESIRED_PLAYER_CLASS;
2+
if (UseCase_RespawnSilently(target)) {
3+
MessageLog_PlayerRespawned(client, target);
4+
5+
return true;
6+
}
7+
8+
return false;
9+
}
10+
11+
bool UseCase_RespawnSilently(int client) {
12+
bool noTeam = GetClientTeam(client) < TEAM_ALLIES;
13+
bool noClass = GetDesiredPlayerClass(client) == NO_DESIRED_PLAYER_CLASS;
414

515
if (noTeam || noClass) {
616
return false;
717
}
818

9-
SdkHook_Respawn(target);
10-
MessageLog_PlayerRespawned(client, target);
19+
SdkHook_Respawn(client);
1120

1221
return true;
1322
}
1423

15-
static int UseCase_GetDesiredPlayerClass(int client) {
24+
static int GetDesiredPlayerClass(int client) {
1625
return GetEntProp(client, Prop_Send, "m_iDesiredPlayerClass");
1726
}

scripting/player-respawn.sp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public Plugin myinfo = {
1616
name = "Player respawn",
1717
author = "Dron-elektron",
1818
description = "Allows you to respawn the player",
19-
version = "1.2.0",
19+
version = "2.0.0",
2020
url = "https://github.com/dronelektron/player-respawn"
2121
};
2222

0 commit comments

Comments
 (0)