Raised This Month: $ Target: $400
 0% 

Solved Am I Correct ?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 11-18-2020 , 18:34   Am I Correct ?
Reply With Quote #1

So hey guys.
Yesterday, I learned about taskids.
So, I tried to work with it and did something in code.
Since, many are veterans in coding here, I wanna know that I did it correct or not.
Please examine my code and tell me if I used taskid properly or not.
Code --

Definition part --
Code:
#define TASK_MODEL               2000
set_task part --
Code:
static Float:current_time
current_time = get_gametime()

if (current_time - g_models_targettime >= g_modelchange_delay)
{
	ChangeModels(id + TASK_MODEL) 
	g_models_targettime = current_time
}
else
{
	set_task((g_models_targettime + g_modelchange_delay) - current_time, "ChangeModels", id + TASK_MODEL)
	g_models_targettime = g_models_targettime + g_modelchange_delay
}
And finally Function part --
Code:
// Set User Model
public ChangeModels(taskid)
{
	static bool:bChange;
	static cModel[24];
	static i;
	static id;
	id = taskid - TASK_MODEL;
	bChange = true;
	fm_cs_get_user_model(id, cModel, 24);
	if (!g_zombie[id])
	{
		if (get_user_flags(id) & read_flags("a"))
		{
			if (equal(cModel, "vip", 0))
			{
				bChange = false;
			}
		}
		i = 0;
		while (i < 4)
		{
			if (equal(cModel, g_cHumanModels[i], 0))
			{
				bChange = false;
			}
			i += 1;
		}
		
	}
	if (bChange)
	{
		if (!g_zombie[id])
		{
			if (get_user_flags(id) & read_flags("a"))
			{
				set_user_info(id, "model", g_cAdminModels[random_num(0, sizeof g_cAdminModels - 1)])
			}
			else
			{
				set_user_info(id, "model", g_cHumanModels[random_num(0, sizeof g_cHumanModels - 1)])
			
			}
			if (g_survivor[id])
			{
				set_user_info(id, "model", g_cSurvivorModels[random_num(0, sizeof g_cSurvivorModels - 1)])
			}
			if (g_sniper[id])
			{
				set_user_info(id, "model", g_cSniperModels[random_num(0, sizeof g_cSniperModels - 1)])
			}
			if (g_zadoc[id])
			{
				set_user_info(id, "model", g_cZadocModels[random_num(0, sizeof g_cZadocModels - 1)])
			}
		}
		else
		{
			if (g_nemesis[id])
			{
				set_user_info(id, "model", g_cNemesisModels[random_num(0, sizeof g_cNemesisModels - 1)])
			}
			if (g_assassin[id])
			{
				set_user_info(id, "model", g_cAssassinModels[random_num(0, sizeof g_cAssassinModels - 1)])
			}
			if (g_bombardier[id])
			{
				set_user_info(id, "model", g_cBombardierModels[random_num(0, sizeof g_cBombardierModels - 1)])
			}
			else
			{
				set_user_info(id, "model", "zombie_source")
			}
		}
	}
	return 0;
}
Please dont judge me, I am still learning.

Last edited by Abhinash; 11-20-2020 at 09:49.
Abhinash is offline
 



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 02:45.


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