#define differenceBetweenNumbers(%0,%1) \
floatround(floatabs((%0) - (%1)))
stock GetDifferenceBetweenNumbers(Float:num1, Float:num2) return printf("%f",((num1) >= (num2)) ? ((num1) - (num2)) : ((num2) - (num1)));
stock bool:FUnkshion()
stock Float:FUnkshion()
stock bool:FUnkshion()
#define int _
stock int:FUnkshion()
#define DOB:: \
DOB_
#define DOB_GetCells(%0) \
(((%0) + cellbits) / cellbits) // Round up
#define BitArray:%0[%1] \
Bits:%0[DOB_GetCells(%1)]
stock DOB::GetBit (Bits: bitarray [], index)
return _: ((bitarray [index / cellbits] & Bits: (1 << (index % cellbits))) != Bits: 0);
stock DOB::SetBit (Bits: bitarray [], index, bool: set)
{
if (set)
bitarray [index / cellbits] |= Bits: (1 << (index % cellbits));
else
bitarray [index / cellbits] &= Bits: ~(1 << (index % cellbits));
}
stock DOB::SetAllBits (Bits: bitarray [], bool: set, cells = sizeof (bitarray))
{
if (set)
for (new i = 0; i < cells; ++i)
bitarray [i] = Bit: 0xFFFFFFFF; // bitarray [i] |= Bit: 0xFFFFFFFF;
else
for (new i = 0; i < cells; ++i)
bitarray [i] = Bit: 0; // bitarray [i] &= Bit: 0;
}
I'm not sure, but if it's an invalid skin ID, won't it just set it to CJ?
|
stock PrintStack()
{
new stp, stk;
new row[4];
new rowidx = 0;
new stackitem;
// Get the registers
#emit lctrl 3
#emit stor.s.pri stp
#emit lctrl 4
#emit stor.s.pri stk
// Walk through the stack print 4 elements in each row
for (new i = stk; i < stp; i += 4) {
#emit lref.s.pri i
#emit stor.s.pri stackitem
row[rowidx++] = stackitem;
if ((i / 4) % 4 == 0) {
printf("[%04x]: %04x%04x %04x%04x %04x%04x %04x%04x", i - stk,
(row[0] & 0xFFFF0000) >> 16, row[0] & 0x0000FFFF,
(row[1] & 0xFFFF0000) >> 16, row[1] & 0x0000FFFF,
(row[2] & 0xFFFF0000) >> 16, row[2] & 0x0000FFFF,
(row[3] & 0xFFFF0000) >> 16, row[3] & 0x0000FFFF
);
rowidx = 0;
}
}
return (stp - stk) / 4; // Number of items (cells) printed
}
You could do:
pawn Код:
pawn Код:
|
#define SetAllBits(%1,%2,%3); \
for(new %1aset=(%2),Bit:bbt%1=(!%1aset)?(Bit:0):(Bit:-1),%1i;%1i!=%3;%1i++){%1[%1i]=bbt%1;}
pawn Код:
|
stock strreplace (newstr [], oldstr [], srcstr [], deststr [], bool: ignorecase = false, size = sizeof (deststr))
{
new
newlen = strlen (newstr),
oldlen = strlen (oldstr),
srclen = strlen (srcstr),
idx,
rep;
for (new i = 0; i < srclen; ++i)
{
if ((i + oldlen) < srclen)
{
if (!strcmp (srcstr [i], oldstr, ignorecase, oldlen))
{
deststr [idx] = '\0';
strcat (deststr, newstr, size);
++rep;
idx += newlen;
i += oldlen - 1;
}
else
{
if (idx < size)
deststr [idx++] = srcstr [i];
else
return rep;
}
}
else
{
if (idx < size)
deststr [idx++] = srcstr [i];
else
return rep;
}
}
return rep;
}
stock strreplace2(string[], const find[], const replace[], bool:ignorecase=false, count=cellmax, maxlength=sizeof(string)) { if(isnull(find) || isnull(string)) return 0; new matches; for(new idx, flen = strlen(find), rlen = strlen(replace), pos = strfind(string, find, ignorecase); pos != -1 && idx < maxlength && matches < count; pos = strfind(string, find, ignorecase, idx)) { strdel(string, pos, pos + flen); if(rlen) strins(string, replace, pos, maxlength); idx = pos + rlen; matches++; } return matches; }
stock str_replace (newstr [], oldstr [], srcstr [], deststr [], bool: ignorecase = false, size = sizeof (deststr))
{
new
newlen = strlen (newstr),
oldlen = strlen (oldstr),
srclen = strlen (srcstr),
idx,
rep;
for (new i = 0; i < srclen; ++i)
{
if ((i + oldlen) <= srclen)
{
if (!strcmp (srcstr [i], oldstr, ignorecase, oldlen))
{
deststr [idx] = '\0';
strcat (deststr, newstr, size);
++rep;
idx += newlen;
i += oldlen - 1;
}
else
{
if (idx < (size - 1))
deststr [idx++] = srcstr [i];
else
return rep;
}
}
else
{
if (idx < (size - 1))
deststr [idx++] = srcstr [i];
else
return rep;
}
}
deststr [idx] = '\0';
return rep;
}
for (new i = 0; i < 500; ++i)
{
new
t,
string [256] = "AffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffe",
string2 [256];
const MAX_I = 20000;
t = GetTickCount ();
for (new k = 0; k < MAX_I; ++k)
{
string = "AffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffe";
string2 = strreplace ("Affe", "Kuh", string);
}
t = GetTickCount () - t;
printf ("strreplace: %d ms (%s)", t, string2);
t = GetTickCount ();
for (new k = 0; k < MAX_I; ++k)
{
string = "AffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffe";
str_replace ("Kuh", "Affe", string, string2);
}
t = GetTickCount () - t;
printf ("str_replace: %d ms (%s)", t, string2);
t = GetTickCount ();
for (new k = 0; k < MAX_I; ++k)
{
string = "AffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffe";
strreplace2 (string, "Affe", "Kuh");
}
t = GetTickCount () - t;
printf ("strreplace2: %d ms (%s)", t, string);
}
[18:09:33] strreplace: 8101 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:09:34] str_replace: 379 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:09:34] strreplace2: 547 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:09:42] strreplace: 7986 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:09:43] str_replace: 378 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:09:43] strreplace2: 550 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:09:51] strreplace: 8017 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:09:52] str_replace: 376 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:09:52] strreplace2: 549 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:10:00] strreplace: 8003 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:10:00] str_replace: 382 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:10:01] strreplace2: 546 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh)
stock strReplace(strWhat[], strWith[], strSrc[], strDest[], bool: ignoreCase = false, destSize = sizeof(strDest))
{
new
strPos = -1,
whatLen = strlen(strWhat)
;
memcpy(strDest, strSrc, _, 1 + strlen(strSrc) << 2, destSize);
while((strPos = strfind(strDest, strWhat, ignoreCase, strPos + 1)) != -1)
{
strdel(strDest, strPos, strPos + whatLen);
strins(strDest, strWith, strPos, destSize);
}
return ;
}
for (new i = 0; i < 500; ++i)
{
new
t,
string [256] = "AffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffe",
string2 [256];
const MAX_I = 20000;
t = GetTickCount ();
for (new k = 0; k < MAX_I; ++k)
{
string = "AffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffe";
string2 = strreplace ("Affe", "Kuh", string);
}
t = GetTickCount () - t;
printf ("strreplace: %d ms (%s)", t, string2);
t = GetTickCount ();
for (new k = 0; k < MAX_I; ++k)
{
string = "AffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffe";
str_replace ("Kuh", "Affe", string, string2);
}
t = GetTickCount () - t;
printf ("str_replace: %d ms (%s)", t, string2);
t = GetTickCount ();
for (new k = 0; k < MAX_I; ++k)
{
string = "AffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffe";
strreplace2 (string, "Affe", "Kuh");
}
t = GetTickCount () - t;
printf ("strreplace2: %d ms (%s)", t, string);
t = GetTickCount ();
for (new k = 0; k < MAX_I; ++k)
{
string = "AffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffeAffe";
strReplace ("Affe", "Kuh", string, string2);
}
t = GetTickCount () - t;
printf ("strReplace: %d ms (%s)", t, string2);
}
[18:27:23] strreplace: 8077 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:27:24] str_replace: 382 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:27:24] strreplace2: 543 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:27:25] strReplace: 484 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:27:33] strreplace: 8032 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:27:33] str_replace: 386 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:27:34] strreplace2: 543 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:27:34] strReplace: 483 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:27:42] strreplace: 8023 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:27:43] str_replace: 381 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:27:43] strreplace2: 544 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh) [18:27:44] strReplace: 489 ms (KuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuhKuh)
stock strCopy(strSrc[], strDest[], maxLen = -1, destSize = sizeof(strDest))
{
if(maxLen == -1)
maxLen = strlen(strSrc);
return memcpy(strDest, strSrc, _, maxLen << 2, destSize);
}