[Solved] Getting data into MySQL table easier. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Solved] Getting data into MySQL table easier. (
/showthread.php?tid=122904)
[Solved] Getting data into MySQL table easier. -
Miguel - 23.01.2010
I've saved 591 vehicles using /save command and added them into my GM, but now i'm moving to mysql, and i need to get:
pawn Код:
m // model ID
x
y
z
a // angle
c // color 1
c2 // color 2
r // respawn delay
into a table. This table has:
I made a command which had a loop and got all the 591 IDs into the table:
pawn Код:
CMD:auto(playerid, params[])
{
#pragma unused params
new
query[50];
for(new i = 0; i < 591; i ++)
{
format(query, sizeof(query), "INSERT INTO `vehicles` (ID) VALUE ('%d')", i);
mysql_query(query);
}
return 1;
}
But i don't know how to get x y z a c c and r into the table faster (as that command). Can anyone help me?
Re: Getting data into MySQL table easier. -
Chaprnks - 24.01.2010
After i, add the location of those variables, since you did not include where they are from. (Ex: CarInfo enum)
pawn Код:
CMD:auto(playerid, params[])
{
#pragma unused params
new query[50];
for(new i = 0; i < 591; i ++)
{
format(query, sizeof(query), "INSERT INTO `vehicles` (ID) VALUE (%d,%f,%f,%f,%f,%d,%d,%d)", i,);
mysql_query(query);
}
return 1;
}
Re: Getting data into MySQL table easier. -
Miguel - 24.01.2010
I got it solved... i made a loop and used an array:
pawn Код:
new Float:Veh[590][4] =
{
{x,y,z,a},
.
.
.
};
pawn Код:
CMD:saveee(playerid, params[])
{
#pragma unused params
new
query[];
for(new i = 0; i < 591; i ++)
{
format(query, sizeof(query), "UPDATE `table` SET x='%.4f', y='%.4f', z='%.4f', a='%.4f' WHERE ID='%d'", Veh[i][0], Veh[i][1], Veh[i][2], Veh[i][3], i);
mysql_query(query);
printf("%d", i); // this was important
}
return 1;
}
Thanks!