Quote:
Originally Posted by ezio_auditore
now what part in the previous code is bad...
as per DavidJr's explaination, a bad code is something which can be coded by anyone else...
Now, Dare.Devil has suggested a harder code, and the last reply is much harder.
So, Connor my friend, what exactly is "baldy coded"
|
Something like:
PHP Code:
new HP = get_user_health(ent)
if (HP >= 100)
{
set_es ( es_handle, ES_RenderColor, { 51, 168, 87 } )
}
else if (HP < 100 && HP >= 75)
{
set_es ( es_handle, ES_RenderColor, { 51, 168, 87 } )
}
else if (HP < 75 && HP >= 50)
{
set_es ( es_handle, ES_RenderColor, { 5, 97, 212 } )
}
else if (HP < 50 && HP >= 25)
{
set_es ( es_handle, ES_RenderColor, { 255, 189, 59 } )
}
else if (HP < 25)
{
set_es ( es_handle, ES_RenderColor, { 255, 0, 0 } )
}
You can optimize like this:
PHP Code:
new HP = get_user_health(ent)
if (HP >= 75)
{
set_es ( es_handle, ES_RenderColor, { 51, 168, 87 } )
}
else if (HP >= 50)
{
set_es ( es_handle, ES_RenderColor, { 5, 97, 212 } )
}
else if (HP >= 25)
{
set_es ( es_handle, ES_RenderColor, { 255, 189, 59 } )
}
else
{
set_es ( es_handle, ES_RenderColor, { 255, 0, 0 } )
}
And don't use too much check or native inside a forward which is called many times (like AddToFullPack), it's faster and better to use a global variable instead of a native function.
That's what I think about "badly coded".
__________________