Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit c58114d

Browse files
committed
v1.1.1 - Include smlib
1 parent 2b4d09c commit c58114d

24 files changed

+10161
-0
lines changed

plugin/libraries/smlib.inc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#if defined _smlib_included
2+
#endinput
3+
#endif
4+
#define _smlib_included
5+
6+
#define SMLIB_VERSION "0.9.7"
7+
8+
#include <smlib/general>
9+
10+
#include <smlib/arrays>
11+
#include <smlib/clients>
12+
#include <smlib/colors>
13+
#include <smlib/concommands>
14+
#include <smlib/convars>
15+
#include <smlib/crypt>
16+
#include <smlib/debug>
17+
#include <smlib/dynarrays>
18+
#include <smlib/edicts>
19+
#include <smlib/effects>
20+
#include <smlib/entities>
21+
#include <smlib/files>
22+
#include <smlib/game>
23+
#include <smlib/math>
24+
#include <smlib/menus>
25+
//#include <smlib/pluginmanager>
26+
#include <smlib/server>
27+
#include <smlib/strings>
28+
#include <smlib/sql>
29+
#include <smlib/teams>
30+
#include <smlib/vehicles>
31+
#include <smlib/weapons>
32+
#include <smlib/world>

plugin/libraries/smlib/arrays.inc

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
#if defined _smlib_array_included
2+
#endinput
3+
#endif
4+
#define _smlib_array_included
5+
6+
#include <sourcemod>
7+
8+
/**
9+
* Returns the index for the first occurance of the given value.
10+
* If the value cannot be found, -1 will be returned.
11+
*
12+
* @param array Static Array.
13+
* @param size Size of the Array.
14+
* @param value Value to search for.
15+
* @param start Optional: Offset where to start (0 - (size-1)).
16+
* @return Array index, or -1 if the value couldn't be found.
17+
*/
18+
stock Array_FindValue(any:array[], size, any:value, start=0)
19+
{
20+
if (start < 0) {
21+
start = 0;
22+
}
23+
24+
for (new i=start; i < size; i++) {
25+
26+
if (array[i] == value) {
27+
return i;
28+
}
29+
}
30+
31+
return -1;
32+
}
33+
34+
/**
35+
* Searchs for the first occurance of a string in the array.
36+
* If the value cannot be located, -1 will be returned.
37+
*
38+
* @param array Static Array.
39+
* @param size Size of the Array.
40+
* @param value String to search for.
41+
* @param start Optional: Offset where to start(0 - (size-1)).
42+
* @return Array index, or -1 if the value couldn't be found.
43+
*/
44+
stock Array_FindString(const String:array[][], size, const String:str[], bool:caseSensitive=true, start=0)
45+
{
46+
if (start < 0) {
47+
start = 0;
48+
}
49+
50+
for (new i=start; i < size; i++) {
51+
52+
if (StrEqual(array[i], str, caseSensitive)) {
53+
return i;
54+
}
55+
}
56+
57+
return -1;
58+
}
59+
60+
/**
61+
* Returns the Index of the Lowest value in the array
62+
*
63+
* @param array Static Array.
64+
* @param size Size of the Array.
65+
* @param start Optional: Offset where to start (0 - (size-1)).
66+
* @return Array index.
67+
*/
68+
stock Array_FindLowestValue(any:array[], size, start=0)
69+
{
70+
if (start < 0) {
71+
start = 0;
72+
}
73+
74+
new any:value = array[start];
75+
new any:tempValue;
76+
new x = start;
77+
78+
for (new i=start; i < size; i++) {
79+
80+
tempValue = array[i];
81+
82+
if (tempValue < value) {
83+
value = tempValue;
84+
x = i;
85+
}
86+
87+
}
88+
89+
return x;
90+
}
91+
92+
/**
93+
* Returns the Index of the Highest value in the array
94+
*
95+
* @param array Static Array.
96+
* @param size Size of the Array.
97+
* @param start Optional: Offset where to start (0 - (size-1)).
98+
* @return Array index.
99+
*/
100+
stock Array_FindHighestValue(any:array[], size, start=0)
101+
{
102+
if (start < 0) {
103+
start = 0;
104+
}
105+
106+
new any:value = array[start];
107+
new any:tempValue;
108+
new x = start;
109+
110+
for (new i=start; i < size; i++) {
111+
112+
tempValue = array[i];
113+
114+
if (tempValue > value) {
115+
value = tempValue;
116+
x = i;
117+
}
118+
119+
}
120+
121+
return x;
122+
}
123+
124+
/**
125+
* Fills an array with a given value in a 1 dimensional static array.
126+
* You can specify the amount of cells to be written.
127+
*
128+
* @param array Static Array.
129+
* @param size Number of cells to write (eg. the array's size)
130+
* @param value Fill value.
131+
* @param start Optional: Offset where to start (0 - (size-1)).
132+
* @noreturn
133+
*/
134+
stock Array_Fill(any:array[], size, any:value, start=0)
135+
{
136+
if (start < 0) {
137+
start = 0;
138+
}
139+
140+
for (new i=start; i < size; i++) {
141+
array[i] = value;
142+
}
143+
}
144+
145+
/**
146+
* Copies a 1 dimensional static array.
147+
*
148+
* @param array Static Array to copy from.
149+
* @param newArray New Array to copy to.
150+
* @param size Size of the array (or number of cells to copy)
151+
* @noreturn
152+
*/
153+
stock Array_Copy(const any:array[], any:newArray[], size)
154+
{
155+
for (new i=0; i < size; i++) {
156+
newArray[i] = array[i];
157+
}
158+
}

0 commit comments

Comments
 (0)