Raised This Month: $51 Target: $400
 12% 

Solved Game crashes when I go past 47 cases


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 11-21-2018 , 10:32   Game crashes when I go past 47 cases
Reply With Quote #1

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;
}

Last edited by manicogaming; 11-04-2020 at 14:47.
manicogaming is offline
Mrs cheng
Member
Join Date: Mar 2017
Old 11-22-2018 , 11:34   Re: Game crashes when I go past 47 cases
Reply With Quote #2

You try to delete the local code blocks in case48 and case49.See if it will cause the game to crash.
Mrs cheng is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 11-23-2018 , 06:35   Re: Game crashes when I go past 47 cases
Reply With Quote #3

Quote:
Originally Posted by Mrs cheng View Post
You try to delete the local code blocks in case48 and case49.See if it will cause the game to crash.
I did what you said, but the game still crashes.
manicogaming is offline
Mrs cheng
Member
Join Date: Mar 2017
Old 11-23-2018 , 07:08   Re: Game crashes when I go past 47 cases
Reply With Quote #4

If every local block is empty, how would it be?
Mrs cheng is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 11-23-2018 , 07:29   Re: Game crashes when I go past 47 cases
Reply With Quote #5

Quote:
Originally Posted by Mrs cheng View Post
If every local block is empty, how would it be?
It no longer crashes.
But what I find weird in this is that I have on other types of items up to 200 cases but it doesn't crash.
manicogaming is offline
Squallkins
AlliedModders Donor
Join Date: Mar 2005
Old 11-25-2018 , 16:27   Re: Game crashes when I go past 47 cases
Reply With Quote #6

Why don't you put the items in a text file instead of having so many cases. Would be easier to add/remove items as well.
Squallkins is offline
manicogaming
AlliedModders Donor
Join Date: Aug 2014
Old 11-25-2018 , 17:01   Re: Game crashes when I go past 47 cases
Reply With Quote #7

Quote:
Originally Posted by Squallkins View Post
Why don't you put the items in a text file instead of having so many cases. Would be easier to add/remove items as well.
And how could I do that, as I'm a beginner in SourcePawn and I've just been editing some simple things in plugins, could you help me with that?
manicogaming is offline
Squallkins
AlliedModders Donor
Join Date: Mar 2005
Old 11-25-2018 , 22:13   Re: Game crashes when I go past 47 cases
Reply With Quote #8

https://wiki.alliedmods.net/KeyValue...eMod_Scripting)
Squallkins is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode