AMX Mod X Plugin Approver
|
![Old](images/statusicon/post_old.svg)
07-18-2008
, 11:46
Re: Point System 1.4.4 || [6/18/2008]
|
#1
|
Next round.
point_system.sma
line 389 : You can add 'clamp()' or 'max()' ( if you want to check the min value only ) function to avoid people to store a negative/null/too high value.
Code:
set_task(get_pcvar_float(ps_adv_time), "fwd_adv_help", _, _, _, "b");
2 exemples ->
Code:
set_task(clamp(get_pcvar_float(ps_adv_time), MyMinValue, MyMaxValue), "fwd_adv_help", _, _, _, "b");
Code:
set_task(max(MyMinValue, get_pcvar_float(ps_adv_time)), "fwd_adv_help", _, _, _, "b");
line 404 : This line alone does nothing :
Code:
clamp(get_pcvar_num(ps_adv_time), 50, 250);
As I've said, you should write :
Code:
set_pcvar_num(ps_adv_time, clamp(get_pcvar_num(ps_adv_time), 50, 250) );
line 497 : client_disconnect() / gb_user_alive You should add into this function, that, otherwise you will got unexpected results :
Code:
gb_user_alive[id] = false;
lines 955, 983 : round_won_t() / round_won_ct() Again, don't create var into a for(). Just create one time before the for().
Code:
for(new i = 0; i <= num; ++i)
{
new plr = players[i];
line ~1000 : chameleon() Use a switch here to avoid to call 2 times [i]fm_get_user_team()|/i] if team is CT. Also, no need to create the 'num' var, too..
Code:
switch( fm_get_user_team(id) )
{
case CS_TEAM_T :
{
switch(random_num(1, 4))
{
case 1: fm_set_user_model(id, "sas");
case 2: fm_set_user_model(id, "gign");
case 3: fm_set_user_model(id, "gsg9");
case 4: fm_set_user_model(id, "urban");
}
}
case CS_TEAM_CT :
{
switch(random_num(1, 4))
{
case 1: fm_set_user_model(id, "leet");
case 2: fm_set_user_model(id, "terror");
case 3: fm_set_user_model(id, "arctic");
case 4: fm_set_user_model(id, "guerilla");
}
}
}
I would prefer to do somethink like ( but really it's user preference here ). It takes less place. ![Mr. Green](images/smilies/mrgreen.gif)
Also, for me, that's more neat since it's constant values.
Code:
new const g_HumanModels_T [][] = { "sas", "gign", "gsg9", "urban" };
new const g_HumanModels_CT[][] = { "leet", "terror", "arctic", "guerilla" };
// [...]
switch( fm_get_user_team(id) )
{
case CS_TEAM_T : fm_set_user_model(id, g_HumanModels_T [random_num(0, 3)] );
case CS_TEAM_CT : fm_set_user_model(id, g_HumanModels_CT[random_num(0, 3)] );
}
ps/cpm.inl
plugin_precache() : - 'static' is useless here.
- Don't create var in the for()
comds.inl
Something like : if ( equali(mystring[0], "") ) is exactly the same than if( !mystring[0] ) but better since it doesn't use native. You should change.
stocks.inl
About is_ps_on() :
is_plugin_loaded() and cvar_exists() is totaly useless. Also this function is called so often, and each time you check that. I can't believe lol.
Something like would be enough :
Code:
stock bool:is_ps_on()
{
if(!get_pcvar_num(ps_toggle) || get_playersnum() < get_pcvar_num(ps_players))
return false;
return true;
}
About : message_begin(MSG_TYPE, get_user_msgid("SayText"), _, id);
Either create a global var abobe plugin_init() either you can do :
Code:
static iSayText;
if( !iSayText ) iSayText = get_user_msgid("SayText");
message_begin(MSG_TYPE, iSayText, _, id)
As additional notes, I don't like cvars. I prefer using a global command which is better to manage easily the customization without using a lot 'get_pcvar_*' native.
If I have to use it, I will try at least to cache some cvars which are called very often.
That's all for the moment. There are so many optimizations/changements to do again, but it needs to understand more deeply the plugin and i'm lazy to do that atm.
__________________
|
|