Is this a good way to store vehicles mods? -
DarkSkull - 17.04.2017
Hi. So I'm working on updating my vehicle system. I decided to a few things better this time. One of those is to change the way I store mods. I used the old fashion method of using 'mod1', 'mod2'... etc. To store vehicle components. I've read Vince's
post On storing Vehicle components, And I think it is a great way to do so. But I'm experimenting with something and need your opinion on it. Here is the code:
PHP код:
new string[69], mods[17][5], count1;
format(string, sizeof(string), "12345678912345678912345678912345678912345678912345678912345678912345");
print(string);
for(new i; i < sizeof(mods); i++) {
strmid(mods[i], string, count1, count1+4);
printf("mod%i: %s", i,mods[i]);
count1 = count1+4;
}
And here is the output:
The string is just an example, Instead of 1234, It would be the component id of the vehicle mod. I plan to use this as a string it self and use strval(); in the script. The code work okay, But I wanted to know some things.
Is this a good idea? What are the pros and cons of using this method?
Thanks
Re: Is this a good way to store vehicles mods? -
DarkSkull - 19.04.2017
BUMP
Re: Is this a good way to store vehicles mods? -
Marricio - 19.04.2017
Vince's method to store vehicle components is more of an example of how you should structure a SQL table to assign relations between tables and therefore, their content (rows).
There is nothing wrong with your code, I often save data that way. However, it will be much more difficult (or impossible) to query through a vehicle component list and process that data, that means you will have to do yourself in PAWN (in large systems this can be a problem).
If you're going to start your script with SQL, a much, much better practice would be what Vince explained! It is an excellent way to structure data and generally a good coding practice, you'll be able to handle data faster. It might look complex but once you get the hold of it it's going to be very easy.
Re: Is this a good way to store vehicles mods? -
[WSF]ThA_Devil - 19.04.2017
I see nothing wrong with this method, except is is quite bad to overview if you want to manually set a mod. Personally I'd use sscanf and a custom delimiter, comma for example. But to be honest, if this works for you, go with it.
Re: Is this a good way to store vehicles mods? -
DarkSkull - 19.04.2017
Quote:
Originally Posted by Marricio
Vince's method to store vehicle components is more of an example of how you should structure a SQL table to assign relations between tables and therefore, their content (rows).
There is nothing wrong with your code, I often save data that way. However, it will be much more difficult (or impossible) to query through a vehicle component list and process that data, that means you will have to do yourself in PAWN (in large systems this can be a problem).
If you're going to start your script with SQL, a much, much better practice would be what Vince explained! It is an excellent way to structure data and generally a good coding practice, you'll be able to handle data faster. It might look complex but once you get the hold of it it's going to be very easy.
|
Quote:
Originally Posted by [WSF]ThA_Devil
I see nothing wrong with this method, except is is quite bad to overview if you want to manually set a mod. Personally I'd use sscanf and a custom delimiter, comma for example. But to be honest, if this works for you, go with it.
|
Okay, Thank You Sooo Much Guys!