SA-MP Forums Archive
Attachments MYSQL - 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: Attachments MYSQL (/showthread.php?tid=581608)



Attachments MYSQL - Scott Zulkifli - 14.07.2015

Код:
    new name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, name, MAX_PLAYER_NAME);
	new query[130];
    mysql_format(SQLHandle, query, sizeof(query), "SELECT * FROM attachments WHERE name='%e' AND indx='%d'", name, index);
	mysql_tquery(SQLHandle, query, "", "");
	
	new querys[1024];
	new rows, fields;
	cache_get_data(rows, fields, SQLHandle);
	if(rows)
	{
	    mysql_format(SQLHandle, querys, sizeof(querys), "UPDATE `attachments` SET model = %d, bone = %d, setX = %f, setY = %f, setZ = %f, rotX = %f, rotY = %f, rotZ = %f, sclX = %f, sclY = %f, sclZ = %f, WHERE `name` = %s AND `indx` = %d",
		modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ,name,index);
		mysql_tquery(SQLHandle, querys, "", "");
	}else{
     	mysql_format(SQLHandle, querys, sizeof(querys), "INSERT INTO `attachments`(`name`, `indx`, `model`, `bone`, `setX`, `setY`, `setZ`, `rotX`, `rotY`, `rotZ`, `sclX`, `sclY`, `sclZ`) VALUES (%e,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",
		name,index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
		mysql_tquery(SQLHandle, querys, "", "");
	}
INSERT INTO do not want to be entered into the database


Re: Attachments MYSQL - X337 - 14.07.2015

You need to escape string with single quotes :

Change :
Код:
mysql_format(SQLHandle, querys, sizeof(querys), "INSERT INTO `attachments`(`name`, `indx`, `model`, `bone`, `setX`, `setY`, `setZ`, `rotX`, `rotY`, `rotZ`, `sclX`, `sclY`, `sclZ`) VALUES (%e,%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",
To :
Код:
mysql_format(SQLHandle, querys, sizeof(querys), "INSERT INTO `attachments`(`name`, `indx`, `model`, `bone`, `setX`, `setY`, `setZ`, `rotX`, `rotY`, `rotZ`, `sclX`, `sclY`, `sclZ`) VALUES ('%e',%d,%d,%d,%f,%f,%f,%f,%f,%f,%f,%f,%f)",



Re: Attachments MYSQL - Scott Zulkifli - 14.07.2015

here fs : http://pastebin.com/KJz5GkWw
*Player Attachments system by Excel
I just change it to mysql,
something go wrong
when stored, the position is not exactly as edited. and when you back edit it will INSERT to the database is not UPDATE