MySQL structure
#1

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?
Reply
#2

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...
Reply
#3

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.
Reply
#4

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
Reply
#5

And bam I'm confused. Why would Pscore and Pmoney be in the carstring?
Reply
#6

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?
Reply
#7

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.
Reply
#8

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.
Reply
#9

Okay going to try these now. Thanks very much guys, hopefully this will fix that other bug I was having in my other post.
Reply
#10

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.
Reply
#11

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.
Reply
#12

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...
Reply
#13

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.
Reply
#14

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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)