Basically when I add more than 47 cases to this script the game crashes to desktop without any error logs.
This doesn't crash the game:
Code:
int rnd = GetRandomInt(0,47);
...
case 46:
{
CreateHat(client, 940, 11, 10); //Ghostly Gibus
}
case 47:
{
CreateHat(client, 941, 11, 31); //The Skull Island Topper
}
But when I add more than 48 cases it crashes to the desktop instantly:
Code:
int rnd = GetRandomInt(0,49);
...
case 47:
{
CreateHat(client, 941, 11, 31); //The Skull Island Topper
}
case 48:
{
CreateHat(client, 30357, 11); //Dark Falkirk Helm
}
case 49:
{
CreateHat(client, 30357, 5); //Dark Falkirk Helm
}
This is the "CreateHat" function:
Code:
bool CreateHat(int client, int itemindex, int quality, int level = 0)
{
int hat = CreateEntityByName("tf_wearable");
if (!IsValidEntity(hat))
{
return false;
}
char entclass[64];
GetEntityNetClass(hat, entclass, sizeof(entclass));
SetEntData(hat, FindSendPropInfo(entclass, "m_iItemDefinitionIndex"), itemindex);
SetEntData(hat, FindSendPropInfo(entclass, "m_bInitialized"), 1);
SetEntData(hat, FindSendPropInfo(entclass, "m_iEntityQuality"), quality);
if (level)
{
SetEntData(hat, FindSendPropInfo(entclass, "m_iEntityLevel"), level);
}
else
{
SetEntData(hat, FindSendPropInfo(entclass, "m_iEntityLevel"), GetRandomInt(1,100));
}
DispatchSpawn(hat);
SDKCall(g_hWearableEquip, client, hat);
return true;
}