SaveCar(vehicleid) not working.
#1

Hello every1, I was thinking alot of my time - but I didn't fix this "error".

I am saving Premier, but it won't save.
My code is:
Код:
SaveCar(vehicleid) {
	new Query[5024], Float:Pos[4], neni, doors, Float:vhp, panels, doors1, lights, tires,ts[14];
	printf("1");
	GetVehicleDamageStatus(vehicleid, panels, doors1, lights, tires);
	printf("2");
	GetVehicleParamsEx(vehicleid, neni, neni, neni, doors, neni, neni, neni);
	printf("3");
	GetVehicleHealth(vehicleid, vhp);
	printf("4");
	GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
	GetVehicleZAngle(vehicleid, Pos[3]);
	for(new i; i < 13; i++) ts[i] = GetVehicleComponentInSlot(vehicleid, i);
	printf("5");
	format(Query,5024,"UPDATE `cars` SET `x` = '%f', `y` = '%f', `z` = '%f', `a` = '%f', `vw` = '%d', `inter` = '%d', `far1` = '%d', `far2` = '%d',",Pos[0],Pos[1],Pos[2],Pos[3],GetVehicleVirtualWorld(vehicleid), 0, vehicle[vehicleid][FARBA1],vehicle[vehicleid][FARBA2]);
    printf("6");
	format(Query,5024,"%s`km` = '%f', `fuel` = '%d', `battery` = '%d', `vlock` = '%d', vhp = '%f', panels = '%d', doors = '%d', lights = '%d', tires = '%d', ts0 = '%d', ts1 = '%d', ts2 = '%d', ts3 = '%d', ts4 = '%d', ts5 = '%d', ts6 = '%d', ts7 = '%d', ts8 = '%d', ts9 = '%d', ts10 = '%d', ts11 = '%d', ts12 = '%d', ts13 = '%d', paintjob = '%d', tanked = '%d',tovar='%d',tovartyp='%d',radio='%d' WHERE spz = '%s'",
	Query,vehicle[vehicleid][KILOMETER],vehicle[vehicleid][FUEL],vehicle[vehicleid][BATTERY],doors,vhp,panels,doors1,lights,tires,ts[0],ts[1],ts[2],ts[3],ts[4],ts[5],ts[6],ts[7],ts[8],ts[9],ts[10],ts[11],ts[12],ts[13],vehicle[vehicleid][PAINTJOB], vehicle[vehicleid][TANKED], vehicle[vehicleid][TOVAR],vehicle[vehicleid][TOVARTYPE],vehicle[vehicleid][RADIO],vehicle[vehicleid][SPZ]);
    printf("7");
	mysql_query(Query);
	printf("8");
	mysql_free_result();
    printf("9");
	SetTimerEx("DestroyCar", 2000, false, "i", vehicleid);
	return 1;
}
Everything that prints in console is "1". Could you find the problem please?
"neni" = "nothing, unused".
Reply
#2

Bump
Reply
#3

You are formatting the query instead of combining them.

Use strcat, and please learn to organize your stuff (referring to Vince's Database Normalization) @ click here for more information about the Database Normalization.
Reply
#4

Hello there, now I changed my DB a little bit, but it is still not working,

Код:
SaveCar(vehicleid) {
	new Query[5024], Float:Pos[4], neni, doors, Float:vhp, panels, doors1, lights, tires,ts[14];
	printf("1");
	GetVehicleDamageStatus(vehicleid, panels, doors1, lights, tires);
	printf("2");
	GetVehicleParamsEx(vehicleid, neni, neni, neni, doors, neni, neni, neni);
	printf("3");
	GetVehicleHealth(vehicleid, vhp);
	printf("4");
	GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
	GetVehicleZAngle(vehicleid, Pos[3]);
	for(new i; i < 13; i++) ts[i] = GetVehicleComponentInSlot(vehicleid, i);
	printf("5");
	format(Query,5024,"UPDATE `cars` SET `x` = '%f', `y` = '%f', `z` = '%f', `a` = '%f', `vw` = '%d', `inter` = '%d', `far1` = '%d', `far2` = '%d',",Pos[0],Pos[1],Pos[2],Pos[3],GetVehicleVirtualWorld(vehicleid), 0, vehicle[vehicleid][FARBA1],vehicle[vehicleid][FARBA2]);
    printf("6");
	new Query1[5024];
    strcat(Query1, Query);
	format(Query,5024,"`km` = '%f', `fuel` = '%d', `battery` = '%d', `vlock` = '%d', vhp = '%f', panels = '%d', doors = '%d', lights = '%d', tires = '%d', ts0 = '%d', ts1 = '%d', ts2 = '%d', ts3 = '%d', ts4 = '%d', ts5 = '%d', ts6 = '%d', ts7 = '%d', ts8 = '%d', ts9 = '%d', ts10 = '%d', ts11 = '%d', ts12 = '%d', ts13 = '%d', paintjob = '%d', tanked = '%d',tovar='%d',tovartyp='%d',radio='%d' WHERE spz = '%s'",
	vehicle[vehicleid][KILOMETER],vehicle[vehicleid][FUEL],vehicle[vehicleid][BATTERY],doors,vhp,panels,doors1,lights,tires,ts[0],ts[1],ts[2],ts[3],ts[4],ts[5],ts[6],ts[7],ts[8],ts[9],ts[10],ts[11],ts[12],ts[13],vehicle[vehicleid][PAINTJOB], vehicle[vehicleid][TANKED], vehicle[vehicleid][TOVAR],vehicle[vehicleid][TOVARTYPE],vehicle[vehicleid][RADIO],vehicle[vehicleid][SPZ]);
	strcat(Query1, Query);
	printf("7");
	mysql_query(Query1);
	printf("8");
	mysql_free_result();
    printf("9");
	SetTimerEx("DestroyCar", 2000, false, "i", vehicleid);
	return 1;
}
- this is my new code, it is still printing just "1" in the console, nothing else.
Reply
#5

Quote:
Originally Posted by Bigwebicek
Посмотреть сообщение
- this is my new code, it is still printing just "1" in the console, nothing else.
if its just printing 1 then the script crashing, use crashdetect plugin and check what it will print for you, if you couldn't fix it post the logs here kindly.

Crashdetect link: https://sampforum.blast.hk/showthread.php?tid=262796
Reply
#6

Код:
[11:57:27] [debug] Run time error 4: "Array index out of bounds"
[11:57:27] [debug]  Accessing element at index 65535 past array upper bound 1999
[11:57:27] [debug] AMX backtrace:
[11:57:27] [debug] #0 0002d9f4 in ?? (4936108) from clrp.amx
[11:57:27] [debug] #1 0004fad0 in ?? (0) from clrp.amx
[11:57:27] [debug] #2 0007ba30 in public OnDialogResponse (0, 1, 1, -1, 16854984) from clrp.amx
[11:58:16] RCON (In-Game): Player [Bastiaan_Viltuautas] sent command: login ****
[11:58:17] RCON (In-Game): Player [Bastiaan_Viltuautas] sent command: gmx
[11:58:17] 1
[11:58:17] [debug] Run time error 3: "Stack/heap collision (insufficient stack size)"
[11:58:17] [debug]  Stack pointer (STK) is 0x10120F0, heap pointer (HEA) is 0x1012FC8
[11:58:17] [debug] AMX backtrace:
[11:58:17] [debug] #0 000565f8 in public CB_OnPlayerDisconnect (0, 1) from clrp.amx
[11:58:17] [debug] #1 00007ef8 in public SSCANF_OnPlayerDisconnect (0, 1) from clrp.amx
[11:58:17] [debug] #2 000005b4 in public OnPlayerDisconnect (0, 1) from clrp.amx
[11:58:17] MapFix by Nexius v2.4.8 unloaded.
that's what it prints.
below "[11:58:17] RCON (In-Game): Player [Bastiaan_Viltuautas] sent command: gmx" is car saving. I dont have any idea where's the problem
Reply
#7

Your query has size of 5024 which is causing run time error 3.

PHP код:
new Float:Pos[4], nenidoorsFloat:vhppanelsdoors1lightstires,ts[14];
static 
Query[450] = "UPDATE cars SET x=%f,y=%f,z=%f,a=%f,vw=%d,inter=%d,far1=%d,far2=%d," \
"km=%f,fuel=%d,battery=%d,vlock=%d,vhp=%f,panels=%d,doors=%d,lights=%d,tires=%d,ts0=%d,ts1=%d, ts2=%d,ts3=%d,ts4=%d,ts5=%d,ts6=%d,ts7=%d,ts8=%d,ts9=%d,ts10=%d,ts11=%d,ts12=%d,ts13=%d,paintjob=%d,tanked=%d,tovar=%d,tovartyp=%d,radio=%d WHERE spz='%s'";
format(Querysizeof QueryQuery,
Pos[0],Pos[1],Pos[2],Pos[3],GetVehicleVirtualWorld(vehicleid), 0vehicle[vehicleid][FARBA1],vehicle[vehicleid][FARBA2],
vehicle[vehicleid][KILOMETER],vehicle[vehicleid][FUEL],vehicle[vehicleid][BATTERY],doors,vhp,panels,doors1,lights,tires,ts[0],ts[1],ts[2],ts[3],ts[4],ts[5],ts[6],ts[7],ts[8],ts[9],ts[10],ts[11],ts[12],ts[13],vehicle[vehicleid][PAINTJOB], vehicle[vehicleid][TANKED], vehicle[vehicleid][TOVAR],vehicle[vehicleid][TOVARTYPE],vehicle[vehicleid][RADIO],vehicle[vehicleid][SPZ]); 
---

About run time error 4, you will need to create a file called pawn.cfg in pawno folder and write -d3 in it. Save it and re-compile the script. Start the server, join and if you get the logs again, post them here.

---

Something last: You don't need to free any result in queries that are not with SELECT. The version of the mysql plugin you are using is also outdated - consider updating eventually.
Reply
#8

Thank you, in meantime I found that the "bug" was in string size, now is saving car working properly. Thanks everyone for help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)