Palonez
бб братки
- Сообщения
- 3,035
- Реакции
- 1,837
Ошибка .sp(51) : error 008: must be a constant expression; assumed zero
И еще вопрос. При инициализации одномерного массива одинаковыми элементами можно делать так:
А что делать, если массив допустим такой
C++:
#include <sdktools>
float fClientPoint[MAXPLAYERS+1][2][3];
bool bInSets[MAXPLAYERS+1] = {false, ...};
int g_HaloSprite, g_BeamSprite;
enum
{
x = 0,
y,
z
};
public void OnPluginStart()
{
RegConsoleCmd("sm_goo", CMDGOO);
}
public void OnMapStart()
{
g_HaloSprite = PrecacheModel("sprites/halo.vmt", true);
g_BeamSprite = PrecacheModel("sprites/laserbeam.vmt", true);
}
public Action CMDGOO(int i, int args)
{
if(IsClientInGame(i) && !IsFakeClient(i) && IsPlayerAlive(i))
{
float fDistance[3];
fDistance = GetDistanceEyePoint(i);
if(!bInSets[i])
{
bInSets[i] = true;
for(int j = 0; j <= 2; j++)
fClientPoint[i][0][j] = fDistance[j];
}
else
{
bInSets[i] = false;
for(int j = 0; j <= 2; j++)
fClientPoint[i][1][j] = fDistance[j];
CreateCube(fClientPoint[i][0], fClientPoint[i][1]);
}
}
return Plugin_Handled;
}
void CreateCube(const float pos1[3], const float pos2[3])
{
TE_SetupBeamPoints(pos1, {pos1[x], pos1[y], pos2[z]}, g_BeamSprite, g_HaloSprite, 0, 66, 50.0, 2.0, 2.0, 10, 0.0, {255, 255, 0, 255}, 1000);
TE_SendToAll();
}
float[] GetDistanceEyePoint(int i)
{
float a[3], o[3], e[3] = {0.0, 0.0, 0.0};
GetClientEyePosition(i, o);
GetClientEyeAngles(i, a);
Handle hTrace = TR_TraceRayFilterEx(o, a, CONTENTS_SOLID, RayType_Infinite, CMDFilter, i);
if(TR_DidHit(hTrace) && hTrace != INVALID_HANDLE) TR_GetEndPosition(e, hTrace);
return e;
}
public bool CMDFilter(int client, int mask)
{
return client ? false : true;
}
C-подобный:
bool bVal[1024] = {true, ...}
C++:
float fVal[MAXPLAYERS+1][2][3]
C-подобный:
такой вариант:
{
{
{
0.0, 0.0, 0.0
},
{
0.0, 0.0, 0.0
}
}, ...
};
или такой
{ { {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0} }, ...}; - выдает ошибку array sizes do not match, or destination array is too small
Последнее редактирование: