Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Commit 58e9cd6

Browse files
committed
Version 1.5.5
New native: ArmsFix_SetDefaultArms - force sets default arms New cvar: sm_arms_fix_autospawn - Enable/disable auto spawn fix - You can manually use plugin natives in your plugin.
1 parent 8f9ad14 commit 58e9cd6

File tree

4 files changed

+90
-3
lines changed

4 files changed

+90
-3
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include <sourcemod>
2+
#include <sdktools>
3+
#include <n_arms_fix>
4+
5+
public Plugin myinfo =
6+
{
7+
name = "Example: My basic player skin changer",
8+
author = "NomisCZ",
9+
description = "Skin for players",
10+
version = "1.0",
11+
url = "http://steamcommunity.com/id/olympic-nomis-p"
12+
}
13+
14+
public void OnPluginStart() {
15+
16+
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);
17+
}
18+
19+
public Action Event_PlayerSpawn(Handle event, const char[] name, bool dontBroadcast) {
20+
21+
int client = GetClientOfUserId(GetEventInt(event, "userid"));
22+
23+
PlayerArmsModel(client);
24+
CreateTimer(1.5, PlayerModel, client); //1.5 is optimal!
25+
}
26+
27+
public void PlayerArmsModel(int client) {
28+
29+
if(!IsValidClient(client))
30+
return;
31+
32+
ArmsFix_SetDefaults(client);
33+
SetEntPropString(client, Prop_Send, "m_szArmsModel", "models/player/custom_player/xxx/yyy_arms.mdl");
34+
}
35+
36+
public Action PlayerModel(Handle timer, any client) {
37+
38+
if(!IsValidClient(client))
39+
return;
40+
41+
SetEntityModel(client, "models/player/custom_player/xxx/yyy.mdl");
42+
SetEntityRenderColor(client, 255, 255, 255, 255);
43+
}
44+
45+
bool IsValidClient(int client) {
46+
47+
return (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client)) ? true : false;
48+
}
679 Bytes
Binary file not shown.

addons/sourcemod/scripting/include/n_arms_fix.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ forward void ArmsFix_OnModelSafe(int client);
2828
*/
2929
native int ArmsFix_SetDefaults(int client);
3030

31+
/**
32+
* Set default arms
33+
*
34+
* @param client client index
35+
* @return no return
36+
*/
37+
native int ArmsFix_SetDefaultArms(int client);
38+
3139
/**
3240
* Has default arms?
3341
*

addons/sourcemod/scripting/n_arms_fix.sp

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
Handle armsHandle;
1919
Handle modelHandle;
2020

21+
ConVar autoSpawnCvar = null;
22+
bool autoSpawn = true;
23+
2124
char defaultCTFbiModels[][] = {
2225
"ctm_fbi.mdl",
2326
"ctm_fbi_variantA.mdl",
@@ -59,17 +62,21 @@ public Plugin myinfo = {
5962
name = "Arms Fix",
6063
author = "NomisCZ (-N-)",
6164
description = "Arms fix",
62-
version = "1.5",
65+
version = "1.5.5",
6366
url = "http://steamcommunity.com/id/olympic-nomis-p"
6467
}
6568

6669
public void OnPluginStart() {
6770

6871
HookEvent("player_spawn", Event_PlayerSpawn);
72+
autoSpawnCvar = CreateConVar("sm_arms_fix_autospawn", "1", "Enable auto spawn fix (automatically sets default gloves)? 0 = False, 1 = True", _, true, 0.0, true, 1.0);
73+
autoSpawnCvar.AddChangeHook(OnCvarChanged);
6974
}
7075

7176
public void OnConfigsExecuted() {
7277

78+
autoSpawn = autoSpawnCvar.BoolValue;
79+
7380
PrecacheModels();
7481
PrecacheModels(true);
7582
PrecacheArms();
@@ -83,17 +90,26 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
8390
modelHandle = CreateGlobalForward("ArmsFix_OnModelSafe", ET_Ignore, Param_Cell);
8491
CreateNative("ArmsFix_SetDefaults", Native_SetDefault);
8592
CreateNative("ArmsFix_HasDefaultArms", Native_HasDefaultArms);
93+
CreateNative("ArmsFix_SetDefaultArms", Native_SetDefaultArms);
8694

8795
return APLRes_Success;
8896
}
8997

98+
public void OnCvarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
99+
{
100+
if (convar == autoSpawnCvar) {
101+
autoSpawn = view_as<bool>(StringToInt(newValue));
102+
}
103+
}
104+
90105
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) {
91106

92107
int client = GetClientOfUserId(event.GetInt("userid"));
93108

94109
if ((!IsValidClient(client) && !IsPlayerAlive(client) || IsFakeClient(client))) return;
95110

96-
SetDefault(client);
111+
if (autoSpawn) SetDefault(client);
112+
97113
CallForwards(client);
98114
}
99115

@@ -128,6 +144,12 @@ public int Native_SetDefault(Handle plugin, int numParams) {
128144
SetDefault(client);
129145
}
130146

147+
public int Native_SetDefaultArms(Handle plugin, int numParams) {
148+
149+
int client = GetNativeCell(1);
150+
SetDefaultArms(client);
151+
}
152+
131153
public int Native_HasDefaultArms(Handle plugin, int numParams) {
132154

133155
int client = GetNativeCell(1);
@@ -204,6 +226,16 @@ public void SetDefault(int client) {
204226
}
205227
}
206228

229+
public void SetDefaultArms(int client) {
230+
231+
if ((!IsValidClient(client) && !IsPlayerAlive(client) || IsFakeClient(client))) return;
232+
233+
int clientTeam = (GetClientTeam(client) == CS_TEAM_T ? 0 : 1);
234+
235+
SetEntPropString(client, Prop_Send, "m_szArmsModel", "");
236+
SetEntPropString(client, Prop_Send, "m_szArmsModel", defaultArms[clientTeam]);
237+
}
238+
207239
char GetNewRandomModel(int client) {
208240

209241
char clientModel[256];
@@ -278,6 +310,5 @@ bool hasDefaultArms(int client) {
278310

279311
char clientModel[256];
280312
GetEntPropString(client, Prop_Send, "m_szArmsModel", clientModel, sizeof(clientModel));
281-
282313
return (StrEqual(clientModel, defaultArms[0]) || StrEqual(clientModel, defaultArms[1]) || StrEqual(clientModel, "")) ? true : false;
283314
}

0 commit comments

Comments
 (0)