View Single Post
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 11-19-2020 , 06:35   Re: Invalid index 0 (count 0) help me fix it
Reply With Quote #9

Quote:
Originally Posted by Napoleon_be View Post
It's probably because you're not properly retrieving/storing your info. Show us what u tried with ArrayPushString
This is how I am doing with ArrayPushString --
Code:
new i
for ( i = 0; i < sizeof g_cHumanModels; i++ )
    {
          ArrayPushString(model_human, i, g_cHumanModels[i])
    }
And this is the retrieval part -
Code:
// Custom models stuff
	static currentmodel[32], tempmodel[32], already_has_model, i, iRand, size
	already_has_model = false
	
	// Get current model for comparing it with the current one
	fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
	
	// Set the right model, after checking that we don't already have it
	if (get_user_flags( id ) & read_flags( "a" ) )
	{
		size = ArraySize(model_admin_human)
		for (i = 0; i < size; i++)
		{
			ArrayGetString(model_admin_human, i, tempmodel, charsmax(tempmodel))
			if (equal(currentmodel, tempmodel)) already_has_model = true
		}
		
		if (!already_has_model)
		{
			iRand = random_num(0, size - 1)
			ArrayGetString(model_admin_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
			if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_admin_human, iRand))
		}
	}
	else
	{
		size = ArraySize(model_human)
		for (i = 0; i < size; i++)
		{
			ArrayGetString(model_human, i, tempmodel, charsmax(tempmodel))
			if (equal(currentmodel, tempmodel)) already_has_model = true
		}
		
		if (!already_has_model)
		{
			iRand = random_num(0, size - 1)
			ArrayGetString(model_human, iRand, g_playermodel[id], charsmax(g_playermodel[]))
			if (g_set_modelindex_offset) fm_cs_set_user_model_index(id, ArrayGetCell(g_modelindex_human, iRand))
		}
	}
	
	// Need to change the model?
	if (!already_has_model)
	{
		// An additional delay is offset at round start
		// since SVC_BAD is more likely to be triggered there
		if (g_newround)
		set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
		else
		fm_user_model_update(id+TASK_MODEL)
	}

Last edited by Abhinash; 11-19-2020 at 06:38.
Abhinash is offline