I can't use sql commands in my server
#1

Insert commands was good down here:

Код:
CMD:fcar(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 5)
		return 0;

	new modelid, color1, color2, factionid;

	if(sscanf(params, "iiii", modelid, color1, color2, factionid))
	{
		SendUsageMessage(playerid, "/fcar [model id] [color1] [color2] [faction]");
		SendServerMessage(playerid, "These vehicles are temporary. Siren allows you to turn sirens on using horn.");
		return 1;
	}

	if(gettime() - lastVehicleSpawn[playerid] < 5)
		return SendServerMessage(playerid, "You need to wait before spawning another vehicle.");

	if(modelid < 400 || modelid > 611)
		return SendErrorMessage(playerid, "You specified an invalid model.");

	if(color1 < 0 || color2 < 0 || color1 > 255 || color2 > 255)
		return SendErrorMessage(playerid, "A color you specified was invalid.");
		
    if(!FactionInfo[factionid][eFactionDBID]) return SendErrorMessage(playerid, "The faction you specified doesn't exist.");

	new
		Float:x,
		Float:y,
		Float:z,
		Float:a
	;
	
	GetPlayerPos(playerid, x, y, z);
	GetPlayerFacingAngle(playerid, a);

	new insertQuery[256];

	mysql_format(ourConnection, insertQuery, sizeof(insertQuery), "INSERT INTO vehicles (`VehicleFaction`, `VehicleModel`, `VehicleColor1`, `VehicleColor2`, `VehicleParkPosX`, `VehicleParkPosY`, `VehicleParkPosZ`, `VehicleParkPosA`) VALUES(%i, %i, %i, %i, %f, %f, %f, %f)",
		factionid, modelid, color1, color2, x, y, z, a);
	mysql_tquery(ourConnection, insertQuery, "OnVehicleAdd", "iiiiiffff", playerid, factionid, modelid, color1, color2, x, y, z, a);
	return 1;
}
CreateVehicle after used /fcar

Код:
function:OnVehicleAdd(playerid, factionid, modelid, color1, color2, Float:x, Float:y, Float:z, Float:a)
{
	new
		vehicleid = INVALID_VEHICLE_ID
	;

	vehicleid =
		CreateVehicle(modelid, x, y, z, a, color1, color2, -1);

	PutPlayerInVehicle(playerid, vehicleid, 0);
//	PlayerInfo[playerid][pOwnedVehicles][id] = cache_insert_id();

	if(vehicleid != INVALID_VEHICLE_ID)
	{
		VehicleInfo[vehicleid][eVehicleAdminSpawn] = true;
		VehicleInfo[vehicleid][eVehicleModel] = modelid;

		VehicleInfo[vehicleid][eVehicleColor1] = color1;
		VehicleInfo[vehicleid][eVehicleColor2] = color2;

		VehicleInfo[vehicleid][eVehicleFaction] = factionid;
		SaveVehicle(vehicleid);
	}

	SendClientMessageEx(playerid, 0xB9E35EFF, "PROCESSED: ¤Шідґй·УЎТГбНґВТ№ѕТЛ№Р Modelid: %d аўйТ Faction: %d", modelid, factionid);
	return 1;
}
The commands for saving vehicle here is the problem no saving on mysql nothing change
But if i restart my server so i can use this commands /fcarsave and everything good
I mean if you use /fcar to create some vehicle and /fcarsave not work after restart everything work
MySQL r39-6 plugins PS. Sorry for my english

Код:
CMD:fcarsave(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] < 5)
		return 0;

    new vehicleid = GetPlayerVehicleID(playerid);
    new Float:vehx, Float:vehy, Float:vehz, Float:veha;
    GetVehiclePos(vehicleid, vehx, vehy, vehz);
	GetVehicleZAngle(vehicleid, veha);
	
	if(vehicleid != INVALID_VEHICLE_ID)
	{
		VehicleInfo[vehicleid][eVehicleParkPos][0] = vehx;
		VehicleInfo[vehicleid][eVehicleParkPos][1] = vehy;
		VehicleInfo[vehicleid][eVehicleParkPos][2] = vehz;
		VehicleInfo[vehicleid][eVehicleParkPos][3] = veha;
	}
	SendServerMessage(playerid, "Save vehicle park complete");
	SaveVehicle(vehicleid);
	printf("VX: %f VY: %f VZ: %f VA: %f", vehx, vehy, vehz, veha);
	return 1;
}
SaveVehicle code

Код:
stock SaveVehicle(vehicleid)
{
	new query[256];
	
	mysql_format(ourConnection, query, sizeof(query), "UPDATE vehicles SET VehicleOwnerDBID = %i, VehicleFaction = %i, VehicleColor1 = %i, VehicleColor2 = %i, VehiclePaintjob = %i, VehiclePlates = '%e', VehicleLocked = %i, VehicleSirens = %i, VehicleFuel = %i WHERE VehicleDBID = %i",
		VehicleInfo[vehicleid][eVehicleOwnerDBID], 
		VehicleInfo[vehicleid][eVehicleFaction],
		VehicleInfo[vehicleid][eVehicleColor1],
		VehicleInfo[vehicleid][eVehicleColor2],
		VehicleInfo[vehicleid][eVehiclePaintjob],
		VehicleInfo[vehicleid][eVehiclePlates],
		VehicleInfo[vehicleid][eVehicleLocked],
		VehicleInfo[vehicleid][eVehicleSirens],
		VehicleInfo[vehicleid][eVehicleFuel],
		VehicleInfo[vehicleid][eVehicleDBID]);
	mysql_tquery(ourConnection, query);
	
	mysql_format(ourConnection, query, sizeof(query), "UPDATE vehicles SET VehicleXMR = %i, VehicleBattery = %f, VehicleEngine = %f, VehicleTimesDestroyed = %i WHERE VehicleDBID = %i",
		VehicleInfo[vehicleid][eVehicleHasXMR],
		VehicleInfo[vehicleid][eVehicleBattery],
		VehicleInfo[vehicleid][eVehicleEngine],
		VehicleInfo[vehicleid][eVehicleTimesDestroyed],
		VehicleInfo[vehicleid][eVehicleDBID]);
	mysql_tquery(ourConnection, query);
	
	mysql_format(ourConnection, query, sizeof(query), "UPDATE vehicles SET VehicleParkPosX = %f, VehicleParkPosY = %f, VehicleParkPosZ = %f, VehicleParkPosA = %f, VehicleParkInterior = %i, VehicleParkWorld = %i WHERE VehicleDBID = %i",
		VehicleInfo[vehicleid][eVehicleParkPos][0],
		VehicleInfo[vehicleid][eVehicleParkPos][1], 
		VehicleInfo[vehicleid][eVehicleParkPos][2],
		VehicleInfo[vehicleid][eVehicleParkPos][3],
		VehicleInfo[vehicleid][eVehicleParkInterior],
		VehicleInfo[vehicleid][eVehicleParkWorld],
		VehicleInfo[vehicleid][eVehicleDBID]);
	mysql_tquery(ourConnection, query);
	
	mysql_format(ourConnection, query, sizeof(query), "UPDATE vehicles SET VehicleImpounded = %i, VehicleImpoundPosX = %f, VehicleImpoundPosY = %f, VehicleImpoundPosZ = %f, VehicleImpoundPosA = %f WHERE VehicleDBID = %i",
		VehicleInfo[vehicleid][eVehicleImpounded],
		VehicleInfo[vehicleid][eVehicleImpoundPos][0],
		VehicleInfo[vehicleid][eVehicleImpoundPos][1],
		VehicleInfo[vehicleid][eVehicleImpoundPos][2],
		VehicleInfo[vehicleid][eVehicleImpoundPos][3],
		VehicleInfo[vehicleid][eVehicleDBID]);
	mysql_tquery(ourConnection, query);
	
	for(new i = 1; i < 6; i++)
	{
		mysql_format(ourConnection, query, sizeof(query), "UPDATE vehicles SET VehicleWeapons%d = %i, VehicleWeaponsAmmo%d = %i WHERE VehicleDBID = %i",
			i,
			VehicleInfo[vehicleid][eVehicleWeapons][i],
			i,
			VehicleInfo[vehicleid][eVehicleWeaponsAmmo][i],
			VehicleInfo[vehicleid][eVehicleDBID]);
		mysql_tquery(ourConnection, query);
	}
	
	for(new j = 1; j < 5; j++)
	{
		mysql_format(ourConnection, query, sizeof(query), "UPDATE vehicles SET VehicleLastDrivers%d = %i, VehicleLastPassengers%d = %i WHERE VehicleDBID = %i",
			j,
			VehicleInfo[vehicleid][eVehicleLastDrivers][j],
			j,
			VehicleInfo[vehicleid][eVehicleLastPassengers][j],
			VehicleInfo[vehicleid][eVehicleDBID]);
		mysql_tquery(ourConnection, query);
			
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)