-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnusedPrecache.sma
125 lines (111 loc) · 2.93 KB
/
UnusedPrecache.sma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
new szSounds[1024][1024], iSound
new szModels[1024][1024], iModels
new szGeneric[1024][1024], iGeneric
new Enabled, HostSound
public plugin_precache()
{
load_config()
register_forward(FM_PrecacheModel, "PrecacheModel")
register_forward(FM_PrecacheGeneric, "PrecacheGeneric")
register_forward(FM_PrecacheSound, "PrecacheSound")
}
public load_config()
{
new cfg[64], path[128]
get_mapname(cfg, charsmax(cfg))
format(path, charsmax(path), "script/unprecache/%s.txt", cfg)
if (!file_exists(path))
{
format(path, charsmax(path), "script/unprecache.txt")
}
new file, linedata[1386], key[512], value[960], section
file = fopen(path, "rt")
while (file && !feof(file))
{
fgets(file, linedata, charsmax(linedata))
replace(linedata, charsmax(linedata), "^n", "")
if (!linedata[0] || linedata[0] == ';') continue;
if (linedata[0] == '[')
{
section++
continue;
}
if(section == 1)
{
parse(linedata, key, 511)
format(szModels[iModels], 1023, "%s", key)
iModels++
}
else if(section == 2)
{
parse(linedata, key, 511)
format(szSounds[iSound], 1023, "%s", key)
iSound++
}
else if(section == 3)
{
parse(linedata, key, 511)
format(szGeneric[iGeneric], 1023, "%s", key)
iGeneric++
}
else if(section == 4)
{
strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
trim(key)
trim(value)
if(equal(key, "unprecache_enabled")) Enabled = str_to_num(value)
else if(equal(key, "unprecache_hostage_sound")) HostSound = str_to_num(value)
}
}
server_print("Unprecache Loaded %i Model %i Sound %i Generic", iModels, iSound, iGeneric)
}
public PrecacheModel(const sModel[])
{
if(!Enabled) return FMRES_IGNORED
for(new i = 0; i < iModels; i++)
{
if(containi(sModel, szModels[i]) != -1 )
{
server_print("Unprecache Block %s", sModel)
forward_return(FMV_CELL, 0)
return FMRES_SUPERCEDE
}
}
return FMRES_IGNORED
}
public PrecacheSound(const sSound[])
{
if(!Enabled) return FMRES_IGNORED
if (equal(sSound, "hostage", 7) && HostSound)
return FMRES_SUPERCEDE;
for(new i = 0; i < iSound; i++)
{
if(containi(sSound, szSounds[i]) != -1 )
{
server_print("Unprecache Block %s", sSound)
forward_return(FMV_CELL, 0)
return FMRES_SUPERCEDE
}
}
return FMRES_IGNORED
}
public PrecacheGeneric(const sGeneric[])
{
if(!Enabled) return FMRES_IGNORED
for(new i = 0; i < iGeneric; i++)
{
if(containi(sGeneric, szGeneric[i]) != -1 )
{
server_print("Unprecache Block %s", sGeneric)
forward_return(FMV_CELL, 0)
return FMRES_SUPERCEDE
}
}
return FMRES_IGNORED
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1057\\ f0\\ fs16 \n\\ par }
*/