Some simple solutions
They are all described with an example.
Correct Definition PHP Code:
not only PHP Code:
PHP Code:
PHP Code:
PHP Code:
1: PHP Code:
PHP Code:
PHP Code:
PHP Code:
You can add what you know. |
Re: Some simple solutions
Code:
if(cs_get_user_team(id) == CS_TEAM_T) //this may be error Code:
set_user_gravity(id, 0.8) //this may be error Code:
new p_Gravity[MAX_PLAYERS] = 0.8 //this may be error Second line is also wrong, float it's a custom tag, the default one is called Float. Again, variable should be tagged as Float, not the value(because the value it's already a float). Correct way: Code:
new Float:p_Gravity[MAX_PLAYERS] PHP Code:
PHP Code:
Code:
p_Money[id] = get_cvar_num("max_money") //this may be error Code:
#define MAX_PLAYERS 33 Code:
new p_Name[33] The usage of charsmax() is correct. Code:
set_user_health(id, get_user_health(id) + 50) Don't get me wrong, I'm not picking on you, I'm trying to explain some stuff that seems to confuse you. |
Re: Some simple solutions
Quote:
Quote:
Quote:
Code:
|
Re: Some simple solutions
Quote:
Code:
It won't throw any warning. cs_get_user_team is already tagged as CsTeams. You should take a look at how tags work. Code:
Same thing, tagging a float as a Float makes no sense. if you don't pay attention to the case, it will cause "Tag mismatch warming". You can try this PHP Code:
PHP Code:
-- Code:
First line is wrong, p_Gravityshould be tagged as Float(i.e. new Float:pGravity[MAX_PLAYERS). Also p usually stands from "pointers", so you should use f if you really want to use HN. Code:
I would also like to add something about this kind of initialization: HTML Code:
Won't throw any error if the cvar is present. Anyway, don't use cvars, use pcvars, they are faster([tt]get_pcvar_num[/tt]). Code:
What 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. For this reason, these are done with "cfg" before the game. Code:
p_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. if you do this, you will encounter a lot of errors new functuality from AMXX amxconst.inc MAX_PLAYERS 33 and and without + 1 ([MAX_PLAYERS]) Code:
While you could argue that's for readability it does not provide any performance optimization. I made the necessary explanations for you, thank you for your comment. |
Re: Some simple solutions
Quote:
Both the return value of cs_get_user_team() and CS_TEAM_T constant are tagged with CsTeams:, a tag override is redundant. Quote:
Quote:
Quote:
Code:
/** |
Re: Some simple solutions
Quote:
|
Re: Some simple solutions
Here you are not coding in c++, keep that in mind. Most of what you say is wrong.
I'm going to answer now only on what Klippy did not. Quote:
PHP Code:
PHP Code:
Quote:
If something is prone to error and could produce a crash or something just don't expose that value by cvars or enforce proper filtering on it to prevent bad values. Quote:
Edit: Quote:
PHP Code:
PHP Code:
|
Re: Some simple solutions
Quote:
I'm going to close this thread as it will probably lead to more confusion/arguing. For understanding the issues, see other posts or more info below:
|
All times are GMT -4. The time now is 13:29. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.