How to load and save vehicles from MySQL R38? -
TheNerka - 09.09.2014
How to load and save vehicles from MySQL R38?
My Enum:
Код:
enum vData
{
Fullname[128],
Number,
Model,
Float:PositionX,
Float:PositionY,
Float:PositionZ,
Float:PositionA,
Float:Health,
Color1,
Color2,
Mod1,
Mod2,
Mod3,
Mod4,
Mod5,
Mod6,
Mod7,
Mod8,
Mod9,
Mod10,
Mod11,
Mod12,
Mod13,
Mod14,
Mod15,
Mod16,
Mod17,
Trunk,
DoorLock,
Bonnet,
Engine,
Lights,
Alarm,
}
new VehicleData[MAX_VEHICLES][vData];
Fullname is car owner name
Re: How to load and save vehicles from MySQL R38? -
Ox1gEN - 09.09.2014
For strings(In your case number and name [Add a string length to Number]) you need to use cache_get_field_content(0, "YOUR-COLUMN-IN-TABLE", -YOUR-VARIABLE-TO-STORE-IT-IN-, -LENGTH-OF-VARIABLE-);
For floats you do cache_get_field_content_float find more about it in the wiki cause it's different from the regular get content and cache_get_field_content_int it's used the same as float but is different than the float one.
This is bassicly how to load and to save just use a simple UPDATE command.
e.g:
pawn Код:
CMD:YOUR-DESIRED-COMMAND(playerid, param[])
{
new query[128];
new Float:x, Float:y, Float:z;
new veh = GetPlayerVehicleID(playerid);
GetVehiclePos(veh, x, y, z);
mysql_format(-YOUR-CONNECTION-, query, sizeof(query), "UPDATE vehicles SET PositionX = %f, PositionY = %f, PositionZ = %f WHERE VehicleID = %d", x, y, z, -YOUR-VARIABLE-TO-FETCH-THE-VEHICLE-ID);
mysql_pquery(-YOUR-CONNECTION-, query);
return 1;
}
Of-course you have to change most of it but this is just a small example.
EDIT: BTW I've used a command here but the whole point is for you to look at the mysql things and at the whole code itself, because this can be used at alot of places(e.g - at a saving vehicles stock).
Re: How to load and save vehicles from MySQL R38? -
TheNerka - 10.09.2014
im scripted with auto load/ save car system
my save/load
Код:
forward LoadVehicleData();
public LoadVehicleData()
{
AntiDeAMX();
for(new vehicleid = 1;vehicleid<100;vehicleid++)
{
cache_get_field_content(0, "Fullname", VehicleData[vehicleid][Fullname], Mysql_users, 129);
cache_get_field_content(0, "Number", VehicleData[vehicleid][Number], Mysql_users, 126);
VehicleData[vehicleid][Model] = cache_get_field_content_int(0, "Model", Mysql_users);
VehicleData[vehicleid][PositionX] = cache_get_field_content_float(0, "PositionX", Mysql_users);
VehicleData[vehicleid][PositionY] = cache_get_field_content_float(0, "PositionY", Mysql_users);
VehicleData[vehicleid][PositionZ] = cache_get_field_content_float(0, "PositionZ", Mysql_users);
VehicleData[vehicleid][PositionA] = cache_get_field_content_float(0, "PositionA", Mysql_users);
VehicleData[vehicleid][Health] = cache_get_field_content_float(0, "Health", Mysql_users);
VehicleData[vehicleid][Color1] = cache_get_field_content_int(0, "Color1", Mysql_users);
VehicleData[vehicleid][Color2] = cache_get_field_content_int(0, "Color2", Mysql_users);
VehicleData[vehicleid][Mod1] = cache_get_field_content_int(0, "Mod1", Mysql_users);
VehicleData[vehicleid][Mod2] = cache_get_field_content_int(0, "Mod2", Mysql_users);
VehicleData[vehicleid][Mod3] = cache_get_field_content_int(0, "Mod3", Mysql_users);
VehicleData[vehicleid][Mod4] = cache_get_field_content_int(0, "Mod4", Mysql_users);
VehicleData[vehicleid][Mod5] = cache_get_field_content_int(0, "Mod5", Mysql_users);
VehicleData[vehicleid][Mod6] = cache_get_field_content_int(0, "Mod6", Mysql_users);
VehicleData[vehicleid][Mod7] = cache_get_field_content_int(0, "Mod7", Mysql_users);
VehicleData[vehicleid][Mod8] = cache_get_field_content_int(0, "Mod8", Mysql_users);
VehicleData[vehicleid][Mod9] = cache_get_field_content_int(0, "Mod9", Mysql_users);
VehicleData[vehicleid][Mod10] = cache_get_field_content_int(0, "Mod10", Mysql_users);
VehicleData[vehicleid][Mod11] = cache_get_field_content_int(0, "Mod11", Mysql_users);
VehicleData[vehicleid][Mod12] = cache_get_field_content_int(0, "Mod12", Mysql_users);
VehicleData[vehicleid][Mod13] = cache_get_field_content_int(0, "Mod13", Mysql_users);
VehicleData[vehicleid][Mod14] = cache_get_field_content_int(0, "Mod14", Mysql_users);
VehicleData[vehicleid][Mod15] = cache_get_field_content_int(0, "Mod15", Mysql_users);
VehicleData[vehicleid][Mod16] = cache_get_field_content_int(0, "Mod16", Mysql_users);
VehicleData[vehicleid][Mod17] = cache_get_field_content_int(0, "Mod17", Mysql_users);
VehicleData[vehicleid][Trunk] = cache_get_field_content_int(0, "Trunk", Mysql_users);
VehicleData[vehicleid][DoorLock] = cache_get_field_content_int(0, "DoorLock", Mysql_users);
VehicleData[vehicleid][Bonnet] = cache_get_field_content_int(0, "Bonnet", Mysql_users);
VehicleData[vehicleid][Engine] = cache_get_field_content_int(0, "Engine", Mysql_users);
VehicleData[vehicleid][Lights] = cache_get_field_content_int(0, "Lights", Mysql_users);
VehicleData[vehicleid][Alarm] = cache_get_field_content_int(0, "Alarm", Mysql_users);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod1]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod2]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod3]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod4]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod5]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod6]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod7]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod8]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod9]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod10]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod11]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod12]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod13]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod14]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod15]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod16]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod17]);
SetVehicleHealth(vehicleid, VehicleData[vehicleid][Health]);
SetVehicleNumberPlate(vehicleid, VehicleData[vehicleid][Number]);
CreateVehicle(VehicleData[vehicleid][Model], VehicleData[vehicleid][PositionX], VehicleData[vehicleid][PositionY], VehicleData[vehicleid][PositionZ], VehicleData[vehicleid][PositionA], VehicleData[vehicleid][Color1], VehicleData[vehicleid][Color2], 1000);
SetVehicleParamsEx(VehicleData[vehicleid][Model], VehicleData[vehicleid][Engine], VehicleData[vehicleid][Lights], VehicleData[vehicleid][Alarm], VehicleData[vehicleid][DoorLock], VehicleData[vehicleid][Bonnet], VehicleData[vehicleid][Trunk], 0);
}
return 1;
}
forward SaveVehicleData();
public SaveVehicleData()
{
AntiDeAMX();
for(new vehicleid = 1;vehicleid<500;vehicleid++)
{
new objective;
GetVehiclePos(vehicleid, VehicleData[vehicleid][PositionX],VehicleData[vehicleid][PositionY],VehicleData[vehicleid][PositionZ]);
GetVehicleZAngle(vehicleid,VehicleData[vehicleid][PositionA]);
GetVehicleHealth(vehicleid, VehicleData[vehicleid][Health]);
GetVehicleParamsEx(VehicleData[vehicleid][Model], VehicleData[vehicleid][Engine], VehicleData[vehicleid][Lights], VehicleData[vehicleid][Alarm], VehicleData[vehicleid][DoorLock], VehicleData[vehicleid][Bonnet], VehicleData[vehicleid][Trunk], objective);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod1]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod2]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod3]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod4]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod5]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod6]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod7]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod8]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod9]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod10]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod11]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod12]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod13]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod14]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod15]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod16]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod17]);
mysql_format(Mysql_users, query, sizeof(query), "UPDATE `"MASINU_LENTELE"` SET Fullname='%e', Number='%e', Model='%d', PositionX='%f', PositionY='%f', PositionZ='%f', PositionA='%f', Health='%f', Color1='%d', Color2='%d', Mod1='%d', Mod2='%d', Mod3='%d', Mod4='%d', Mod5='%d', Mod6='%d', Mod7='%d'",\
VehicleData[vehicleid][Fullname],
VehicleData[vehicleid][Number],
VehicleData[vehicleid][Model],
VehicleData[vehicleid][PositionX],
VehicleData[vehicleid][PositionY],
VehicleData[vehicleid][PositionZ],
VehicleData[vehicleid][PositionA],
VehicleData[vehicleid][Health],
VehicleData[vehicleid][Color1],
VehicleData[vehicleid][Color2],
VehicleData[vehicleid][Mod1],
VehicleData[vehicleid][Mod2],
VehicleData[vehicleid][Mod3],
VehicleData[vehicleid][Mod4],
VehicleData[vehicleid][Mod5],
VehicleData[vehicleid][Mod6],
VehicleData[vehicleid][Mod7]);
mysql_format(Mysql_users, query, sizeof(query), "%s, Mod8='%d', Mod9='%d', Mod10='%d', Mod11='%d', Mod12='%d', Mod13='%d', Mod14='%d', Mod15='%d', Mod16='%d', Mod17='%d', Trunk='%d', DoorLock='%d', Bonnet='%d', Engine='%d', Lights='%d', Alarm='%d' WHERE Fullname='%e'",\
query,
VehicleData[vehicleid][Mod8],
VehicleData[vehicleid][Mod9],
VehicleData[vehicleid][Mod10],
VehicleData[vehicleid][Mod11],
VehicleData[vehicleid][Mod12],
VehicleData[vehicleid][Mod13],
VehicleData[vehicleid][Mod14],
VehicleData[vehicleid][Mod15],
VehicleData[vehicleid][Mod16],
VehicleData[vehicleid][Mod17],
VehicleData[vehicleid][Trunk],
VehicleData[vehicleid][Lights],
VehicleData[vehicleid][Bonnet],
VehicleData[vehicleid][Engine],
VehicleData[vehicleid][Alarm],
VehicleData[vehicleid][Fullname]);
mysql_tquery(Mysql_users, query, "", "");
}
}
when im login, got flood 2MB/5s mysql_log:
Код:
...
[21:36:26] [DEBUG] cache_get_field_content - row: 0, field_name: "Fullname", connection: 1, max_len: 129
[21:36:26] [WARNING] cache_get_field_content - no active cache
[21:36:26] [DEBUG] cache_get_field_content - row: 0, field_name: "Number", connection: 1, max_len: 126
[21:36:26] [WARNING] cache_get_field_content - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Model", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_float - row: 0, field_name: "PositionX", connection: 1
[21:36:26] [WARNING] cache_get_field_content_float - no active cache
[21:36:26] [DEBUG] cache_get_field_content_float - row: 0, field_name: "PositionY", connection: 1
[21:36:26] [WARNING] cache_get_field_content_float - no active cache
[21:36:26] [DEBUG] cache_get_field_content_float - row: 0, field_name: "PositionZ", connection: 1
[21:36:26] [WARNING] cache_get_field_content_float - no active cache
[21:36:26] [DEBUG] cache_get_field_content_float - row: 0, field_name: "PositionA", connection: 1
[21:36:26] [WARNING] cache_get_field_content_float - no active cache
[21:36:26] [DEBUG] cache_get_field_content_float - row: 0, field_name: "Health", connection: 1
[21:36:26] [WARNING] cache_get_field_content_float - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Color1", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Color2", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod1", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod2", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod3", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod4", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod5", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod6", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod7", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod8", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod9", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod10", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod11", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod12", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod13", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod14", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod15", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod16", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Mod17", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Trunk", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "DoorLock", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Bonnet", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Engine", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Lights", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:36:26] [DEBUG] cache_get_field_content_int - row: 0, field_name: "Alarm", connection: 1
[21:36:26] [WARNING] cache_get_field_content_int - no active cache
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "UPDATE `accounts` SET Fullname='%e', Password='%e', PositionX='%f', PositionY='%f', PositionZ='%f', PositionA='%f', Health='%f',..."
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "%s, Warnings='%d', Warning1Reason='%e', Warning2Reason='%e', Warning3Reason='%e', WarnedBy1='%e', WarnedBy2='%e', WarnedBy3='%e'..."
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "%s, Helper='%d', Money='%d', MoneyBank='%d', Score='%d', Skin='%d', Hour='%d', Min='%d', Sec='%d', Kills='%d', Deaths='%d', Kred..."
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "%s, Weapon1='%d', Weapon1a='%d', Weapon2='%d', Weapon2a='%d', Weapon3='%d', Weapon3a='%d', Weapon4='%d', Weapon4a='%d', Weapon5=..."
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "%s, Weapon7='%d', Weapon7a='%d', Weapon8='%d', Weapon8a='%d', Weapon9='%d', Weapon9a='%d', Weapon10='%d', Weapon10a='%d', Weapon..."
[21:37:56] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `accounts` SET Fullname='The_Nerka', Password='41479FC4C3", callback: "(null)", format: "(null)"
[21:37:56] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "UPDATE `vehicles` SET Fullname='%e', Number='%e', Model='%d', PositionX='%f', PositionY='%f', PositionZ='%f', PositionA='%f', He..."
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "%s, Mod8='%d', Mod9='%d', Mod10='%d', Mod11='%d', Mod12='%d', Mod13='%d', Mod14='%d', Mod15='%d', Mod16='%d', Mod17='%d', Trunk=..."
[21:37:56] [ERROR] mysql_format - no value for specifier "%e" available
[21:37:56] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `vehicles` SET Fullname='', Number='', Model='0', Positio", callback: "(null)", format: "(null)"
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "UPDATE `vehicles` SET Fullname='%e', Number='%e', Model='%d', PositionX='%f', PositionY='%f', PositionZ='%f', PositionA='%f', He..."
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "%s, Mod8='%d', Mod9='%d', Mod10='%d', Mod11='%d', Mod12='%d', Mod13='%d', Mod14='%d', Mod15='%d', Mod16='%d', Mod17='%d', Trunk=..."
[21:37:56] [ERROR] mysql_format - no value for specifier "%e" available
[21:37:56] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `vehicles` SET Fullname='', Number='', Model='0', Positio", callback: "(null)", format: "(null)"
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "UPDATE `vehicles` SET Fullname='%e', Number='%e', Model='%d', PositionX='%f', PositionY='%f', PositionZ='%f', PositionA='%f', He..."
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "%s, Mod8='%d', Mod9='%d', Mod10='%d', Mod11='%d', Mod12='%d', Mod13='%d', Mod14='%d', Mod15='%d', Mod16='%d', Mod17='%d', Trunk=..."
[21:37:56] [ERROR] mysql_format - no value for specifier "%e" available
[21:37:56] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `vehicles` SET Fullname='', Number='', Model='0', Positio", callback: "(null)", format: "(null)"
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "UPDATE `vehicles` SET Fullname='%e', Number='%e', Model='%d', PositionX='%f', PositionY='%f', PositionZ='%f', PositionA='%f', He..."
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "%s, Mod8='%d', Mod9='%d', Mod10='%d', Mod11='%d', Mod12='%d', Mod13='%d', Mod14='%d', Mod15='%d', Mod16='%d', Mod17='%d', Trunk=..."
[21:37:56] [ERROR] mysql_format - no value for specifier "%e" available
[21:37:56] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `vehicles` SET Fullname='', Number='', Model='0', Positio", callback: "(null)", format: "(null)"
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "UPDATE `vehicles` SET Fullname='%e', Number='%e', Model='%d', PositionX='%f', PositionY='%f', PositionZ='%f', PositionA='%f', He..."
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "%s, Mod8='%d', Mod9='%d', Mod10='%d', Mod11='%d', Mod12='%d', Mod13='%d', Mod14='%d', Mod15='%d', Mod16='%d', Mod17='%d', Trunk=..."
[21:37:56] [ERROR] mysql_format - no value for specifier "%e" available
[21:37:56] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `vehicles` SET Fullname='', Number='', Model='0', Positio", callback: "(null)", format: "(null)"
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "UPDATE `vehicles` SET Fullname='%e', Number='%e', Model='%d', PositionX='%f', PositionY='%f', PositionZ='%f', PositionA='%f', He..."
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "%s, Mod8='%d', Mod9='%d', Mod10='%d', Mod11='%d', Mod12='%d', Mod13='%d', Mod14='%d', Mod15='%d', Mod16='%d', Mod17='%d', Trunk=..."
[21:37:56] [ERROR] mysql_format - no value for specifier "%e" available
[21:37:56] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE `vehicles` SET Fullname='', Number='', Model='0', Positio", callback: "(null)", format: "(null)"
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "UPDATE `vehicles` SET Fullname='%e', Number='%e', Model='%d', PositionX='%f', PositionY='%f', PositionZ='%f', PositionA='%f', He..."
[21:37:56] [DEBUG] mysql_format - connection: 1, len: 4098, format: "%s, Mod8='%d', Mod9='%d', Mod10='%d', Mod11='%d', Mod12='%d', Mod13='%d', Mod14='%d', Mod15='%d', Mod16='%d', Mod17='%d', Trunk=..."
Re: How to load and save vehicles from MySQL R38? -
Ox1gEN - 10.09.2014
Well, you haven't retreived any data...
Use:
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
//Your code to load/save or whatever
}
In your loading code, and in the saving code just save it using a simple mysql query.
Re: How to load and save vehicles from MySQL R38? -
TheNerka - 10.09.2014
not saving car pos and not loading
Re: How to load and save vehicles from MySQL R38? -
Ox1gEN - 10.09.2014
pawn Код:
forward LoadVehicleData();
public LoadVehicleData()
{
AntiDeAMX();
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
for(new vehicleid = 1;vehicleid<100;vehicleid++)
{
cache_get_field_content(0, "Fullname", VehicleData[vehicleid][Fullname], Mysql_users, 129);
cache_get_field_content(0, "Number", VehicleData[vehicleid][Number], Mysql_users, 126);
VehicleData[vehicleid][Model] = cache_get_field_content_int(0, "Model", Mysql_users);
VehicleData[vehicleid][PositionX] = cache_get_field_content_float(0, "PositionX", Mysql_users);
VehicleData[vehicleid][PositionY] = cache_get_field_content_float(0, "PositionY", Mysql_users);
VehicleData[vehicleid][PositionZ] = cache_get_field_content_float(0, "PositionZ", Mysql_users);
VehicleData[vehicleid][PositionA] = cache_get_field_content_float(0, "PositionA", Mysql_users);
VehicleData[vehicleid][Health] = cache_get_field_content_float(0, "Health", Mysql_users);
VehicleData[vehicleid][Color1] = cache_get_field_content_int(0, "Color1", Mysql_users);
VehicleData[vehicleid][Color2] = cache_get_field_content_int(0, "Color2", Mysql_users);
VehicleData[vehicleid][Mod1] = cache_get_field_content_int(0, "Mod1", Mysql_users);
VehicleData[vehicleid][Mod2] = cache_get_field_content_int(0, "Mod2", Mysql_users);
VehicleData[vehicleid][Mod3] = cache_get_field_content_int(0, "Mod3", Mysql_users);
VehicleData[vehicleid][Mod4] = cache_get_field_content_int(0, "Mod4", Mysql_users);
VehicleData[vehicleid][Mod5] = cache_get_field_content_int(0, "Mod5", Mysql_users);
VehicleData[vehicleid][Mod6] = cache_get_field_content_int(0, "Mod6", Mysql_users);
VehicleData[vehicleid][Mod7] = cache_get_field_content_int(0, "Mod7", Mysql_users);
VehicleData[vehicleid][Mod8] = cache_get_field_content_int(0, "Mod8", Mysql_users);
VehicleData[vehicleid][Mod9] = cache_get_field_content_int(0, "Mod9", Mysql_users);
VehicleData[vehicleid][Mod10] = cache_get_field_content_int(0, "Mod10", Mysql_users);
VehicleData[vehicleid][Mod11] = cache_get_field_content_int(0, "Mod11", Mysql_users);
VehicleData[vehicleid][Mod12] = cache_get_field_content_int(0, "Mod12", Mysql_users);
VehicleData[vehicleid][Mod13] = cache_get_field_content_int(0, "Mod13", Mysql_users);
VehicleData[vehicleid][Mod14] = cache_get_field_content_int(0, "Mod14", Mysql_users);
VehicleData[vehicleid][Mod15] = cache_get_field_content_int(0, "Mod15", Mysql_users);
VehicleData[vehicleid][Mod16] = cache_get_field_content_int(0, "Mod16", Mysql_users);
VehicleData[vehicleid][Mod17] = cache_get_field_content_int(0, "Mod17", Mysql_users);
VehicleData[vehicleid][Trunk] = cache_get_field_content_int(0, "Trunk", Mysql_users);
VehicleData[vehicleid][DoorLock] = cache_get_field_content_int(0, "DoorLock", Mysql_users);
VehicleData[vehicleid][Bonnet] = cache_get_field_content_int(0, "Bonnet", Mysql_users);
VehicleData[vehicleid][Engine] = cache_get_field_content_int(0, "Engine", Mysql_users);
VehicleData[vehicleid][Lights] = cache_get_field_content_int(0, "Lights", Mysql_users);
VehicleData[vehicleid][Alarm] = cache_get_field_content_int(0, "Alarm", Mysql_users);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod1]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod2]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod3]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod4]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod5]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod6]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod7]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod8]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod9]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod10]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod11]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod12]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod13]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod14]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod15]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod16]);
AddVehicleComponent(vehicleid, VehicleData[vehicleid][Mod17]);
SetVehicleHealth(vehicleid, VehicleData[vehicleid][Health]);
SetVehicleNumberPlate(vehicleid, VehicleData[vehicleid][Number]);
CreateVehicle(VehicleData[vehicleid][Model], VehicleData[vehicleid][PositionX], VehicleData[vehicleid][PositionY], VehicleData[vehicleid][PositionZ], VehicleData[vehicleid][PositionA], VehicleData[vehicleid][Color1], VehicleData[vehicleid][Color2], 1000);
SetVehicleParamsEx(VehicleData[vehicleid][Model], VehicleData[vehicleid][Engine], VehicleData[vehicleid][Lights], VehicleData[vehicleid][Alarm], VehicleData[vehicleid][DoorLock], VehicleData[vehicleid][Bonnet], VehicleData[vehicleid][Trunk], 0);
}
}
return 1;
}
EDIT: How would you expect it to load if you're not saving it correctly, check your saving query.
Re: How to load and save vehicles from MySQL R38? -
TheNerka - 10.09.2014
my savevehicle
Код:
forward SaveVehicleData();
public SaveVehicleData()
{
AntiDeAMX();
for(new vehicleid = 1;vehicleid<500;vehicleid++)
{
new objective;
GetVehiclePos(vehicleid, VehicleData[vehicleid][PositionX],VehicleData[vehicleid][PositionY],VehicleData[vehicleid][PositionZ]);
GetVehicleZAngle(vehicleid,VehicleData[vehicleid][PositionA]);
GetVehicleHealth(vehicleid, VehicleData[vehicleid][Health]);
GetVehicleParamsEx(VehicleData[vehicleid][Model], VehicleData[vehicleid][Engine], VehicleData[vehicleid][Lights], VehicleData[vehicleid][Alarm], VehicleData[vehicleid][DoorLock], VehicleData[vehicleid][Bonnet], VehicleData[vehicleid][Trunk], objective);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod1]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod2]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod3]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod4]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod5]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod6]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod7]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod8]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod9]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod10]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod11]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod12]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod13]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod14]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod15]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod16]);
GetVehicleComponentInSlot(vehicleid, VehicleData[vehicleid][Mod17]);
mysql_format(Mysql_users, query, sizeof(query), "UPDATE `"MASINU_LENTELE"` SET Fullname='%e', Number='%e', Model='%d', PositionX='%f', PositionY='%f', PositionZ='%f', PositionA='%f', Health='%f', Color1='%d', Color2='%d', Mod1='%d', Mod2='%d', Mod3='%d', Mod4='%d', Mod5='%d', Mod6='%d', Mod7='%d'",\
VehicleData[vehicleid][Fullname],
VehicleData[vehicleid][Number],
VehicleData[vehicleid][Model],
VehicleData[vehicleid][PositionX],
VehicleData[vehicleid][PositionY],
VehicleData[vehicleid][PositionZ],
VehicleData[vehicleid][PositionA],
VehicleData[vehicleid][Health],
VehicleData[vehicleid][Color1],
VehicleData[vehicleid][Color2],
VehicleData[vehicleid][Mod1],
VehicleData[vehicleid][Mod2],
VehicleData[vehicleid][Mod3],
VehicleData[vehicleid][Mod4],
VehicleData[vehicleid][Mod5],
VehicleData[vehicleid][Mod6],
VehicleData[vehicleid][Mod7]);
mysql_format(Mysql_users, query, sizeof(query), "%s, Mod8='%d', Mod9='%d', Mod10='%d', Mod11='%d', Mod12='%d', Mod13='%d', Mod14='%d', Mod15='%d', Mod16='%d', Mod17='%d', Trunk='%d', DoorLock='%d', Bonnet='%d', Engine='%d', Lights='%d', Alarm='%d' WHERE Fullname='%e'",\
query,
VehicleData[vehicleid][Mod8],
VehicleData[vehicleid][Mod9],
VehicleData[vehicleid][Mod10],
VehicleData[vehicleid][Mod11],
VehicleData[vehicleid][Mod12],
VehicleData[vehicleid][Mod13],
VehicleData[vehicleid][Mod14],
VehicleData[vehicleid][Mod15],
VehicleData[vehicleid][Mod16],
VehicleData[vehicleid][Mod17],
VehicleData[vehicleid][Trunk],
VehicleData[vehicleid][Lights],
VehicleData[vehicleid][Bonnet],
VehicleData[vehicleid][Engine],
VehicleData[vehicleid][Alarm],
VehicleData[vehicleid][Fullname]);
mysql_tquery(Mysql_users, query, "", "");
}
}
Re: How to load and save vehicles from MySQL R38? -
TheNerka - 11.09.2014
....
Re: How to load and save vehicles from MySQL R38? -
Ox1gEN - 11.09.2014
Gimmie the log of the saving query.
Re: How to load and save vehicles from MySQL R38? -
TheNerka - 11.09.2014
Not give log, but onplayerdisconnect have SaveVehiclePos();
UPDATE: created cmd with vehicle save got log:
Код:
[16:06:57] [DEBUG] cache_get_data - connection: 1
[16:06:57] [WARNING] cache_get_data - no active cache