SA-MP Forums Archive
Help mysql crashing - 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)
+--- Thread: Help mysql crashing (/showthread.php?tid=413882)



Help mysql crashing - PaulDinam - 07.02.2013

Why this code is crashing my server:

Код:
stock AddLabelToFile(LabelID, LabelInfo[], color, Float:LX, Float:LY, Float:LZ)
{
	new Query[200];
	format(Query, sizeof(Query), "INSERT INTO `labels` (posx, posy, posz, color, labeltext) VALUES(%f, %f, %f, %d, '%s')", LX, LY, LZ, color, LabelInfo);
	mysql_function_query(dbHandle, Query, true, "OnLabelInsert", "is[128]dfff", LabelID, LabelInfo, color, LX, LY, LZ);
	return 1;
}

forward OnLabelInsert(LabelID, LabelInfo, color, LX, LY, LZ);
public OnLabelInsert(LabelID, LabelInfo, color, LX, LY, LZ)
{
	LabelsInfo[LabelID][tID] = mysql_insert_id();
	LabelsInfo[LabelID][LabelX] = LX;
	LabelsInfo[LabelID][LabelY] = LY;
	LabelsInfo[LabelID][LabelZ] = LZ;
	LabelsInfo[LabelID][LColor] = color;
	LabelsInfo[LabelID][LInfo] = LabelInfo;
	LabelsInfo[LabelID][LID] = CreateDynamic3DTextLabel(LabelsInfo[LabelID][LInfo], LabelsInfo[LabelID][LColor], LabelsInfo[LabelID][LabelX], LabelsInfo[LabelID][LabelY], LabelsInfo[LabelID][LabelZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
	return 1;
}



Re: Help mysql crashing - Vince - 07.02.2013

The format specifiers for the mysql plugin are not the same as those for sscanf. So a singular 's' without size will suffice. Next, if you want to pass a string to a function then that parameter must be declared as such in the function header. Same applies to floating point values.

pawn Код:
public OnLabelInsert(LabelID, LabelInfo[], color, Float:LX, Float:LY, Float:LZ)
I am surprised that you even ran this on your server, even though the compiler should have given you a ton of warnings (tag mismatch and such).


Re: Help mysql crashing - PaulDinam - 07.02.2013

thanks man, it works now
mysql is so fun, i've made tons of systems, doors, pickups ETC..