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

Zombie Plague 4.3 fix5a issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
scoty
Member
Join Date: Nov 2015
Old 01-03-2022 , 14:58   Zombie Plague 4.3 fix5a issue
Reply With Quote #1

server crash when i check the logs i get this

L 01/03/2022 - 20:51:13: Invalid index 0 (count: 0)
L 01/03/2022 - 20:51:13: [AMXX] Displaying debug trace (plugin "zombie_plague.amxx", version "4.3 Fix5a")
L 01/03/2022 - 20:51:13: [AMXX] Run time error 10: native error (native "ArrayGetString")
L 01/03/2022 - 20:51:13: [AMXX] [0] zombie_plague.sma::ambience_sound_effects (line 7864)
scoty is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-04-2022 , 05:50   Re: Zombie Plague 4.3 fix5a issue
Reply With Quote #2

This has nothing to do with the server crashing but its recommended to fix the error.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
scoty
Member
Join Date: Nov 2015
Old 01-04-2022 , 10:12   Re: Zombie Plague 4.3 fix5a issue
Reply With Quote #3

thank you for your response, thats why im here btw asking to fix this error
scoty is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-04-2022 , 11:15   Re: Zombie Plague 4.3 fix5a issue
Reply With Quote #4

Maybe post the code so we can actually see what's going on?

I'm assuming the array is empty or you're trying to access it before it's created.
__________________

Last edited by OciXCrom; 01-04-2022 at 11:16.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-04-2022 , 11:16   Re: Zombie Plague 4.3 fix5a issue
Reply With Quote #5

You have to post some code, do not expect anyone to go into zombie plague 4.3 thread, download, and scroll through 10,000 lines to find out where that error happened.

Anyway, I will assume that ambience_sound_effects is like this

Code:
// Ambience Sound Effects Task
public ambience_sound_effects(taskid)
{
	// Play a random sound depending on the round
	static sound[64], iRand, duration
	
	if (g_nemround) // Nemesis Mode
	{
		iRand = random_num(0, ArraySize(sound_ambience2) - 1)
		ArrayGetString(sound_ambience2, iRand, sound, charsmax(sound))
		duration = ArrayGetCell(sound_ambience2_duration, iRand)
	}
	else if (g_survround) // Survivor Mode
	{
		iRand = random_num(0, ArraySize(sound_ambience3) - 1)
		ArrayGetString(sound_ambience3, iRand, sound, charsmax(sound))
		duration = ArrayGetCell(sound_ambience3_duration, iRand)
	}
	else if (g_swarmround) // Swarm Mode
	{
		iRand = random_num(0, ArraySize(sound_ambience4) - 1)
		ArrayGetString(sound_ambience4, iRand, sound, charsmax(sound))
		duration = ArrayGetCell(sound_ambience4_duration, iRand)
	}
	else if (g_plagueround) // Plague Mode
	{
		iRand = random_num(0, ArraySize(sound_ambience5) - 1)
		ArrayGetString(sound_ambience5, iRand, sound, charsmax(sound))
		duration = ArrayGetCell(sound_ambience5_duration, iRand)
	}
	else // Infection Mode
	{
		iRand = random_num(0, ArraySize(sound_ambience1) - 1)
		ArrayGetString(sound_ambience1, iRand, sound, charsmax(sound))
		duration = ArrayGetCell(sound_ambience1_duration, iRand)
	}
	
	// Play it on clients
	PlaySound(sound)
	
	// Set the task for when the sound is done playing
	set_task(float(duration), "ambience_sound_effects", TASK_AMBIENCESOUNDS)
}
You got the error because the code tried to access an array that is empty for some reason.
To fix that, check if the array has any item.

Code:
if (g_nemround) // Nemesis Mode {     new soundCount = ArraySize(sound_ambience2)     if (soundCount > 0)     {         iRand = random(soundCount)         ArrayGetString(sound_ambience2, iRand, sound, charsmax(sound))         if (0 <= iRand < ArraySize(sound_ambience2_duration))         {             duration = ArrayGetCell(sound_ambience2_duration, iRand)         }     } }

And check if any sound was selected

Code:
if (sound[0]) {     // Play it on clients     PlaySound(sound)         // Set the task for when the sound is done playing     set_task(float(duration), "ambience_sound_effects", TASK_AMBIENCESOUNDS) }

Since you're going to use this multiple times, wrap everything into one function for two reasons:
- Makes it a lot more readable and organized
- If something goes wrong, it will be easier to fix

Code:
GetRandomSoundAndDuration(Array:sounds, sound[], maxLen, Array:durations, &duration)
{
	new count = ArraySize(sounds)

	if (count == 0)
	{
		return false
	}

	new rand = random(count)

	if (!(0 <= rand < ArraySize(durations)))
	{
		return false
	}

	ArrayGetString(sounds, rand, sound, maxLen)
	duration = ArrayGetCell(durations, rand)

	return true
}
Now all of this
Code:
// Ambience Sound Effects Task
public ambience_sound_effects(taskid)
{
	// Play a random sound depending on the round
	new sound[64], iRand, duration

	if (g_nemround) // Nemesis Mode
	{
		new soundCount = ArraySize(sound_ambience2)

		if (soundCount > 0)
		{
			iRand = random(soundCount)
			ArrayGetString(sound_ambience2, iRand, sound, charsmax(sound))

			if (0 <= iRand < ArraySize(sound_ambience2_duration))
			{
				duration = ArrayGetCell(sound_ambience2_duration, iRand)
			}

		}
	}
	else if (g_survround) // Survivor Mode
	{
		new soundCount = ArraySize(sound_ambience3)

		if (soundCount > 0)
		{
			iRand = random(soundCount)
			ArrayGetString(sound_ambience3, iRand, sound, charsmax(sound))

			if (0 <= iRand < ArraySize(sound_ambience3_duration))
			{
				duration = ArrayGetCell(sound_ambience3_duration, iRand)
			}

		}
	}
	else if (g_swarmround) // Swarm Mode
	{
		new soundCount = ArraySize(sound_ambience4)

		if (soundCount > 0)
		{
			iRand = random(soundCount)
			ArrayGetString(sound_ambience4, iRand, sound, charsmax(sound))

			if (0 <= iRand < ArraySize(sound_ambience4_duration))
			{
				duration = ArrayGetCell(sound_ambience4_duration, iRand)
			}

		}
	}
	else if (g_plagueround) // Plague Mode
	{
		new soundCount = ArraySize(sound_ambience5)

		if (soundCount > 0)
		{
			iRand = random(soundCount)
			ArrayGetString(sound_ambience5, iRand, sound, charsmax(sound))

			if (0 <= iRand < ArraySize(sound_ambience5_duration))
			{
				duration = ArrayGetCell(sound_ambience5_duration, iRand)
			}

		}
	}
	else // Infection Mode
	{
		new soundCount = ArraySize(sound_ambience1)

		if (soundCount > 0)
		{
			iRand = random(soundCount)
			ArrayGetString(sound_ambience1, iRand, sound, charsmax(sound))

			if (0 <= iRand < ArraySize(sound_ambience1_duration))
			{
				duration = ArrayGetCell(sound_ambience1_duration, iRand)
			}

		}
	}

	if (sound[0])
	{
		// Play it on clients
		PlaySound(sound)
		
		// Set the task for when the sound is done playing
		set_task(float(duration), "ambience_sound_effects", TASK_AMBIENCESOUNDS)
	}
}
Will simply become this

Code:
// Ambience Sound Effects Task
public ambience_sound_effects(taskid)
{
	// Play a random sound depending on the round
	new sound[64], duration
	
	if (g_nemround) // Nemesis Mode
	{
		GetRandomSoundAndDuration(sound_ambience2, sound, charsmax(sound), sound_ambience2_duration, duration)
	}
	else if (g_survround) // Survivor Mode
	{
		GetRandomSoundAndDuration(sound_ambience3, sound, charsmax(sound), sound_ambience3_duration, duration)
	}
	else if (g_swarmround) // Swarm Mode
	{
		GetRandomSoundAndDuration(sound_ambience4, sound, charsmax(sound), sound_ambience4_duration, duration)
	}
	else if (g_plagueround) // Plague Mode
	{
		GetRandomSoundAndDuration(sound_ambience5, sound, charsmax(sound), sound_ambience5_duration, duration)
	}
	else // Infection Mode
	{
		GetRandomSoundAndDuration(sound_ambience1, sound, charsmax(sound), sound_ambience1_duration, duration)
	}

	// if any sound was selected
	if (sound[0])
	{
		// Play it on clients
		PlaySound(sound)
		
		// Set the task for when the sound is done playing
		set_task(float(duration), "ambience_sound_effects", TASK_AMBIENCESOUNDS)
	}
}

GetRandomSoundAndDuration(Array:sounds, sound[], maxLen, Array:durations, &duration)
{
	new count = ArraySize(sounds)

	if (count == 0)
	{
		return false
	}

	new rand = random(count)

	if (!(0 <= rand < ArraySize(durations)))
	{
		return false
	}

	ArrayGetString(sounds, rand, sound, maxLen)
	duration = ArrayGetCell(durations, rand)

	return true
}
That will fix just the log error, this isn't the cause of why your server is crashing. If it is a plugin problem, you'll have to disable all of them and keep testing one by one until you find it out.
__________________








CrazY. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-04-2022 , 13:29   Re: Zombie Plague 4.3 fix5a issue
Reply With Quote #6

Whats the crash error code ?
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 13:59.


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