Skip to content

Commit 1be0dce

Browse files
committed
initial
0 parents  commit 1be0dce

10 files changed

+4399
-0
lines changed

api_custom_entities.sma

Lines changed: 1048 additions & 0 deletions
Large diffs are not rendered by default.

api_custom_weapons.sma

Lines changed: 2623 additions & 0 deletions
Large diffs are not rendered by default.

api_player_model.sma

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
#include <amxmodx>
2+
#include <amxmisc>
3+
#include <hamsandwich>
4+
#include <reapi>
5+
#include <fakemeta>
6+
#include <xs>
7+
8+
#define PLUGIN "[API] Player Model"
9+
#define VERSION "0.9.0"
10+
#define AUTHOR "Hedgehog Fog"
11+
12+
new g_rgszPlayerModel[MAX_PLAYERS + 1][32];
13+
new g_rgszCustomPlayerModel[MAX_PLAYERS + 1][256];
14+
15+
public plugin_init() {
16+
register_plugin(PLUGIN, VERSION, AUTHOR);
17+
18+
RegisterHamPlayer(Ham_Spawn, "HamHook_Player_Spawn_Post", .Post = 1);
19+
20+
register_forward(FM_SetClientKeyValue, "FMHook_SetClientKeyValue");
21+
}
22+
23+
public plugin_natives() {
24+
register_library("api_player_model");
25+
register_native("PlayerModel_Get", "Native_GetPlayerModel");
26+
register_native("PlayerModel_Set", "Native_SetPlayerModel");
27+
register_native("PlayerModel_Reset", "Native_ResetPlayerModel");
28+
register_native("PlayerModel_Update", "Native_UpdatePlayerModel");
29+
}
30+
31+
public Native_GetPlayerModel(iPluginId, iArgc) {
32+
new pPlayer = get_param(1);
33+
34+
set_string(2, g_rgszCustomPlayerModel[pPlayer], get_param(3));
35+
}
36+
37+
public Native_SetPlayerModel(iPluginId, iArgc) {
38+
new pPlayer = get_param(1);
39+
get_string(2, g_rgszCustomPlayerModel[pPlayer], charsmax(g_rgszCustomPlayerModel[]));
40+
}
41+
42+
public Native_ResetPlayerModel(iPluginId, iArgc) {
43+
new pPlayer = get_param(1);
44+
@Player_ResetModel(pPlayer);
45+
}
46+
47+
public Native_UpdatePlayerModel(iPluginId, iArgc) {
48+
new pPlayer = get_param(1);
49+
@Player_UpdateModel(pPlayer);
50+
}
51+
52+
public client_connect(pPlayer) {
53+
copy(g_rgszCustomPlayerModel[pPlayer], charsmax(g_rgszCustomPlayerModel[]), NULL_STRING);
54+
copy(g_rgszPlayerModel[pPlayer], charsmax(g_rgszPlayerModel[]), NULL_STRING);
55+
}
56+
57+
public HamHook_Player_Spawn_Post(pPlayer) {
58+
@Player_UpdateModel(pPlayer);
59+
}
60+
61+
public FMHook_SetClientKeyValue(pPlayer, const szInfoBuffer[], const szKey[], const szValue[]) {
62+
if (equal(szKey, "model")) {
63+
copy(g_rgszPlayerModel[pPlayer], charsmax(g_rgszPlayerModel[]), szValue);
64+
65+
if (!equal(g_rgszCustomPlayerModel[pPlayer], NULL_STRING)) {
66+
return FMRES_SUPERCEDE;
67+
}
68+
69+
return FMRES_IGNORED;
70+
}
71+
72+
return FMRES_IGNORED;
73+
}
74+
75+
public @Player_UpdateModel(this) {
76+
if (!equal(g_rgszCustomPlayerModel[this], NULL_STRING)) {
77+
new iModelIndex = engfunc(EngFunc_ModelIndex, g_rgszCustomPlayerModel[this]);
78+
set_user_info(this, "model", "");
79+
set_pev(this, pev_modelindex, iModelIndex);
80+
set_member(this, m_modelIndexPlayer, iModelIndex);
81+
} else {
82+
@Player_ResetModel(this);
83+
}
84+
}
85+
86+
public @Player_ResetModel(this) {
87+
if (equal(g_rgszPlayerModel[this], NULL_STRING)) {
88+
return;
89+
}
90+
91+
static szPath[MAX_RESOURCE_PATH_LENGTH];
92+
format(szPath, charsmax(szPath), "models/player/%s/%s.mdl", g_rgszPlayerModel[this], g_rgszPlayerModel[this]);
93+
94+
new iModelIndex = engfunc(EngFunc_ModelIndex, szPath);
95+
set_user_info(this, "model", g_rgszPlayerModel[this]);
96+
set_pev(this, pev_modelindex, iModelIndex);
97+
set_member(this, m_modelIndexPlayer, iModelIndex);
98+
copy(g_rgszCustomPlayerModel[this], charsmax(g_rgszCustomPlayerModel[]), NULL_STRING);
99+
}

api_player_viewrange.sma

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#include <amxmodx>
2+
#include <amxmisc>
3+
#include <hamsandwich>
4+
#include <reapi>
5+
#include <fakemeta>
6+
#include <xs>
7+
8+
#define PLUGIN "[API] Player View Range"
9+
#define VERSION "0.9.0"
10+
#define AUTHOR "Hedgehog Fog"
11+
12+
new Float:g_rgflPlayerViewRange[MAX_PLAYERS + 1];
13+
new g_rgiPlayerNativeFogColor[MAX_PLAYERS + 1][3];
14+
new Float:g_flPlayerNativeFogDensity[MAX_PLAYERS + 1];
15+
16+
new gmsgFog;
17+
18+
public plugin_init() {
19+
register_plugin(PLUGIN, VERSION, AUTHOR);
20+
21+
gmsgFog = get_user_msgid("Fog");
22+
23+
register_message(gmsgFog, "Message_Fog");
24+
}
25+
26+
public plugin_natives() {
27+
register_library("api_player_viewrange");
28+
register_native("PlayerViewRange_Get", "Native_GetPlayerViewRange");
29+
register_native("PlayerViewRange_Set", "Native_SetPlayerViewRange");
30+
register_native("PlayerViewRange_Reset", "Native_ResetPlayerViewRange");
31+
register_native("PlayerViewRange_Update", "Native_UpdatePlayerViewRange");
32+
}
33+
34+
public Float:Native_GetPlayerViewRange(iPluginId, iArgc) {
35+
new pPlayer = get_param(1);
36+
37+
return g_rgflPlayerViewRange[pPlayer];
38+
}
39+
40+
public Native_SetPlayerViewRange(iPluginId, iArgc) {
41+
new pPlayer = get_param(1);
42+
new Float:flValue = get_param_f(2);
43+
44+
@Player_SetViewRange(pPlayer, flValue);
45+
}
46+
47+
public Native_ResetPlayerViewRange(iPluginId, iArgc) {
48+
new pPlayer = get_param(1);
49+
50+
@Player_SetViewRange(pPlayer, -1.0);
51+
}
52+
53+
public Native_UpdatePlayerViewRange(iPluginId, iArgc) {
54+
new pPlayer = get_param(1);
55+
56+
@Player_UpdateViewRange(pPlayer);
57+
}
58+
59+
public client_connect(pPlayer) {
60+
g_rgflPlayerViewRange[pPlayer] = 0.0;
61+
g_rgiPlayerNativeFogColor[pPlayer][0] = 0;
62+
g_rgiPlayerNativeFogColor[pPlayer][1] = 0;
63+
g_rgiPlayerNativeFogColor[pPlayer][2] = 0;
64+
g_flPlayerNativeFogDensity[pPlayer] = 0.0;
65+
}
66+
67+
public Message_Fog(iMsgId, iMsgDest, pPlayer) {
68+
g_rgiPlayerNativeFogColor[pPlayer][0] = get_msg_arg_int(1);
69+
g_rgiPlayerNativeFogColor[pPlayer][1] = get_msg_arg_int(2);
70+
g_rgiPlayerNativeFogColor[pPlayer][2] = get_msg_arg_int(3);
71+
g_flPlayerNativeFogDensity[pPlayer] = Float:(
72+
get_msg_arg_int(4) |
73+
(get_msg_arg_int(5) << 8) |
74+
(get_msg_arg_int(6) << 16) |
75+
(get_msg_arg_int(7) << 24)
76+
);
77+
}
78+
79+
public @Player_SetViewRange(this, Float:flViewRange) {
80+
if (g_rgflPlayerViewRange[this] == flViewRange) {
81+
return;
82+
}
83+
84+
g_rgflPlayerViewRange[this] = flViewRange;
85+
86+
@Player_UpdateViewRange(this);
87+
}
88+
89+
public @Player_UpdateViewRange(this) {
90+
if (g_rgflPlayerViewRange[this] >= 0.0) {
91+
new Float:flDensity = g_rgflPlayerViewRange[this] < 0 ? 0.0 : (1.0 / g_rgflPlayerViewRange[this]);
92+
93+
message_begin(MSG_ONE, gmsgFog, {0, 0, 0}, this);
94+
write_byte(0);
95+
write_byte(0);
96+
write_byte(0);
97+
write_long(_:flDensity);
98+
message_end();
99+
} else { // reset to engine fog
100+
message_begin(MSG_ONE, gmsgFog, {0, 0, 0}, this);
101+
write_byte(g_rgiPlayerNativeFogColor[this][0]);
102+
write_byte(g_rgiPlayerNativeFogColor[this][1]);
103+
write_byte(g_rgiPlayerNativeFogColor[this][2]);
104+
write_long(_:g_flPlayerNativeFogDensity[this]);
105+
message_end();
106+
}
107+
}

0 commit comments

Comments
 (0)