[Include] Dynamic CCTV
#10

There are some things you should think about

1. You should use static and stock.
For example if someone only wanna use 1 or 2 functions, he dont need the others.
So use stock for Variables and Functions if you write an Include.
The other thing is, imagine he uses the same variable name like u.
Then it comes to an Error, so that this never happens use static so your include has his own scope

2. Huge Space Wasting
PHP код:
new
    
FloatCCTV_oldX[MAX_PLAYERS],
    
FloatCCTV_oldY[MAX_PLAYERS],
    
FloatCCTV_oldZ[MAX_PLAYERS],
    
FloatCCTV_oldAngle[MAX_PLAYERS],
    
CCTV_oldSkin[MAX_PLAYERS],
    
CCTV_oldVW[MAX_PLAYERS],
    
CCTV_oldInterior[MAX_PLAYERS],
    
inCCTV[MAX_PLAYERS],
    
CCTV_ID[MAX_PLAYERS],
    
CCTV_inEditing[MAX_PLAYERS]; 
10 (there are 10 Vars)*500 (MAX_PLAYERS)*4 (4Bytes per Cell)
= 20.000Bytes = ~19.53 KB

So...this isnt a complex system and an user wanna use it and instant waste 19.53 KB...
In Pawn this is much space and most time this all doesn't get used.
So it is wasted.
Temporary Vars, when u just wanna save a var over a short time, for example Dialog choosing, or for commands and then using dialogs, it is perfect to use PVars, cause you can delete it right after you used it and save a lot of space.
For other things it is neat to use Propertys, because if you do this, you can use as much as your Server RAM is big
And most of your vars are only for a short distance so use PVar, and delete it right after you used it

3. Why use MySQL?
MySQL can do huge problems for not so experienced users or with plugins and microsoft or linux.
So just use SQLite so, the user doesn't need to make a huge thing about your include.
Try to make it smart, so that it runs perfect

4. Injections
There are some open bugs in your code
For example if you save the vars, you use for the name %s, but if i write an injection in the name, so yeah you right load it
So you should use %q instead or escape the string

5. Defines
At the End of the Include you should undefine your defines.
For example
PHP код:
#undef MAX_CCTV_NAME 
And you should do the start like this:
PHP код:
#if !defined MAX_CCTV
    #define MAX_CCTV 100
#endif 
So that you can redefine it from the Script and dont need to edit your include


So far some points, but all in all it isn't that bad
Good that you use Streamer functions and an Iteration Include

And nice idea, so good job anyway
Reply


Messages In This Thread
Dynamic CCTV System (MySQL, foreach, ZCMD) - by IFilip - 26.08.2016, 23:00
Re: Dynamic CCTV - by IFilip - 26.08.2016, 23:35
Re: Dynamic CCTV - by IFilip - 27.08.2016, 10:50
Re: Dynamic CCTV - by TayFunCZE - 27.08.2016, 11:17
Re: Dynamic CCTV - by CoachCarter - 28.08.2016, 13:44
Re: Dynamic CCTV - by Ritzy2K - 28.08.2016, 14:44
Re: Dynamic CCTV - by XHunterZ - 28.08.2016, 15:22
Re: Dynamic CCTV - by IFilip - 29.08.2016, 00:24
Re: Dynamic CCTV - by MaazS - 29.08.2016, 00:49
Re: Dynamic CCTV - by Kaliber - 29.08.2016, 12:47
Respuesta: Dynamic CCTV - by EdinsonWalker - 30.08.2016, 02:53
Re: Dynamic CCTV - by MaazS - 30.08.2016, 23:34
Re: Dynamic CCTV - by SetPlayerNameTag - 27.08.2017, 01:45
Re: Dynamic CCTV - by Xeon™ - 27.08.2017, 03:02
Re: Dynamic CCTV - by SetPlayerNameTag - 28.08.2017, 02:58
Re: Dynamic CCTV - by Meller - 28.08.2017, 06:52

Forum Jump:


Users browsing this thread: 2 Guest(s)