197: stock SendFormatToAll(colour, const format[], {Float,_}:...)
198: {
199: new string[128];
200: format(string, sizeof(string), format, {Float,_}:...);
201: SendClientMessageToAll(colour, string);
202: }
C:\Server\gamemodes\mode.pwn(100) : error 012: invalid function call, not a valid address C:\Server\gamemodes\mode.pwn(100) : warning 215: expression has no effect C:\Server\gamemodes\mode.pwn(100) : warning 215: expression has no effect C:\Server\gamemodes\mode.pwn(100) : warning 215: expression has no effect C:\Server\gamemodes\mode.pwn(100) : error 017: undefined symbol "Float" C:\Server\gamemodes\mode.pwn(100) : error 029: invalid expression, assumed zero C:\Server\gamemodes\mode.pwn(100) : fatal error 107: too many error messages on one line
new FALSE = false;
#define SendFormattedMessageToAll(%0,%1,%2) \
do \
{ \
new \
string[128]; \
if(strlen(%1) > 0) \
{ \
format(string, sizeof(string), %1, %2); \
foreach(Player, u) SendClientMessage(u, %0, string); \
} \
} \
while(FALSE)
pawn Код:
|
stock SendFormatMessage(playerid, color, const string[], { Float, _ }: ...)
{
new
tempString[128],
parts[64],
tempLen,
totalFound,
i,
j,
t
;
memcpy(tempString, string, _, (strlen(string) + 1) * 4);
for(i = 0; tempString[i] != 0; ++i)
{
for(j = 0; parts[j] != 0; ++j)
{
parts[j] = '\0';
}
switch(tempString[i])
{
case 's', 'S', 'i', 'I', 'd', 'D', 'f', 'F', 'c', 'C', 'x', 'X', 'b', 'B':
{
if(tempString[(i > 0) ? (i - 1) : (i)] != '%')
{
continue;
}
else if(tempString[(i > 0) ? (i - 1) : (i)] == '%')
{
++totalFound;
if(tempString[i] == 's' || tempString[i] == 'S')
{
for(j = 0; getarg(totalFound + 2, j) != 0; ++j)
{
parts[j] = getarg(totalFound + 2, j);
}
}
switch(tempString[i])
{
case 'd', 'D', 'i', 'I': format(parts, sizeof(parts), "%d", getarg(totalFound + 2));
case 'f', 'F': format(parts, sizeof(parts), "%.02f", getarg(totalFound + 2));
case 'c', 'C': format(parts, sizeof(parts), "%c", getarg(totalFound + 2));
case 'x', 'X': format(parts, sizeof(parts), "%x", getarg(totalFound + 2));
case 'b', 'B': format(parts, sizeof(parts), "%b", getarg(totalFound + 2));
}
tempLen = strlen(parts);
if(tempLen > 2)
{
for(j = 0; j != (tempLen - 2); ++j)
{
strins(tempString, "_", (i + 1));
}
for(j = 0, t = 0; tempString[j] != 0; ++j)
{
if(j >= (i - 1) && t < tempLen)
{
tempString[j] = parts[t];
++t;
}
}
continue;
}
else if(tempLen == 2)
{
for(j = 0, t = 0; tempString[j] != 0; ++j)
{
if(j == i || j == (i - 1))
{
tempString[j] = parts[t];
++t;
}
}
continue;
}
else if(tempLen < 2)
{
strdel(tempString, i, i+1);
for(j = 0, t = 0; tempString[j] != 0; ++j)
{
if(j == (i - 1))
{
tempString[j] = parts[t];
++t;
}
}
continue;
}
}
}
}
}
if(playerid != INVALID_PLAYER_ID)
SendClientMessage(playerid, color, tempString);
else
SendClientMessageToAll(color, tempString);
return 1;
}