Correct Definition
Code: Select all
if(cs_get_user_team(id) == CS_TEAM_T) //this may be error
if(cs_get_user_team(id) == CsTeams:CS_TEAM_T) //the best way to be sure Correct Numerical Data TypesIt won't throw any warning. cs_get_user_team is already tagged as CsTeams. You should take a look at how tags work.
not only
Code: Select all
set_user_gravity(id, 0.8) //this may be error
set_user_gravity(id, Float:0.8) //the best way to be sure but alsoSame thing, tagging a float as a Float makes no sense.
Code: Select all
new p_Gravity[MAX_PLAYERS] = 0.8 //this may be error
new p_Gravity[MAX_PLAYERS] = float:0.8 //the best way to be sure ("float" for defination, "Float" for function - upper case) Clean Cvar UsageI would also like to add something about this kind of initialization:
This won't set all array cells to 1, only the first one(var[0] is 1, but var[1],var[2], ... are 0). If you want to initialize the entire array with 1, you should do:Code: Select all
new var[33] = 1
Code: Select all
new var[33] = {1, ...}
Code: Select all
p_Money[id] = get_cvar_num("max_money") //this may be error correct wayWon't throw any error if the cvar is present. Anyway, don't use cvars, use pcvars, they are faster(get_pcvar_num).
Code: Select all
#define MAX_PLAYERS 33
new cvar_max_money
new p_Money[MAX_PLAYERS]
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
cvar_max_money = get_cvar_num("max_money")
}
public client_connect(id) {
p_Money[id] = cvar_max_money
} Clean AlgorithmWhat you did here is basically to cache the cvar value, so if it's changed in-game it won't take affect until the next map change.
1:
Code: Select all
new p_Name[33]
get_user_name(id, p_Name, 33) top_Name should be 32, not 33 and in get_user_name you should put size - 1, so 31. Indexing pName by MAX_PLAYERS is confusing. You would do that when you want to have an array for players, but here you are using a char array to store the name of ONLY ONE player at a time. So just put 32.
The usage of charsmax() is correct.
Code: Select all
#define MAX_PLAYERS 33
new p_Name[MAX_PLAYERS]
get_user_name(id, p_Name, charsmax(p_Name)) Code: Select all
set_user_health(id, get_user_health(id) + 50)
set_user_armor(id, get_user_armor(id) + 50)
p_UsrXP[id] = p_UserXP[id] + 50 Code: Select all
new i_Val = 50
set_user_health(id, get_user_health(id) + i_Val)
set_user_armor(id, get_user_armor(id) + i_Val)
p_UsrXP[id] += i_Val While you could argue that's for readability it does not provide any performance optimization.
Don't get me wrong, I'm not picking on you, I'm trying to explain some stuff that seems to confuse you.
