File tree Expand file tree Collapse file tree 5 files changed +20
-13
lines changed Expand file tree Collapse file tree 5 files changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ Allows you to respawn the player
23
23
24
24
Respawn the ` client `
25
25
26
+ Returns ` true ` on success and ` false ` if the player does not have a team or class
27
+
26
28
``` sourcepawn
27
- native void RespawnPlayer(int client);
29
+ native bool RespawnPlayer(int client);
28
30
```
Original file line number Diff line number Diff line change 3
3
#endif
4
4
#define _player_respawn_api_included
5
5
6
- native void RespawnPlayer (int client );
6
+ native bool RespawnPlayer (int client );
Original file line number Diff line number Diff line change 1
- static const int VOID = 0 ;
2
-
3
1
void Native_Create () {
4
2
CreateNative (" RespawnPlayer" , Native_RespawnPlayer );
5
3
RegPluginLibrary (" player-respawn" );
@@ -8,7 +6,5 @@ void Native_Create() {
8
6
any Native_RespawnPlayer (Handle plugin , int numParams ) {
9
7
int client = GetNativeCell (1 );
10
8
11
- SdkHook_Respawn (client );
12
-
13
- return VOID ;
9
+ return UseCase_RespawnSilently (client );
14
10
}
Original file line number Diff line number Diff line change 1
1
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 ;
4
14
5
15
if (noTeam || noClass ) {
6
16
return false ;
7
17
}
8
18
9
- SdkHook_Respawn (target );
10
- MessageLog_PlayerRespawned (client , target );
19
+ SdkHook_Respawn (client );
11
20
12
21
return true ;
13
22
}
14
23
15
- static int UseCase_GetDesiredPlayerClass (int client ) {
24
+ static int GetDesiredPlayerClass (int client ) {
16
25
return GetEntProp (client , Prop_Send , " m_iDesiredPlayerClass" );
17
26
}
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public Plugin myinfo = {
16
16
name = " Player respawn" ,
17
17
author = " Dron-elektron" ,
18
18
description = " Allows you to respawn the player" ,
19
- version = " 1.2 .0" ,
19
+ version = " 2.0 .0" ,
20
20
url = " https://github.com/dronelektron/player-respawn"
21
21
};
22
22
You can’t perform that action at this time.
0 commit comments