1
1
/* *
2
- * Custom Spawn V1.0
2
+ * Custom Spawn V1.1. 0
3
3
* By David Y.
4
4
* 2015-01-21
5
5
*
21
21
#include <sdktools>
22
22
23
23
new Handle :sm_players_spawn_admin_only = INVALID_HANDLE ;
24
+ new Handle :sm_player_spawns = INVALID_HANDLE ;
24
25
25
26
static Float :SpawnPoint [MAXPLAYERS ][3 ];
26
27
static bool :SpawnSet [MAXPLAYERS ];
@@ -30,13 +31,14 @@ public Plugin:myinfo = {
30
31
name = " Player Spawns" ,
31
32
author = " David Y." ,
32
33
description = " Players set a custom spawnpoint for themselves." ,
33
- version = " 1.0 .0" ,
34
+ version = " 1.1 .0" ,
34
35
url = " http://www.davidvyee.com/"
35
36
}
36
37
37
38
public OnPluginStart () {
38
- CreateConVar (" sm_player_spawns_version" , " 1.0.0" , " Player Spawns Version" , FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY );
39
- sm_players_spawn_admin_only = CreateConVar (" sm_players_spawn_admin_only" , " 0" , " Toggles Admin Only spawn saving." , FCVAR_PLUGIN );
39
+ CreateConVar (" sm_player_spawns_version" , " 1.1.0" , " Player Spawns Version" , FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY );
40
+ sm_player_spawns = CreateConVar (" sm_player_spawns" , " 1" , " Respawn players to their custom locations on death; 0 - disabled, 1 - enabled" );
41
+ sm_players_spawn_admin_only = CreateConVar (" sm_players_spawn_admin_only" , " 0" , " Toggles Admin Only spawn saving; 0 - disabled, 1 - enabled" , FCVAR_PLUGIN );
40
42
RegConsoleCmd (" sm_setspawn" , SetSpawn );
41
43
RegConsoleCmd (" sm_clearspawn" , ClearSpawn );
42
44
@@ -52,6 +54,12 @@ public OnClientPutInServer(Client) {
52
54
}
53
55
54
56
public Action :SetSpawn (Client , Args ) {
57
+ new playerSpawnsState = GetConVarInt (sm_player_spawns );
58
+ if (playerSpawnsState == 0 ) {
59
+ PrintToChat (Client , " [SM] You cannot set your spawn location because player spawns has been disabled." );
60
+ return Plugin_Handled ;
61
+ }
62
+
55
63
if (SpawnSetDisabled == true ) {
56
64
PrintToChat (Client , " [SM] You cannot set your spawn right now." );
57
65
return Plugin_Handled ;
@@ -89,6 +97,12 @@ public Action:SetSpawn(Client, Args) {
89
97
}
90
98
91
99
public Action :ClearSpawn (Client , Args ) {
100
+ new playerSpawnsState = GetConVarInt (sm_player_spawns );
101
+ if (playerSpawnsState == 0 ) {
102
+ PrintToChat (Client , " [SM] You cannot clear your spawn location because player spawns has been disabled." );
103
+ return Plugin_Handled ;
104
+ }
105
+
92
106
if (Args == 0 ) {
93
107
if (Client == 0 ) {
94
108
return Plugin_Handled ;
@@ -202,17 +216,20 @@ public Action:ClearSpawn(Client, Args) {
202
216
203
217
public PlayerSpawn (Handle :Event , const String :Name [], bool :Broadcast )
204
218
{
205
- decl Client ;
206
- Client = GetClientOfUserId (GetEventInt (Event , " userid" ));
219
+ new playerSpawnsState = GetConVarInt (sm_player_spawns );
220
+ if (playerSpawnsState > 0 ) {
221
+ decl Client ;
222
+ Client = GetClientOfUserId (GetEventInt (Event , " userid" ));
207
223
208
- new AdminId :id = GetUserAdmin (Client );
224
+ new AdminId :id = GetUserAdmin (Client );
209
225
210
- if (GetConVarBool (sm_players_spawn_admin_only ) && id == INVALID_ADMIN_ID ) {
211
- return ;
212
- }
226
+ if (GetConVarBool (sm_players_spawn_admin_only ) && id == INVALID_ADMIN_ID ) {
227
+ return ;
228
+ }
213
229
214
- if (SpawnSet [Client ]) {
215
- TeleportEntity (Client , SpawnPoint [Client ], NULL_VECTOR , NULL_VECTOR );
230
+ if (SpawnSet [Client ]) {
231
+ TeleportEntity (Client , SpawnPoint [Client ], NULL_VECTOR , NULL_VECTOR );
232
+ }
216
233
}
217
234
}
218
235
0 commit comments