MySQL structure -
JackBurgani - 04.05.2013
So when making the table, I want each player to store values for score, money, robskill, coprank, bankcash, and store up to 9 vehicles. Is there a better way to do the 9 vehicles instead of having a column for vehicle1x, vehicle1y, vehicle 1z, angle1, 1color1, 1color2, all the way to 9color1, 9color2, ect?
Re: MySQL structure -
IceCube! - 04.05.2013
If your using an old file system write and load from strings, so...
Format(Car1string, sizeof(...), "%i|%i"' PScore, Pmoney); then save that as one line...
Re: MySQL structure -
Chenko - 04.05.2013
I'd say the best way is to have another Mysql database for vehicles and link the vehicle to the player somehow. I'd suggest having a vehicle variable like playerSQLID where you store the SQLID of the player who owns the vehicle.
Re: MySQL structure -
Wesley221 - 04.05.2013
Create a new table for just the vehicles. Only thing you have to add extra, is the username.
So it will be like vehicleid, owner, vehiclemodel, x, y, z, a, color, color, respawn
Re: MySQL structure -
JackBurgani - 04.05.2013
And bam I'm confused. Why would Pscore and Pmoney be in the carstring?
Re: MySQL structure -
JackBurgani - 04.05.2013
Quote:
Originally Posted by Wesley221
Create a new table for just the vehicles. Only thing you have to add extra, is the username.
So it will be like vehicleid, owner, vehiclemodel, x, y, z, a, color, color, respawn
|
Okay that makes a lot of sense. I was thinking about making another table but wasn't quit sure how I'd link the vehicles to the players.. So for owner do you think it'd be best to do it by ID or name?
Re: MySQL structure -
IceCube! - 04.05.2013
It was an example, I don't read you were using MySQL, I suggest numbering your vehicles in the MySQL table.. Then in the player table say Vehicle1 - 23
The. Search for vehicle 23 in the car table... As it quicker than comparing strings in MySQL or so I've been told.
Re: MySQL structure -
Chenko - 04.05.2013
You can store the player SQLID or name on the vehicle or you can store the vehicle SQLID on the player and spawn the car when the player logs in. Your best bet would be to store an SQLID somewhere as that would be much more reliable than just the players name.
Re: MySQL structure -
JackBurgani - 04.05.2013
Okay going to try these now. Thanks very much guys, hopefully this will fix that other bug I was having in my other post.
Re: MySQL structure -
Wesley221 - 04.05.2013
You can either do what they say above here, or just save it through the players name. Not by playerid, since your playerid will always be different.
Re: MySQL structure -
RajatPawar - 04.05.2013
You could store the positions as arrays, which would reduce 9 * 3 = 27 variables to only 9 arrays of 3 (4) cells each. There is a function for fetching arrays, in BlueG's plugin, however it's a bit of a pain in the arse. (
http://stackoverflow.com/questions/2...rrays-in-mysql)
You can try that if you like, or I am sure there is a tutorial here to connect two tables, I think Vince or someone wrote it.
Re: MySQL structure -
IceCube! - 04.05.2013
Playerid would be stupid they were going by the Belief he had numbered each players account so if 100 would registered the next account. Would be 101. Which is what big corporations do, he never said this which is why I never suggested that way. By numbering the vehicles and placing the I'd of the vehicle in the players account, he can choose weather to spawn that vehicle or not as we don't know what he plans to do...
Re: MySQL structure -
JackBurgani - 04.05.2013
Quote:
Originally Posted by Wesley221
You can either do what they say above here, or just save it through the players name. Not by playerid, since your playerid will always be different.
|
By playerid I meant my own player identification I use in MySQL, regardless everything is fine now, works like it should. Thanks again guys.
Re: MySQL structure -
ReV. - 04.05.2013
Quote:
Originally Posted by Wesley221
You can either do what they say above here, or just save it through the players name. Not by playerid, since your playerid will always be different.
|
Or better yet.. create a "registration ID" for the user.
The best way to go about this would be to create another table for things like vehicles as someone already mentioned.